Saturday, March 24, 2012

Triggers for update panel

I have a web page (aspx) that has on it 2 controls (ascx) - one of the controls has an update panel with functionality for it etc. - I want to trigger the update function from the second control that has a linkbutton on it.

Is this possible?

TIA

Yes. Update panel has Triggers element which can be used as follows
 <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="lnkButton" EventName="Click"/> </Triggers> </asp:UpdatePanel>

It would seem so - but if the trigger and the update panel are in different ascx files they can not see each other - even if those ascx files exist as controls on the same aspx page

You can explicitly call Update method of another UpdatePanel like this:

UpdatePanel1.Update() ;

Assumption: LinkButton is in UpdatePanel2 and the above code is written in event handler for LinkButton click event.

Generally, you have this kind of scenario in Master-Detail relationship. There is tutorial onhttp://ajax.asp.net site about this.


Okay I dont think you are looking at what the question says - because this doesnt work - unless you can point me to the specific tutorial I cant find the one you are talking about

here is a simple picture that diagrams what I am trying to do

Page1.aspx has two controls on it - both controls are ascx files (Control1.ascx and Control2.ascx)

Control1.ascx has an image button that when clicked is to trigger the UpdatePanel on Control2.ascx

Example

No comments:

Post a Comment