Showing posts with label updatepanels. Show all posts
Showing posts with label updatepanels. Show all posts

Monday, March 26, 2012

Prevent child control inside the updatepanel to refresh the updatepanel

let say i have 2 UpdatePanels UP1 and UP2. Up1 contains a dropdownlist with 3000 items. When selectedindex of the dropdownlist is changed, it fires a partial postback to refresh the controls inside the UP2 which uses trigger. but at the same time it also refreshes the UP1which i want to avoid. and i also need this dropdown list to be inside the Updatepanel because the selected index is changing during partial postback.

Currently what i have done is i took this dropdownList out of updatepanel and the UP2 gets refreshed using trigger of that dropdownlist, and when it is required to update the the dropdown list i 'm injecting the javascript code in partial postback to do this.

any better work around to achieve this.

Thanks in Advance

RG

Pushed...

Preventing an UpdatePanel rendering after a Postback

Hi Everyone,

I have a page with three UpdatePanels, let's call them A, B and C and I have a control in B (a webgrid from ComponentArt) which issues a postback when one of it's rows is selected. What I would like to happen is for that event to be processed on the server, however I only want C to update its display (because in B, that row in the grid automatically changes it's appearance, so there is no need for the grid to be redrawn). Do you know if this is possible, ie to switch off the normally-useful behaviour of Atlas always refreshing the UpdatePanel containing the control that triggered the postback.

Thanks for any helpSmile [:)]

Rob.

Try insert Mode=Conditional in the Properties of UpdatePanel.

Bye.


Thanks for replying Paulo, however the mode is already set to "Conditional" for all of the UpdatePanels.


Sorry, but I don't think it's really possible.

You can cause 'C' to update by calling the Update method on that UpdatePanel in code behind, but if 'B' is causing the postback due to an event firing within it, 'B' is going to either force a full postback if its not in an UpdatePanel or a partial postback if its contained within an UpdatePanel.

The only idea I have is to change from the postback occurring on a row selected to a JavaScript command or something like tied to the onclick event to change the appearance of the row and then click a hidden button through JavaScript or something like that to cause 'C' to postback.

A partial postback is a lot like a regular postback and there's a difference in the parameter of the Render methods that determines what Html is sent back down to the browser.(Check out my blog posting on the subject.)

- Joel

I think this could be helpful (http://forums.asp.net/thread/1266249.aspx). I don't know if it's really what are you looking for but try it. I had a similar problem. I wanted to update panel B when I click on control in update panel A. The solution described in the thread works (and is very simple).

Pavel

Previous ViewState being used after UpdatePanel refresh

I am not sure its a problem with a viewstate--just a guess. The problem is this:

I have a page that uses a master page. It has two updatepanels in it. One updatepanel has a dropdownlist and one has a button and a label. When the button triggers a partial postback, I set the value of the label and can see it change on the page. When the dropdownlist triggers a partial postback the label switches back to its previous value right before the partial postback. When I inspect the value in the code behind for the dropdownlist the previous value is what is in the label.

What could be causing this? Has someone else had a similar problem? Where was the previous value even stored for it to be retrieved. Does each updatepanel have a viewstate?

Due to the complexity of my master page, I cannot put the dropdownlist, button and label in the same updatepanel. Is that the source of the problem?


There's one ViewState for the entire page, and it's updated during each async postback.

Could you boil this down to a small sample (e.g. a couple UpdatePanels, one with a DropDownList, one with a Label) and paste the code here?

Also, try removing the UpdatePanels (or setting EnablePartialRendering="false" on your ScriptManager) to see if this works with regular postbacks. That may help to figure out what's going wrong.


Also make sure each UpdatePanel's UpdateMode is set to conditional.

Saturday, March 24, 2012

Problem forcing an UpdatePanel to post from client-side code (javascript)...

Here's what I'm trying to achieve. I have a rather complex web page that allows data entry. The page utilizes Atlas UpdatePanels for partial reposts. When the user clicks on certain buttons, the data is validated (server-side), and then the user is given the option to save or abandon the changes. To do this, I use RegisterJavaScript to insert a client-side call to a javascript function which calls a vbscript function to display a msgbox (we're only using IE). The vbscript function returns the msgbox value back to the javascript function which then sets an ASP HiddenField. The next step is where I'm having problems. I need the javascript function to force a partial postback so that the server-side code can evaluate the msgbox results (in the hidden field), and respond accordingly. I don't want to repost the entire form because I loose data from other asynchronous client-side page modifications.

So the real question is; how can I force an UpdatePanel to post from client-side code? I've read a number of other threads on this subject and a suggested solution is to call the click event of a hidden LinkButton within the UpdatePanel. So I tried this and it worked! At least it worked for a while. This is the most frustrating part. At some point, and I have no idea what changed to cause this, the code stopped working. Now, when I call the click event, I get an undefined error in the doPostBack function and the form will no long post at all.

If anyone has any suggestions on what is causing this problem, or a better way to force an UpdatePanel to partial post, it would be greatly appreciated!

Here's some of my code;

<atlas:UpdatePanel ID="upConfirmActivitySave" runat="server" Mode="conditional"><ContentTemplate> <asp:HiddenField ID="hfConfirmActivitySave" runat="server" /> <asp:LinkButton ID="lnkDoPostBack" runat="server" style="display:none"></asp:LinkButton></ContentTemplate></atlas:UpdatePanel><script language="javascript" type="text/javascript"><!--function confirmActivitySave() { document.getElementById('hfConfirmActivitySave').value = ConfirmActivitySaveMsgbox(); document.getElementById('lnkDoPostBack').click();} // --></script><script language="vbscript" type="text/vbscript"><!--Function ConfirmActivitySaveMsgbox()'This only works for IEConfirmActivitySaveMsgbox = MsgBox("Do you wish to save?",35)End Function// --></script>

I decided to simplify things and created a new aspx page with a single UpdatePanel and two ASP ImageButtons, one inside the UpdatePanel and the other outside the UpdatePanel. The client-side code for the button outside the UP calls the click method for the button inside the UP. And sure enough, I get a partial post. So this tells me there's something wrong with my main project page. I wonder if I've hit some sort of atlas bug or limitation?


This just gets weirder and weirder. I restored my project to a prior version – one that the partial post code still worked. I compared the differences in the html between the working and non working versions and the only changes were some controls that were renamed (all within UpdatePanels) and a single control (an asp:HyperLink) that moved from outside to inside an UpdatePanel. So, from the working code, I moved the one control (using cut/past) and sure enough the page fails during the client-side partial post; "unknown runtime error". And get this; if I delete the control, the page still fails. By the way, all references to this control (client-side and server-side) have been removed. Essentially, the control is unused. But if I delete it, the page fails. What gives? I can remove other controls, or add and remove controls with no problem. It's almost like there's some reference that's not getting deleted correctly. Any ideas? Anyone?