asp.NET - Open jQuery UI Dialog from Code Behind

sumfgt

New Member
I am kind of new with jQuery and JavaScript, and I ran into a problem. I am having some problems to open the jQuery UI Dialog Box from my ButtonField within the Gridview:\[code\]<asp:ButtonField ButtonType="link" Text="Modify Deadline" Visible="true" runat="server" CommandName="modifyDeadline" ControlStyle-CssClass="button" ItemStyle-CssClass="sliderPopupOpener"/>\[/code\]At first I tried to give a class to the above and named it sliderPopupOpener, and make it open the jQuery Popup when clicked as below: \[code\]$(".sliderPopupOpener").click(function () { $("#sliderPopup").dialog("open");});\[/code\]However, this was not working because of the postback, apart from that, it also does not work with my approach. Since I would like to get some data from the database before showing the jQuery UI Dialog. So I think the best approach is to call the Dialog function from the Code Behind.How can I do this?I tried this approach, but it did not work, I am not sure if I am doing something wrong. \[code\]if (e.CommandName == "modifyDeadline"){ string sliderPopupFunction = @" <script type=""text/javascript""> $(function () { jQuery(function () { $(""#sliderPopup"").dialog(""open""); } }); </script>"; ClientScript.RegisterStartupScript(typeof(Page), "key", sliderPopupFunction);}\[/code\]Is the above possible? If so, what am I doing wrong?EDIT:I noticed everyone is giving their answers with a way around this, rather than telling me whether this is possible just by calling the jQuery function from the Code Behind. Although I appreciate other solutions, I would appreciate if I could get this to work, with the least effort possible, through the code behind, since I have everything ready that way.
 
Back
Top