Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating a modal dialog via button click
    primarykey
    data
    text
    <p>I am trying to have a button inside an update panel create a modal dialog in javascript and have it pop up the code below is what I am using. I have tried several different ways of going about this and I am just completely stuck. </p> <pre><code>protected void btnRequestPrint_Command(object sender, CommandEventArgs e) { var button = sender as Button; var parent = button.Parent; var row = parent.DataItemContainer; var printLabel = row.FindControl("lblPrints") as Label; var literal = parent.FindControl("lJavascriptPrint") as Literal; var label = parent.FindControl("lblMessage") as Label; switch (e.CommandName) { case "RequestPrint": var productId = Convert.ToInt32(e.CommandArgument); currentProduct = productId; var customerId = NopContext.Current.User.CustomerId; var ei = this.EncryptionService.GetEncryptionInfo(customerId, productId); if (ei != null &amp;&amp; ei.Prints &gt; 0) { literal.Text = @" &lt;div id=""removeME""&gt; &lt;!-- yes/no dialog --&gt; &lt;div class=""modal"" id=""yesno""&gt; &lt;h2&gt; Did your music print correctly?&lt;/h2&gt; &lt;p&gt; &amp;lt;--Printing Instructions for your browser will go here--&amp;gt;&lt;/p&gt; &lt;!-- yes/no buttons --&gt; &lt;p&gt;" //&lt;asp:Button runat=""server"" ID=""btnPrintDialogYes"" CssClass=""close btn btn-primary"" // Text=""Yes"" OnClick=""btnPrintDialogYes_Click"" /&gt; //&lt;asp:Button runat=""server"" ID=""btnPrintDialogNo"" CssClass=""close btn btn-danger"" // Text=""No"" /&gt; + @" &lt;button onclick=""absorbPrint(" + currentProduct + @")"" class=""btn btn-primary close""&gt;Yes&lt;/button&gt; &lt;button class=""btn btn-danger close""&gt;No&lt;/button&gt; &lt;/div&gt; &lt;/div&gt;"; string UtilsScript = @" &lt;script type=""text/javascript""&gt; function absorbPrint(id) { $.ajax({ type: ""POST"", url: ""checkoutdownload.aspx/absorbPrint"", data: ""{}"", contentType: ""application/json; charset=utf-8"", dataType: ""json"", success: function(msg) { console.log(""success""); } }); } var yesnoDialog = $(""#yesno"").dialog({ modal: true }); $(""#yesno .close"").click(""function() { $(""#yesno"").dialog(""close""); }); &lt;/script&gt;"; var upanel = parent.Parent as UpdatePanel; ScriptManager.RegisterStartupScript(upanel, upanel.GetType(), "PrintSong", UtilsScript, false); } else { label.Visible = true; label.Text = "No prints available"; button.Visible = false; } break; } } </code></pre> <p>The markup (this is inside of a gridview):</p> <pre><code>&lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:Panel ID="pnlNonFolio" runat="server" Visible='&lt;%# ! IsProductFolio( (int)Eval("ProductId")) %&gt;'&gt; &lt;asp:UpdatePanel ID="upnlInstantPrint" runat="server"&gt; &lt;ContentTemplate&gt; &lt;asp:Button runat="server" ID="btnRequestPrint" CssClass="btn btn-primary modalInput" Text="Print" CommandName="RequestPrint" CommandArgument='&lt;%# Eval("ProductId") %&gt;' OnCommand="btnRequestPrint_Command" /&gt; &lt;asp:Literal ID="lJavascriptPrint" runat="server" /&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;asp:Label runat="server" ID="lblMessage" Visible="false" /&gt; &lt;/asp:Panel&gt; &lt;asp:Panel ID="pnlFolio" runat="server" Visible='&lt;%# IsProductFolio( (int)Eval("ProductId")) %&gt;'&gt; &lt;asp:Label runat="server" ID="lblIsFolio" Text="This Product Is A Folio" /&gt; &lt;/asp:Panel&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; </code></pre> <p>I can try to paste more code if necessary it's just private code so I can't paste some of it.</p> <p>So anyhow, currently when I am doing this I am getting the following error upon click the print button:</p> <pre><code>Uncaught SyntaxError: Unexpected token ILLEGAL Type.registerNamespace('Sys.WebForms');Sys.WebForms.Res={"PRM_UnknownToken":"Unknown token: \u0027{0}\u0027.","PRM_MissingPanel":"Could not find UpdatePanel with ID \u0027{0}\u0027. If it is being updated dynamically then it must be inside another UpdatePanel.","PRM_ServerError":"An unknown error occurred while processing the request on the server. The status code returned from the server was: {0}","PRM_ParserError":"The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.\r\nDetails: {0}","PRM_TimeoutError":"The server request timed out.","PRM_ParserErrorDetails":"Error parsing near \u0027{0}\u0027.","PRM_CannotRegisterTwice":"The PageRequestManager cannot be initialized more than once."}; </code></pre>
    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.
    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