using masterpage's UpdatePanel from contentpage
Can I update masterpage's updatepanel from content page.
suppose that i have an updatepanel in masterpage like as follows..
<asp:Upd开发者_StackOverflowatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
</ContentTemplate>
</asp:UpdatePanel>
Can i change that Literal1's text from contentpage ?
If so - how?
Any help appreciated!
Alternatively you can programatically add your sender as AsyncPostBackTrigger to your UpdatePanel.
UpdatePanel panel = (UpdatePanel)Master.FindControl("UpdatePanel1");
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
trigger.ControlID = ((Control)sender).ID;
panel.Triggers.Add(trigger);
panel.DataBind();
Literal literal = Master.FindControl("Literal1") as Literal;
literal.Text = "some text";
sure you can.
make sure you put both Literal
on Master page & Button
on content page inside UpdatePanel
. in the Button
's click handler, you can update the Literal
control on Master page
Literal literal1 = (Literal)Master.FindControl("Literal1");
You can find any control from the master page via code like this:
Literal literal = (Literal)Master.FindControl("Literal1");
Then you should be able to update the content of that literal.
Thank's to
Özgür Kaplan
, I've produced my own solution:
I had to produce a warning message with jQuery.dialog, I've placed an UpdatePanel with an empty asp:label (UpdateMode="Conditional").
In Master.cs I've placed this Public Funcion:
public void WarningUpdate(string childControlID, string eventName, string warningMessage)
{
lblWarningMessage.Text = warningMessage;
var trigger = new AsyncPostBackTrigger {ControlID = childControlID, EventName = eventName};
upWarningMessage.Triggers.Add(trigger);
upWarningMessage.DataBind();
upWarningMessage.Update();
}
In the Page, in some event (a Click one...) I've placed this code:
var master = (FM) Master;
if (master != null) master.WarningUpdate(((Control)sender).ID, "Click", "Devi prima selezionare una Provincia!");
And the result is:
精彩评论