Showing posts with label inside. Show all posts
Showing posts with label inside. Show all posts

Wednesday, March 28, 2012

updatepanel

Hi,

I am using updatepanel to update a message that's to be show to the user. I have a textbox with the submit button inside another updatepanel. Once the user hits a submit I have to display whatever he entered in the textbox.

The problem I am having is that the div (which displays result, can a server side control too), just appends the new text to the original value. So if I hit enter a multiple times, it goes on appending!

Am I missing something here?

Thanks!

Can you show the code that move the text from the textbox to the div?


Please show an example of what you are doing.


HtmlGenericControl DivControl = new HtmlGenericControl();

DivControl = (HtmlGenericControl)ResultsDiv;

DivControl.InnerHTML = txtReply.Text;

This comes up when the submit button's pressed.


Is there some reason you couldn't use a Label inside the div as your target? (I'm just trying to prevent the innerHTML thing from being the issue...)


hi, no, I tried label too. but did not work out. If you can paste the code for that, it would be really helpful.

Thanks!


I'm not sure why your code isn't doing what you expect it to, but here's some code that seems to work fine, using a Label:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void button_click(object sender, EventArgs e) { Label1.Text = TextBox1.Text; }</script><html xmlns="http://www.w3.org/1999/xhtml" ><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:TextBox ID="TextBox1" runat="server" /> <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="button_click" /> <asp:Label ID="Label1" runat="server" /> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

Just a Small Correction, As you want to append the Text each time the button is pressed, the click handler should be:

protected void button_click(object sender, EventArgs e)
{
Label1.Text += TextBox1.Text;
}

Everything else is fine with the above example.


I thought he explicitlydidn't want to append?

From original post: "The problem I am having is that the div (which displays result, can a server side control too), just appends the new text to the original value. So if I hit enter a multiple times, it goes on appending!"


Sorry my mistake, the Requirment is not to append.


Hi mate, works like a charm! Thanks!

UpdatePanel - DataGrid - Client Refresh

hi
I have a GridView inside a UpdatePanel


the case is: The user open a new window, select new items witch afect the data displayed in the DataGrid.

I want to update de GridView content via a Javascript method is there a way to do that?


thanks for any help

hello.

an easy way to do this is to add a dummy button and then perform a click programatically on that button. this should be enough to force the postback. you can also take a look at the postbackaction or event call the _dopostback method directly.


That Works fine
Thanks Madeira  
function RefreshGridView(){__doPostBack('Button1','');//Button.click();}

That Works fine
Thanks Luis Abreu
function RefreshGridView(){__doPostBack('Button1','');//Button.click();}

Does this only work from within the update panel?

I'm trying it from outside the panel and it is refreshing the whole page.

UpdatePanel - Javascript Refresh

hi
I have a GridView inside a UpdatePanel


the case is: The user open a new window, select new items witch afect the data displayed in the DataGrid.

I want to update de GridView content via a Javascript method is there a way to do that?


thanks for any help

I think this is possible. I've got the initial idea fromhere.
So put a hidden div into the UpdatePanel, for example:

<div style="display:none;">
<asp:Button id="btnHidden" runat="server" OnClick="btnHidden_Click" UseSubmitBehavior="false" /></div>

Then "trigger" this button in your popup window from javascript:

var refreshHelper = window.opener.document.getElementById( "btnHidden" );
refreshHelper.click( );

It works for me, but maybe there is smarter solutions than this.

hello.

well, currently you have 2 options: use the "dummy" button or use the postback action introduced by atlas.


Luis Abreu:

hello.

well, currently you have 2 options: use the "dummy" button or use the postback action introduced by atlas.

Luis (or anyone else), can you provide an example of using postback action? I'm trying to accomplish something very similar and the dummy button approach doesn't appeal to me.

-Lee


hello.

well, the dopostback action (or, if you want to use javascript, the __doPostBack method) will only work out correctly if there's a control placed inside the form which will be considered responsible for the postback.


Hi Luis,

I do have a a DropDownList that is inside the form so I that would work. I suppose I could just call the __doPostPack method, but I was hoping there would be something that was specific to ATLAS that would force the UpdatePanel to refresh.


hello again,

well, i guess that the answer is no, there isn't. and the reason is simple too: the update panel is just a delimiter that identifies a region which will be refreshed dinamically. all the partial postbacks are controlled by the pagerequestmanager object which uses the updatepanels defined on the page (normally divs or spans) to decide if it should perform a partial or a complete postback.


Ok, so what would you say would be the best way to accomplish this? It sounds as though the options are limited to the dummy button approach or explicitly calling __doPostBack.

hello again.

yep, that's it. i think that currently, there's no other option to perform that kind of operation.

Monday, March 26, 2012

UpdatePanel & AccordionExtender

To all,

this is what i have so far.. a nested repeater that displays info from a datasource... the repeaters sits inside a updatepanel which has a conditional mode that should re-render (dont know if thats the right terminology) itself base on an event...

now.. i have so far managed to get the accordion extender working such that the updatepanel re-render itself to give out the right data... but ONLY if the scriptmanager having the PartialRendering as false... ie.. the re-rendering works if the whole page is rendered... the the partial rendering is true... the repeated accordion inside the update panel all expands and the accordion action no longer works... pretty much to the point where its similar to a treeview...

below is a snippet of my code...

<div id="navigation_left" runat="server" class="accordionSpan" >
<asp:Panel ID="Panel2" runat="server">
<atlas:UpdatePanel ID="UpdatePanel1" Mode="Conditional" runat="server" RenderMode="Inline">
<Triggers>
<atlas:ControlEventTrigger ControlID="StateRadioBtnLst" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:Repeater ID="rMyRepeater" runat="server">
<ItemTemplate>
<span id="Accordion1Pane">
<div><div class="accordionHeader">
<%# Eval("Name") %>
</div></div>
<div><div class="accordionContent">
<asp:Repeater ID="rMyRepeater1" runat="server" DataSource='<%# ((BusinessObjects.MatterCategorieJoin)Container.DataItem).MatterType %>'>
<ItemTemplate>
<div><%# ((BusinessObjects.MatterType)(Container.DataItem)).Name%></div>
</ItemTemplate>
</asp:Repeater>
</div></div></span>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</atlas:UpdatePanel>
</asp:Panel>
</div>

<atlas:AccordionExtender ID="AccordionExtender1" runat="server">
<atlas:AccordionProperties
TargetControlID="UpdatePanel1"
AutoSize="None"
SelectedIndex="0"
FadeTransitions="false"
FramesPerSecond="80"
TransitionDuration="150"/>
</atlas:AccordionExtender>

anyone with any idea of help??...
thanks to all who replies...

Hi tony_c,

Part of the problem is that you don't seem to have the right hierarchy of HTML elements. Check out the posthttp://forums.asp.net/thread/1333093.aspx to see how the divs and span should be nested. I would also recommend that you don't use the UpdatePanel as the TargetControlID. I'm not sure this is causing your problems, but it looks suspect.

Thanks,
Ted

UpdatePanel & Opening a new window when returning from code-behind

Hi there,

Here's the OnClick event code for a button inside an UpdatePanel:

protected void btnReport_Click(object sender, EventArgs e)
{
this.ClientScript.RegisterStartupScript(this.GetType(), "viewRepo", "<script>window.open('RepoViewer.aspx','viewReport')</script>");
}

As you can see, after returning from code-behind I want to open a new browser window with a given web form. Well, this works correctly without an UpdatePanel, or when EnablePartialRendering is set to false.

If EnablePartialRendering is set to true, a new window does not open.

Any workarounds?

-Benton

I'm having the same issue.

Rob


Hi Benton,

I'd the same problem, but I solve it, use've just to remove the tag scrip from your code (belive, it works!!!)

I used before this:

Sub wOpen(ByVal fWindow As String, ByVal fNameWin As String, ByVal fWidth As Integer, ByVal fHeight As Integer, ByVal fMenu As Boolean, ByVal fResizable As Boolean, ByVal fScroll As Boolean)
Dim strJ As String
strJ = "<script language='text/javascript'>"
strJ &= "window.open('" & fWindow & "', '" & fNameWin & "', "
strJ &= "'width=" & fWidth & ", height=" & fHeight & ", menubar="
If fMenu = True Then
strJ &= "yes"
Else
strJ &= "no"
End If
strJ &= ", resizable="
If fResizable = True Then
strJ &= "yes"
Else
strJ &= "no"
End If
strJ &= ", scrollbars="
If fScroll = True Then
strJ &= "yes"
Else
strJ &= "no"
End If
strJ &= "')<"
strJ &= "/script>"
'Page.RegisterClientScriptBlock("wOpen", strJ)
'Me.ClientScript.RegisterStartupScript(Me.Page.GetType(), "wOpen", strJ, True)
Me.ClientScript.RegisterStartupScript(Me.GetType(), "wOpen", strJ, True)
End Sub

And now I'm using:
Sub xOpen(ByVal fWindow As String, ByVal fNameWin As String, ByVal fWidth As Integer, ByVal fHeight As Integer, ByVal fMenu As Boolean, ByVal fResizable As Boolean, ByVal fScroll As Boolean)
Dim strJ As String
strJ = "window.open('" & fWindow & "', '" & fNameWin & "', "
strJ &= "'width=" & fWidth & ", height=" & fHeight & ", menubar="
If fMenu = True Then
strJ &= "yes"
Else
strJ &= "no"
End If
strJ &= ", resizable="
If fResizable = True Then
strJ &= "yes"
Else
strJ &= "no"
End If
strJ &= ", scrollbars="
If fScroll = True Then
strJ &= "yes"
Else
strJ &= "no"
End If
strJ &= "')"
Me.ClientScript.RegisterStartupScript(Me.GetType(), "xOpen", strJ, True)
End Sub

Note that I just remove the javascript tag, and it works very well.

jb.alessandro:

Hi Benton,

I'd the same problem, but I solve it, use've just to remove the tag scrip from your code (belive, it works!!!)


Note that I just remove the javascript tag, and it works very well.

Hi JB,

I am having the same problem. I hope there is a way to fix it with my case. Below is my script. Thanks

Response.Write(

"<script>window.open('../MailCenter/mailMain.aspx?tomemid=" +Convert.ToInt32(ViewState["MemID"]) +"','_blank');</script>");

How is it possible to remove the tags in this case? I tried but it didn't work.

blumonde

UpdatePanel & GridView Event

Hi,

I have a GridView inside an UpdatePanel. How can I update that panel after (at the end) the RowUpdating event of the GridView?

I've tried many things, but none solved my problem yet.

What do you mean Update the panel? If the gridview is inside the update panel, then anything that is inside on the update panel that is modified durring the events will be changed after the partail postback. Now the RowUpdating event is fired before the datasource is updated, so technically there is no change to the gridview after this event is fired. Now the RowUpdated event, this is fired AFTER the datasource has been updated (or to be correct, after the datasource has attempted to change). You can put a GridView1.DataBind() at the end of this event to force a gridview update its rows.

-Alan


On the properties tab for the update panel click on Triggers. A box will pop-up click the add button. There will be a dropdownlist for the ControlID, select the GridView that you want to trigger the update. There will be a dropdownlist for the EventName, select RowUpdating. Click OK and it should work.


You could use the .Update() method of the UpdatePanel you want to refresh.


You have to use UpdatePanel.Update() method to update the contents inside UpdatePanel


I've tried before the Update() method and the triggers, but they don't work.

I'm using this GridView:

http://www.aspdotnetcodes.com/Simple_Insert_Update_Delete_GridView_Sample.aspx

So, what I want is to update the UpdatePanel after a row edit, wich hapens on the RowUpdating Event. I want to update it because I have a label outside the GridView with the sum of one of the columns of the GridView, and without the update it only changes the value when I hit refresh on the browser or when I move to another page and then return.


Is the label inside the ContentTemplate of the updatepanel?


bolinc:

Is the label inside the ContentTemplate of the updatepanel?

NoEmbarrassed

I forgot to put the label inside the ContentTemplate tags of the UpdatePanel.

It's always something so stupid...

Thanks bolinc Yes


I think this might solve your problem.

The gridview has to call the onRowUpdated method. Don't forget that the data source also has to be within the update panel (i left mine out b/c it took up too much space). the method it calls is simple. Don't forget to set the dataKeyNames on the gridview. I forget that all the time. and i just put those extra two labels in to test that the update was only occurring in the panel b/c i didn't have anything else on the page.

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"AutoGenerateEditButton="True"

DataKeyNames="SPDdifference,biMonthlySalary"DataSourceID="SqlDataSource1"OnRowUpdated="Display_Message">

<Columns>

<asp:BoundFieldDataField="ID"HeaderText="ID"InsertVisible="False"ReadOnly="True"

SortExpression="ID"/>

<asp:BoundFieldDataField="ssan"HeaderText="ssan"SortExpression="ssan"/>

<asp:BoundFieldDataField="fName"HeaderText="fName"SortExpression="fName"/>

<asp:BoundFieldDataField="lName"HeaderText="lName"SortExpression="lName"/>

<asp:BoundFieldDataField="SPDdifference"HeaderText="SPDdifference"SortExpression="SPDdifference"/>

<asp:BoundFieldDataField="biMonthlySalary"HeaderText="biMonthlySalary"SortExpression="biMonthlySalary"/>

</Columns>

</asp:GridView>

<br/>

<asp:LabelID="Label1"runat="server"Width="536px"></asp:Label><br/>

<asp:LabelID="Label3"runat="server"Text="Label"Width="528px"></asp:Label>

</ContentTemplate>

</asp:UpdatePanel>

==========================================================================================

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load

Label2.Text =Date.Now

Label3.Text =Date.Now

EndSub

Sub Display_Message(ByVal SrcAsObject,ByVal ArgsAs GridViewUpdatedEventArgs)

Dim spAsDecimal = Args.Keys("SPDdifference")

Dim biAsDecimal = Args.Keys("biMonthlySalary")

Dim totalAsDecimal = bi - sp

Label1.Text ="here's spd " & total

EndSub


sorry to have given such a detailed answer to such a simple question. Zip it!

i have been bored this morning!

UpdatePanel (and other Ajax) not working inside of a frame

Hi,

I'm working on a project that uses a frame for the navigation and then a larger window for the actual content. Most of the site is built with classic ASP - which I know very little of - and we're working towards converting it piece by piece to .NET. I built up a page with several UpdatePanels and at least one UpdateProgress controls on it. Everything works absolutely perfectly until I try to bring it into the frameset used by this site. I thought maybe it was just being inside a frame that it didn't like so I made a simple prototype inside a frame from scratch and ran it outside of our site frame (the top navigation frame was just pointed to google.com and the content frame was what I was testing) and that worked just fine.

I guess the end result of all that is that there's something somewhere in the old ASP section of the site preventing me from using any Ajax on the site. Being so unfamiliar with ASP, I'm not even really sure where to begin troubleshooting something like that.

Any ideas or suggestions would be greatly appreciated. Thanks!

one thing to note is that using frames is becoming an old obsolete practise and if you are moving to .net I would recomend switching to masterpages to handle navigation and such


I believe that's in the plans at some point. I inherited this site and the frames with it so for the moment, there's nothing I can do about it, unfortunately. I definitely would prefer to go the master page route.

UpdatePanel (Ajax) with DetailView

Hi All:

I have an UpdatePanel(Ajax) and inside one DetailView. When I try to insert a new record in the DetailView the new values are "" (null) . I don't know what I am doing wrong. He re is part of my code for get the values from the DetailView

protected

void DetailsView1_ItemInserting(object sender,DetailsViewInsertEventArgs e)

{

TextBox txtRow_MasterCustId = ((TextBox)DetailsCustomerMaster2.FindControl("TextBox0")); // The values are ""TextBox txtMaster_CustomerId = ((TextBox)DetailsCustomerMaster2.FindControl("TextBox1")); // The values are ""

ObjectDatacustomerMasterDetails.InsertParameters[1].DefaultValue = txtMaster_CustomerId.Text;

ObjectDatacustomerMasterDetails.InsertParameters[2].DefaultValue = txtCustomer_Name.Text;

}

I appreciate any help

thanks

Can you please elaborate on the problem. What I understand is briefly as

Problem Identified As: That when you insert a null value, it does not get inserted into the database.

Solution: Check your database fields first. If nulls are not accepted, then this problem could possibly arise.

Problem Identified As: Even if you insert data, only nulls are inserted.

Solution: This could be possibly because of the queries that are associated with the detailsview. Happens when you've not specified the fields properly in the queries.

Please reply if what I've understood was right and if they solved your problem. Else elaborate more on the problem to clarify what the problem actually is. It is not clear with your message.

Enzoi!!!


The problem is that when I click the Insert button in the DetailView ( the DetailView is in Insert Mode), the values that holds the textboxes are empty. The user typed some values to each textbox in the Detailview for Insert a new record. I try to get the new values inserted by the user before the inserting but there are not values.

protected

void DetailsView1_ItemInserting(object sender,DetailsViewInsertEventArgs e)

{

TextBox txtRow_MasterCustId = ((TextBox)DetailsCustomerMaster2.FindControl("TextBox0")); //The textbox is empty but the user inserted some textTextBox txtMaster_CustomerId = ((TextBox)DetailsCustomerMaster2.FindControl("TextBox1"));TextBox txtCustomer_Name = ((TextBox)DetailsCustomerMaster2.FindControl("TextBox2"));

ObjectDatacustomerMasterDetails.InsertParameters[1].DefaultValue = txtMaster_CustomerId.Text; //The textbox is empty but the user inserted some text so the parameter are empty

ObjectDatacustomerMasterDetails.InsertParameters[2].DefaultValue = txtCustomer_Name.Text;

ObjectDatacustomerMasterDetails.InsertParameters[3].DefaultValue = txtAddress.Text;

}

If I put the DetailView outside of the update panel , it works. I can get the new values and the parameters are fine in the InsertParameter

but if it is inside of the update panel is not working. I can't get the new values and the parameters are empty. Why the differences ?

Thank you for any help.


Have you found any solution?

I'm having the same problem except from the fact that I'm not using any Ajax. My program was working fine, but after integrating with some design (pics and CSS, ...etc) the TextBoxes are always empty when submitting a page, even if the user writes things in there. The textboxes are found in the code-behind page (not null, but do exist) However their .Text value is always an empty string no matter what the user writes in them.


No I don't have a solution ?

I am waiting that somebody can help me.

UpdatePanel -> window.close

Good morning @dotnet.itags.org. all

I am working on a ModalDialog window, there i have UpdatePanel over the whole modalDialog, Inside of it several atlas/ajax components.
Inside on top i have a Button to save the Datasheet/ Data fields. On other modals before i did it like so:

btnSave_Onlick -> save data to SQL and after it (last command) Response.Write ....window.close / PageStartupScript...window.close...
It worked fine in the past, but now the button is inside of the updatepanel and it throws out a Error with the response.write method,
and if i use StartupScript it just dont close the window. Is there any method to do this events inside of an updatePanel event?

Thanks for reponses
Marc

Specifially - Response.Write commands kill the whole microsoft.ajax enviroment - specifically with the new BETA. (I learned the hard way unknowningly)...

The alterantive is to just use a label or textarea (html) and assign values to after doing whatever you need to display after whatever processing. Little confused though are you talking window close as in IFRAME or modalpopup.show() hide()? Your post seems to indicate you are using an iframe and not a modal...

None the less if modal - then wrap the form or whatever you present in the modal in a panel and on successful submit make it not visible and assign a lable or generichtmlcontrol and display whatever message you want in it with a close button ...


hello.

if you're trying to insert javascript statements from a partial postback then use the new registerXXX static methods of the scriptmanager class.


Ok Thanks Luis i will remind it for further things :D
After all, for this i just brought my button outside of the panel...wasnt that big problem.

UpdatePanel & Wizard together ERROR

I have a Wizard control inside of the UpdatePanel control. In the Wizard control, I have a FileUpload control. WHen I set the ScriptManager to enable Partial Rending, I get this error message when I tried to upload the file:

"Object reference not set to an instance of an object"

This is the culprit:

int imageSize = fileuploader.PostedFile.ContentLength;

Because fileuploader is NULL.

Why does this happen? Does the page not instantiate a fileupload object when the whole page is not rendered?

thanks!

Lots of threads on this issue ... Unfortunately you can't use a FileUpload control inside of an update panel. FileUploading, in general, has always been a thorny issue. The form has has to do an HTTP post to include the bytes of the file selected by the user. No indication that this can (or should) be fixed.

With a normal "full" form postback, the browser (running natively on the operating system of the host system) is able to obtain the binary of the file selected by the user and push those bytes to the server in an HTTP POST.

Allowing arbitrary JavaScript to perform the same operation -- whether it's Atlas or any other Ajax framework -- would violoate the security lockdowns that most modern browsers *must* enforce. If JavaScript was able to programmatically probe the local file system of the user and upload binary data to a server, an entirely new/old form of exploits would be enabled.

It's for the similar reasons that you can't programmatically set the default file that you'd like to upload in the web page. Use of FileUpload and the underlying HTML tags requires an "act of comission" on the part of the user. If this was not enforced by the browser, a malicious web page could data-mine arbitrary local storage w/out any knowledge/awareness of the user.

What should work would be to render in a asp:Literal control the raw HTML <input type="file" .../> tag. Going down this path would require that you manually implement an ASPX file that can accept the resulting HTTP post and process the response -- exactly what the FileUpload control is actually doing under the covers.
After many hours of trying to get a fileUpload control to work from inside an update panel i discovered that it isn't possible.

However, from all that I can gather, it should work from outside anupdate panel, even if there is a different update panel on the page?

Can someone confirm for me that this is the case?

Many Thanks,
Dave

hello.

yes, this is the case. the upload control should work when pleced outside the updatepanel.


what if the FileUpload component is inside an iframe inside an update panel?would it help to trigger an full page postback?

As I know that the popup control is using an iframe, please try if u guys still want to...


I think you should take a look by overwritting the methods loadControlState and savecontrolstate, to maintain the fileupload's state. I am a newbie, but maybe it could work.

UpdatePanel + FileUpload + PostBackTrigger doesnt seem to work

As the title of the thread states, I have a file upload control inside an update panel and added a postbacktrigger to activate a full post back when the submit button is pressed but everytime I try and upload a file the HasFile property never equals true even though I know I chose a file with the file upload control. Am I missing something essential? Here is a snippet of the code..

1<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true">2 <ContentTemplate>34 ...5 ...6 ...78 </ContentTemplate>910 <Triggers>11 <asp:PostBackTrigger ControlID="PropertyValueSubmitButton" />12 </Triggers>1314</asp:UpdatePanel>

Hi There,

As what i can see, your code seem to be alright.

I even run a test base on your scenaria.

<asp:UpdatePanelID="UpdatePanel1"runat="server"ChildrenAsTriggers="true">

<ContentTemplate>

<asp:FileUploadID="FileUpload1"runat="server"/>

<asp:ButtonID="btnPostBack"runat="server"Text="My PostBack Button"OnClick="btnPostBack_Click"/>

</ContentTemplate>

<Triggers>

<asp:PostBackTriggerControlID="btnPostBack"/>

</Triggers>

</asp:UpdatePanel>

In code behind, i set a break point and test the value is true when i select a file and post it by click on the button

protectedvoid btnPostBack_Click(object sender,EventArgs e)

{

Boolean b = FileUpload1.HasFile;

}


Hi kbeeveer46,

Has your problem been resolved yet? If yes , sharing your work will be greatly appreciated!


Hi did you find a solution to your problem. I experience the same problem.

/Frederik


Hi,

I trying the exakt same thing with an AsynPostBackTrigger and then the FileUpload1.HasFile returns false. Do you know why this is so. What am I doing wrong.


I ran into almost exactly the same problem, although mine was a little more difficult because my File Upload control was in a dynamically loaded User Control and couldn't be moved outside of the Update Panel. I set the PostBackTrigger so that everything inside the userconrol would post back. I ran into the same problem that the .HasFile value was always false/null on the first page load. If I posted the page back with any button, then the upload control would work.

I had another AJAX application that was set up almost identical and it was working fine after setting the postbacktrigger. I started looking for differences, and in my default.aspx in the working app I found the following directive on the Form statement:

enctype="multipart/form-data"

Looks like this:

<formid="Form1"method="post"enctype="multipart/form-data"runat="server">

I'm not sure why I ever put it there, and I read on another post where this shouldn't matter, but guess what... I put that in my default.aspx and tried the non-working app again, and viola. Working like a charm.


I never did find a solution but I will definitely try out what hartmacw has said.

EDIT: hartmacw's solution worked perfectly. Thanks.

UpdatePanel + Dynamically UserControl

Hi everybody.

I have next problem, I have a menu with a couple of options, when youclick over any option the web load a usercontrol inside of aupdatepanel (i save the virtualpath of the control in a viewstate), oneof these controls has a uptatepanel with a gridview.

The option which load the usercontrol is Customers, when I click thefirst time over Customers, the usercontrol and the gridview work fine,but if i click one more time over this option the gridview doesn'twork, I press to sort one column, but the gridview isn't updated, it islike it was frozen.

Thanks, Pedro.

I have exactly the same problem.

I'm not sure, but I think that this issue is related to the fact that the second updatepanel it's n loot loaded at page init, so it's not going to work properly.

If anybody has found a solution to get updatepanels to work after loaded dynamically, please HEELP!!

UpdatePanel + DataList (not updating)

I have a DataList inside of an UpdatePanel, with an update trigger from a drop down list. The DataList is data bound to a IDataReader upon postback. I'm not getting an update. When I remove the UpdatePanel, things work as expected. Here's the code:

<asp:Panel ID="pnlFilters" runat="server" style='margin: 0px auto 0px auto;text-align: center;'>
<asp:Label ID="lblProducts" runat="server" Text="Rovion Products:" />
<asp:DropDownList ID="ddlProducts" runat="server" style='margin-right: 50px;' OnSelectedIndexChanged='ddl_SelectedIndexChanged' AutoPostBack='true' />
<asp:Label ID="lblCategories" runat="server" Text="Vertical Categories:" />
<asp:DropDownList ID="ddlCategories" runat="server" OnSelectedIndexChanged="ddl_SelectedIndexChanged" AutoPostBack="true" />
</asp:Panel>
<br />
<br />
<atlas:UpdatePanel ID="upDemos" runat="server">
<ContentTemplate>
<atlas:UpdateProgress ID="uppDemos" runat="server">
<ProgressTemplate>
<asp:Panel id="pnlLoader" runat="server" style='margin: 0px auto 0px auto;text-align: center;'>
<asp:Image ID="imgLoader" runat="server" ImageUrl="~/Images/ajax-loader.gif" />
</asp:Panel>
<br />
</ProgressTemplate>
</atlas:UpdateProgress>
<asp:DataList ID="dlDemos" runat="server" CellPadding="10" GridLines="None" RepeatColumns="3" ShowFooter="False" ShowHeader="False" BorderColor="#89a3b2" BorderWidth="2px" style='margin: 0px auto 0px auto;text-align: center;'>
<ItemTemplate>
<asp:HyperLink ID="hlThumbnail" runat="server" ImageUrl='<%# Eval("ThumbnailURL") %>' NavigateUrl='<%# GetNavigateUrl() %>' Target="_new" />
<br />
<br />
<b>Title:</b> <%# Eval("Title") %>
<br />
<b>Product:</b> <%# Eval("ProductName") %>
<br />
<b>Vertical:</b> <%# Eval("CategoryName") %>
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
<Triggers>
<atlas:ControlValueTrigger ControlID="ddlCategories" PropertyName="SelectedValue" />
<atlas:ControlValueTrigger ControlID="ddlProducts" PropertyName="SelectedValue" />
</Triggers>
</atlas:UpdatePanel>

Any suggestions? Thanks! :-)

I really need some advice on this problem. I have a ScriptManager w/ partial rendering enabled. What happens is the UpdateProgress graphic will show up when I change the selection of the drop down list (like it's posting back), but 1) the UpdateProgress never goes away, and 2) the DataList is never updated...so everything in the UpdatePanel is not being updated, and I don't know why :-(

Does anyone have a clue why this would be occurring? Thanks for your time!


Hi~This might be the explanation of your problem. You may try event trigger other than value trigger, e.g

<atlas:ControlEventTriggerControlID="ddlCategories"EventName="SelectedIndexChanged"/>

Saturday, March 24, 2012

UpdatePanel + MultiView + TreeView do not work

HI

I have simple master page having the ContentPlaceHolder inside an UpdatePanel.

<%@dotnet.itags.org. Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </ContentTemplate> </asp:UpdatePanel> </div> </form></body></html>

My content page has a MultiView and Two View controls. Each View control has a TreeView inside. My problem is the TreeView in the first View can expand/collpase but the one in the second view has no response when clicking on it. What is going on?
<%@dotnet.itags.org. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="TemplatedPage.aspx.cs" Inherits="TemplatedPage" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <asp:Button ID="Button1" runat="server" Text="Switch pane" OnClick="Button1_Click" /> <asp:MultiView ID="mv1" runat="server" ActiveViewIndex="0"> <asp:View ID="view1" runat="server"> <asp:TreeView ID="TreeView1" runat="server"> <Nodes> <asp:TreeNode Text="Tree 1" Value="Tree 1"> <asp:TreeNode Text="New Node" Value="New Node"></asp:TreeNode> </asp:TreeNode> </Nodes> </asp:TreeView> </asp:View> <asp:View ID="view2" runat="server"> <asp:TreeView ID="TreeView2" runat="server"> <Nodes> <asp:TreeNode Text="Tree2" Value="Tree2"> <asp:TreeNode Text="New Node" Value="New Node"></asp:TreeNode> </asp:TreeNode> </Nodes> </asp:TreeView> </asp:View> </asp:MultiView></asp:Content>

Code behind:

public partialclass TemplatedPage : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) { }protected void Button1_Click(object sender, EventArgs e) {if (mv1.ActiveViewIndex == 0) mv1.ActiveViewIndex = 1;else mv1.ActiveViewIndex = 0; }}

From my limited knowledge treevie and menu controls are not currently supported in the ajax enviroment.. thus you will need to resort to a iframes approach or simply not place menu or treeview controls into a update panel. It is the Goal however of the Asp.Net to make all current .Net controls usable with the update panel but it won't most likely happend until the release of Orcas..

It is probably related to my problem with the Multiview control:

http://forums.asp.net/thread/1412888.aspx

UpdatePanel and "foreign" characters

Hi!

I'm using an UpdatePanel with a DataList inside and a Trigger that updates the panel.

In Explorer no updates are shown if the datalist contains swedish characters ( ?, ? or ?), the trigger works but the "old" content is still shown. This works perfectly fine in FireFox.

Any suggestions?

/Jovan

I tried to simulate this and it appears to be working okay. What I did was have both FormView and DataList for a table within the same UpdatePanel. I've also handled the ItemUpdated event for the FormView and invoked DataList.DataBind() method to refresh the DataList content. Using your swedish characters for one of the FormView updates, it gets reflected to the DataList. I'm using IE version 6.0.

UpdatePanel and ASP.NET validation controls

Ok, here's the setup:

-- July version of ATLAS

-- Inside an update panel, we have an asp textbox and a required field validator.

-- Outside the update panel we have an image button.

If you click the image button without entering anything in the text box, you get the client-side validation (which is correct). Then, enter valid data and click on the image button with the mouse (don't tab off the text box first). The validator message is cleared, but the the button's click event is never fired. We always have to click it a second time.

We only have this problem in an update panel. Our workaround is to put client-script on the OnMouseDown event of the button to fire the click event. Does anyone know what may be causing this?

Thanks, --David

Turns out it's not an ATLAS problem at all. The validation controls are set to display="dynamic" and they were pushing the image button down (and pulling it back up) and the onmouseup event wasn't completing on the button. Who knew.

UpdatePanel and AutoPostback

I have a textbox with AutoPostback set to true to fire an OnTextChanged event. This worked until I put the textbox inside an UpdatePanel and now it doesn't fire the event. Why is that?

Thanks

Sounds odd, I have a repeater where I have a TextBox and the TextChanged event fires to potentially show more controls based on the record being changed. I have it wrapped in an update panel and it works fine.

<asp:ScriptManagerProxyID="ScriptManagerProxy1"runat="server">

</asp:ScriptManagerProxy>

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<asp:UpdateProgressID="UpdateProgress1"runat="server">

<ProgressTemplate>

Updating...</ProgressTemplate>

</asp:UpdateProgress>

'''''Stuff goes here, like tables and my repeater, etc.

<asp:TextBoxID="txtQty"runat="server"Width="35"AutoPostBack="true"OnTextChanged="txtQty_TextChanged"></asp:TextBox>

'''''Stuff goes here, like tables and my repeater, etc.

</ContentTemplate>

</asp:UpdatePanel>

ProtectedSub txtQty_TextChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)

'Event Handler Guts go here

Me.SetFocus(txtQty.UniqueID)

Next

EndSub


Are you sure the event isn't firing (did you check in the debugger)? If the actions of your OnTextChanged event handler don't act on an UpdatePanel that's updating in the resulting partial postback, you aren't going to see anything happen. So, if you just wrapped that TextBox in an UpdatePanel and nothing else, it would appear that it stopped working.

UpdatePanel and Default Button

There is nothing special about my ASP.NET code below. I have a label inside the update panel, and Button1, when pressed, sets the current time to the Label.

The only thing is, Button1 is the form's default button.

It works flawlessly in the development environment. I can press ENTER endlessly and it will work without postbacks. However, in the target environment, I observe very strange behaviors.

* Pleasecheck out the pageI have on my test server. Place your cursor inside one of the text boxes and press ENTER. It works. Now press ENTER again, Then it posts back. Every other time, it posts back.

* In my actual application, again it works in the development environment. But when ENTER is pressed the second time, I get a popup box that says,

Sys.WebForms.PageRequestManagerParserException:the message received from the server could not be parsed. Commoncauses for this error are when the response is modified by calls toResponse.Write(), response filters, HttpModules, or server traceenabled.Details: Error parsing near

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server" defaultbutton="Button1">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
<br />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>

<asp:Button ID="Button2" runat="server" Text="Not Default" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="Default" />
</div>
</form>
</body>
</html>

Can you give your server side code.So i can find out your problem's solution.


There is very little to the server side code. Here
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partialclass _Default : System.Web.UI.Page
{

protected void Button1_Click1(object sender, EventArgs e)
{
Label3.Text ="Default button pressed. Time is " + DateTime.Now.ToString();
}
}


I think when hitting enter you are going of Focus on your app. Perhaps at the end of your method you can get focus back on your textbox through javascript or your method.

function focuxtextbox () {

document.getElementById('textbox').focus();

}


vicpal25:

I think when hitting enter you are going of Focus on your app. Perhaps at the end of your method you can get focus back on your textbox through javascript or your method.

Well, losing the focus is not the issue. It posts back every other time when I press ENTER. That it redraws the whole page every other time is a problem. When you just press the button, it works, but not when you press ENTER.


Hum, yeah I was checking out your sample app. Interesting behavior. Have you tried passing the:

UpdateMode="Conditional"

to the udpate panel?


vicpal25:

Hum, yeah I was checking out your sample app. Interesting behavior. Have you tried passing the:

UpdateMode="Conditional"

to the udpate panel?

Yes I did. Same behavior.


hello.

well, the problem is that you're partial postback isn't re-registering the button as the default button. you can see this by using fiddler. i've tried hosting the app on my machine, but iis is working correctly here. can you debug the app on the server and see the value of the _requireFocusScript field during the pre-render event of the page?


Luis Abreu:

can you debug the app on the server and see the value of the _requireFocusScript field during the pre-render event of the page?

I've noted this behavior only on the target machine, not on my development machine. So how would I go about debugging the value of the _requireFocusScript?


hello again.

yes, here on my machine i'm not seeing that behavior too. i only see it when i try to load the page from the server where you've deployed the app

well, you'll have to add a method that handlers the prereder event and then you'll have touse the watch window since you'll have to go through several non public fields:

manager._pageRequestManager._requireFocusScript


Problem resolved. Well, kinda.

A windows update for .NET fromwork 2.0 fixed it. However, it now only works for IE, but not for Firefox. I suspect that is a different issue all together.

updatepanel and default button

hello

is there a way to set a default button inside update panel ?

thank u,

Hi,

UpdatePanel doesn't support this behavior directly, you can achieve this by adding a panel inside the UpdatePanel.

Then place all controls inside the UpdatePanel into the Panel. And set defaultButton on the panel.

For instance:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Button1_Click(object sender, EventArgs e) { TextBox1.Text = DateTime.Now.ToString(); } protected void Button2_Click(object sender, EventArgs e) { TextBox2.Text = DateTime.Now.ToString(); }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate>  <asp:panel ID="Panel1" runat="server" height="50px" width="125px" DefaultButton="Button1"> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </asp:panel> </ContentTemplate> </asp:UpdatePanel>  <asp:panel runat="server" ID="Panel2" height="50px" width="125px" DefaultButton="Button2"> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" /> </asp:panel> </form></body></html>

UpdatePanel and Dynamic populated table

My control builds a table dynamically [some subscription rows]

The table is placed inside and update panel:

<atlas:UpdatePanel ID="upBrowse" runat="server" Mode="Conditional" RenderMode="Inline"> <Triggers> <atlas:ControlEventTrigger ControlID="btnDelete" EventName="Click" /> <atlas:ControlEventTrigger ControlID="btnOK" EventName="Click" /> </Triggers> <ContentTemplate> <asp:Table ID="tblSubscriptions" runat="server" CellPadding="1" CellSpacing="1" Style="position: relative" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" EnableViewState="true"> </asp:Table> <br /> <asp:Button ID="btnAdd" Text="Add" runat="server" OnClick="btnAdd_Click" /> <asp:Button ID="btnDelete" Text="Delete" runat="server" OnClick="btnDelete_Click" /> </ContentTemplate> </atlas:UpdatePanel>

When the table gets populated, there is a checkbox for each row to select the subscriptions to be deleted.

There is a Delete Button and the task is to select all the checked rows and delete them.

My problem is that on the trip back, handling the delete button 'btnDelete_Click' I cannot iterate the table programmatically because there are no rows:

foreach (TableRow rowin tblSubscriptions.Rows) --> no rows

What is wrong?

Thx,

Uri

Can you show a some code how you add dynamic rows? Just as an idea - maybe HtmlTableRow instead TableRow? You can use Repeater with checkboxes instead your table, and you will receive selected values in the Form collection...
foreach (Subscription oSubin oSubscriptions) { count++;if ((int)oSub.GetFieldValue("SystemID") == _systemId) { TableRow row =new TableRow();if (bInStyleAlt) { row.ApplyStyle(styleAlt); bInStyleAlt =false; }else { row.ApplyStyle(styleNormal); bInStyleAlt =true; } CheckBox box =new CheckBox(); box.ID ="chkSub_" + oSub.SubscriptionId; box.Checked =false; TableCell cellChk =new TableCell(); cellChk.Controls.Add(box); row.Cells.Add(cellChk);

Interesting points:

I am able to manipulate other elements inside the update panel (like textboxes) if these are not inserted dynamically.

Let me try HtmlTableRow or the repeater