Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

__doPostBack reloading entire page instead of just the UpdatePanel

In my javascript, I have the following line:

__doPostBack('MyPanel', MyParam);

In my code behind, I use MyParam to query a database and bind the result to a gridview that's inside the MyPanel updatepanel. The updatemode of the updatepanel is set to conditional and in the postback part of the code I have MyPanel.Update();

The updatepanel works fine when I'm doing sorting and paging; only the panel is refreshed. However, when I trigger the updatepanel with my javascript, I see the traffic in firebug showing that the entire page is being refreshed.

What's the solution?

Thanks.

like image 912
frenchie Avatar asked Feb 10 '11 16:02

frenchie


1 Answers

My assuption: your update panel is located inside the naming container, so its id in the client side will be a little bit different from the server side ID. This means you pass the wrong __EVENTTARGET parameter to the client side __doPostBack function and your partial postback became full(meaning not async).

So changing your client code to:

__doPostBack('<%= MyPanel.ClientID %>', MyParam);

should solve the problem.

BTW, you could get the second(MyParam in your code) parameter from the server side:

var arg = Request.Params.Get("__EVENTARGUMENT");
like image 75
Oleks Avatar answered Nov 20 '22 21:11

Oleks