Hi all,
I have a MasterPage with Calendar Control, and a content page with ListBox control.
My plan is to have a post back on the ListBox, when the Calendar control "SelectionChanged" event fires.
Both the Calendar control and the ListBox control are child elements of separate UpdatePanel controls.
I have this code fragment in the content page "Load" event handler.
if (!IsPostBack)
{
Microsoft.Web.UI.AsyncPostBackTrigger trigger = new
Microsoft.Web.UI.AsyncPostBackTrigger();
trigger.ControlID = master.CalendarStartDate.ClientID.ToString();
trigger.EventName = "SelectionChanged";
UpdatePanelItemMovers.Triggers.Add(trigger);
}
But when the page loads, I get this error:
A control with ID 'ctl00_ctl00_RightSidePlaceHolder_calendarStartDate' could not be found for the trigger in UpdatePanel 'UpdatePanelItemMovers'
Can someone tell me why?
Any luck on this. I'm having the exact same problem.|||I get the same problem using markup. This is the complete page, which uses a very simple master page that has just 2 content areas.<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ScriptManager id="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Button ID="Button1" runat="server" Text="Click" /><br />
Time: <%= DateTime.Now.ToLongTimeString() %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<asp:UpdatePanel id="UpdatePanel1" runat="server">
<contenttemplate>
Time: <%= DateTime.Now.ToLongTimeString() %>
</contenttemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
If I move the button into the Content2 placeholder, it works fine.|||One answer is to add the trigger using code:
protected void Page_Init()
{
Microsoft.Web.UI.AsyncPostBackTrigger trigger = new Microsoft.Web.UI.AsyncPostBackTrigger();
trigger.EventName = "Click";
trigger.ControlID = Button1.UniqueID.ToString();
UpdatePanel1.Triggers.Add(trigger);
}
see:
http://forums.asp.net/thread/1456042.aspx|||
I don't use Triggers any more, I just manually call UpdatePanel.Update() whenever I need to update a section of the page, and the result is exactly the same as using triggers. I believe the error can be traced to the MasterPage/Content relationship, where controls are assigned some strange-looking ID's.
|||Use the ChildrenAsTriggers="false" attribute in UpdatePanel for using AsyncPostBackTrigger.Code Snippet
<asp:UpdatePanel ID="general" runat="server" UpdateMode="conditional" ChildrenAsTriggers="false"> <Triggers>
<asp:AsyncPostBackTrigger ControlID="bt_envia" EventName="Click" />
</Triggers>
No comments:
Post a Comment