开发者

ASP.Net multiple UpdatePanel refresh with JavaScript

I have a GridView and and some jQuery code that allows the user to expand individual rows. On row expansion I display a div which will contain more information relating to the row. Inside 开发者_如何学编程the div is an ASP.Net UpdatePanel. I make a call to the __doPostBack function passing the ID of the specific UpdatePanel I wish to refresh.

var updatePanel = $(expandContent).children("div[id$=UpdatePanel1]").attr("id");
__doPostBack(updatePanel, '');

However when debugging I notice that the *UpdatePanel_Load* method is getting called for each UpdatePanel on the page. As expanding the row will cause the system to go off and retrieve data I really only want to fetch this data for the specific row that has been expanded.

So my question is, does anyone know of a means to cause individual UpdatePanels to refresh using JavaScript.

Thanks Alan.


If I pass the ID of the UpdatePanel to the __doPostBack function like:

var updatePanel = $(expandContent).children("div[id$=UpdatePanel1]").attr("id");
__doPostBack(updatePanel, updatePanel);

In the code behind I can do a test like this to ensure the retrieval is only carried out for the specific UpdatePanel:

UpdatePanel panel = sender as UpdatePanel;

// the ClientId of the UpdatePanel being update is passed in
// __EVENTARGUMENT this can be checked against the sender to ensure
// data is retrieved only for the row being expanded. 
string panelID = Request.Params.Get("__EVENTARGUMENT");

if(panel.ClientID.Equals(panelID))
{
    // retrieve data
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜