Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdatePanel where Button Event does not fire
    primarykey
    data
    text
    <p>I have a UpdatePanel with a PlaceHold contained in it. I create some controls with Labels and Buttons, when Button is clicked it fires an Event that clears PlaceHolder and adds some Textboxes and a Button with an Event. Problem is when this Button is click it appears to do a PostBack and does not fire Event associated with Button. I thought that since these controls are all contained within the UpdatePanel the would be no PostBack, am I missing the flow.</p> <pre><code>&lt;asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"&gt; &lt;%--&lt;%@ Register assembly="System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.DynamicData" tagprefix="cc1" %&gt; --%&gt; &lt;div id="content" &gt; &lt;!--start content div--&gt; &lt;asp:Label ID="Label1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt; &lt;br /&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;br /&gt; &lt;asp:UpdatePanel ID="upBlog" runat="server" UpdateMode="Conditional"&gt; &lt;ContentTemplate &gt; &lt;asp:PlaceHolder ID="phBlog" runat="server"&gt;&lt;/asp:PlaceHolder&gt; &lt;/ContentTemplate&gt; &lt;Triggers &gt; &lt;%-- &lt;asp:AsyncPostBackTrigger EventName="Click" ControlID = "btnSave" /&gt;--%&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; &lt;br /&gt; &lt;/div&gt; &lt;!--ends content div--&gt; &lt;/asp:Content&gt; </code></pre> <p>//Code Behind</p> <pre><code>protected override void OnInit(EventArgs e) { base.OnInit(e); FirstView(); } protected void Page_Load(object sender, EventArgs e) { } private void FirstView() { FileStream fs = new FileStream(Server.MapPath(GlobalVar.compathver), FileMode.Open, FileAccess.Read, FileShare.ReadWrite); DataSet dset = new DataSet(); dset.ReadXml(fs); fs.Close(); //other controls Button btnComments = new Button(); btnComments.ID = "mybtnComments" + i.ToString(); btnComments.BorderWidth = 0; btnComments.Text = MyFunc.CountComments(row["ID"].ToString(), dset) + " Comments"; phBlog.Controls.Add(btnComments); btnComments.CommandArgument = row["ID"].ToString(); btnComments.BorderWidth = 0; btnComments.Command += new CommandEventHandler(Button1_Click) } private void CommentView(string ID) /// THIS DOES not FIRE { DataView myCommentView = GetCommentView(ID); Button btnCommentSave = new Button(); btnCommentSave.ID = "mySavebtnComments" + i.ToString(); btnCommentSave.Text = "Publish"; btnCommentSave.BackColor = Color.Aquamarine; phBlog.Controls.Add(btnCommentSave); btnCommentSave.CommandArgument = row["ID"].ToString(); btnCommentSave.Click += new EventHandler(btnSave_Click); } protected void Button1_Click(object sender, CommandEventArgs e) { CommentView(e.CommandArgument.ToString()); } protected void btnSave_Click(object sender, EventArgs e) //protected void btnSave_Click(object sender, CommandEventArgs e) { FileStream fsxml = new FileStream(Server.MapPath(GlobalVar.compathver), FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite); //other code // XML Document Saved xmldoc.Save(fsxml); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload