DDiVita
DDiVita

Reputation: 4265

UpdatePanel's PostbackTrigger that is inside a usercontrol inside a masterpage?

I have a masterpage and inside that masterage is a user control that has a toolbar with a save button. I then have an aspx page that inherits form t he master page. In that page I have and updatepanel. Is it possible to set the post back trigger to the Save button inside the usercontrol?

Upvotes: 2

Views: 6847

Answers (3)

DDiVita
DDiVita

Reputation: 4265

I went with a different approach of find my controls. I used this method. I have used this in the past and not sure why I didn't think about it earlier. In my user control I expose controls as properties. In my master page I created a property that allows me to get the user control instance. In my page I can call this: Master.UserControlName.PropertyInControl

So, if I expose a button or control in the user control, I should be able to add that to the trigger collection.

Upvotes: 0

Grant Thomas
Grant Thomas

Reputation: 45068

Check the fourth post down (marked as answer) here, it ought to help.

In short, create an PostBackTrigger instance, set fields appropriately and then add to the UpdatePanel's Triggers collection.

For example (from linked site):

//Creates a new async trigger
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();

//Sets the control that will trigger a post-back on the UpdatePanel
trigger.ControlID = "btnCommit";

//Sets the event name of the control
trigger.EventName = "Click";

//Adds the trigger to the UpdatePanels' triggers collection
pnlMain.Triggers.Add(trigger);

Upvotes: 0

Brad Christie
Brad Christie

Reputation: 101614

You should be able to use Master.FindControl("MySaveButton") from within the content page, and attach it to the scriptmanager's trigger list:

this.MyScriptManager.RegisterAsynchPostBackControl(Master.FindControl("MySaveButton"))

Unless I'm not understanding the question correctly.

Upvotes: 3

Related Questions