Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi,

I created a jquery dialog box which I call from code behind

C#
sb.Append("$(function() { ");
            sb.Append(" var dlg = jQuery('#Update').dialog({");
            sb.Append("    width: 400,height: 300, modal:true");
            sb.Append(" });");
            sb.Append("dlg.parent().appendTo(jQuery('form:fist'));");
            sb.Append("});");
            Page.ClientScript.RegisterStartupScript(typeof(Page), "dgUpdate", sb.ToString(), true);


When this opens up in my page the button on the dialog box that has a code behind script does not work. I saw some articles in the web and tried to follow it but with no luck, any help is greatly needed.

Thanks,
Posted
Comments
Sergey Alexandrovich Kryukov 23-May-13 0:17am    
No you don't. You don't call jQuery method from code behind.
—SA
Franco Cipriano 23-May-13 2:43am    
I call the jquery from code behind since I need to execute a script after opening the jquery. I tried calling the jquery from javascript but it closes right away

function openDialog(divname) {
$('#' + divname).dialog({
width: 400,height: 300,
open:function() {$(this).parent().appendTo("form:first");}
});

return true;
}
Sergey Alexandrovich Kryukov 23-May-13 2:45am    
No you don't. Code behind is on server part, jQuery on client. Perhaps you call "a call" something else, which is not called like that.
Code behind generates all the content, and browser calls JavaScript functions.
—SA

I also encountered the same issue while developing using JQuery dialog.
what i done is
First i mentioned the button with client id as button in a script tag in the page ,
then i used Jquery ajax call back in client click of this button to do the server operations.
XML
$('#<%=btnClose.ClientID%>').button().click(function () {
            //Do ajax call back here 
        });

by doing this you can see that the style of button will automatically change(depends on your css)
OR else place another button outside the dialog and then invoke the button click or__dopostback from the modal dialog button client click.(not a right practice)
As per my experience you can only do client operations with buttons placed Jquery dialog
 
Share this answer
 
v2
Hi,

I was able to solve the problem. Here is the code

C#
sb.Append("$(function() { ");
            sb.Append(" $('#Update').dialog({");
            sb.Append("    width: 400,height: 300,");
            sb.Append("open:function() {$(this).parent().appendTo(\"form\");},");
            sb.Append("});");
            sb.Append("});");
            Page.ClientScript.RegisterStartupScript(typeof(Page), "dgUpdate", sb.ToString(), true);


But here is another problem..It does not work on Content page of Master page
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900