So, I have to show jQuery UI Dialog from codebehind.
I tried everything: this , this , this , and also modified these answers to check if it works with me, but does not work.
I use the first solution because it is organized. It works if I use alert ('whatever') instead of jquery dialog code. therefore, I know his work, but nothing happens with the dialogue. I also tried it with colorbox and did not work.
Can someone give me a workaround? That would be appreciated. Thanks.
My aspx:
HEAD <script type="text/javascript"> function BindEvents() { $.fx.speeds._default = 1000; $(document).ready(function () { var dlg = $("#DivMostrarIguales").dialog({ autoOpen: false, show: "fold", hide: "clip", width: 500, height: 500 }); dlg.parent().appendTo(jQuery("form:first")); }); } </script> ENDHEAD <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <asp:UpdatePanel runat="server" ID="upTotal"> <ContentTemplate> <script type="text/javascript"> Sys.Application.add_load(BindEvents); </script>.... <tr> <td class="Izquierda"> (*) Número único: </td> <td class="Derecha"> <asp:TextBox ID="tbNumeroUnico" runat="server"></asp:TextBox> <asp:Button ID="btMostrarIgualesEntrante" runat="server" Text="Revisar si ya existe" OnClick="MostrarVentanaIgualesEntrante" ValidationGroup="none" CausesValidation="false" CssClass="Button" /> <asp:Label runat="server" ID="lbNumeroUnicoEntrante" Text="Debe digitar el formato correcto del número único (completo)" Visible="false" CssClass="ErrorCampo"></asp:Label> </td> </tr>... <div id="DivMostrarIguales" title="Número Único Igual"> WhatEver </div> </ContentTemplate> </asp:UpdatePanel> </asp:Content>
My .CS features:
private string getjQueryCode(string jsCodetoRun) { StringBuilder sb = new StringBuilder(); sb.AppendLine("$(document).ready(function() {"); sb.AppendLine(jsCodetoRun); sb.AppendLine(" });"); return sb.ToString(); } private void runjQueryCode(string jsCodetoRun) { ScriptManager requestSM = ScriptManager.GetCurrent(this); if (requestSM != null && requestSM.IsInAsyncPostBack) { ScriptManager.RegisterClientScriptBlock(this, typeof(Page), Guid.NewGuid().ToString(), getjQueryCode(jsCodetoRun), true); } else { ClientScript.RegisterClientScriptBlock(typeof(Page), Guid.NewGuid().ToString(), getjQueryCode(jsCodetoRun), true); } } protected void MostrarVentanaIgualesEntrante(object sender, EventArgs e) { CargarGridMostrarIgualesEntrante(); runjQueryCode("$('#DivMostrarIguales').dialog('open')"); }
source share