Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery effects on dynamically created controls inside ASP.NET AJAX update panel
    primarykey
    data
    text
    <p>Hello StakOverflowians! Wondering whether someone could help with this. </p> <p>I have a dynamically created tag inside an AJAX update panel. Upon clicking the tag, I am trying to (for the time being) display an alert using JQuery. The problem is that the alert doesn't get displayed when the tag is generated dynamically, however, if I declare the tag statically in .aspx, then it works. Here is the code: </p> <pre><code> protected void Button_Click(object sender, EventArgs e){ HtmlAnchor htmlA = new HtmlAnchor(); htmlA.ID = "hidden_link"; PlaceHolder1.Controls.Add(htmlA); string javaScriptFunction = "jQuery(document).ready(function() {" + "$(function () {" + "$(\"a[id$='hidden_link']\").click(function () {" + "alert('Alert: Hello from jQuery!');" + "});" + "});" + "}"; ScriptManager.RegisterStartupScript(this, this.GetType(), "myScript", javaScriptFunction, true); } </code></pre> <p>and on .aspx, I have:</p> <pre><code>&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt; &lt;ContentTemplate&gt; &lt;asp:PlaceHolder ID="PlaceHolder1" runat="server"&gt;&lt;/asp:PlaceHolder&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;script language="javascript" type="text/javascript"&gt; function pageLoad() { jQuery(document).ready(function() { $("a[id$='hidden_link']").click(function() { alert("Alert: Hello from jQuery!"); }); }); } &lt;/script&gt; </code></pre> <p>What should I do to get the alert working for dynamically created controls inside the PlaceHolder1? Any help will be most appreciated. </p> <p>Thanks, Ali</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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