Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET jQuery
Hi,
 
I created a jquery dialog box which I call from code behind
 
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 22-May-13 17:54pm
Comments
Sergey Alexandrovich Kryukov at 23-May-13 0:17am
   
No you don't. You don't call jQuery method from code behind.
—SA
Franco Cipriano at 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 at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
$('#<%=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
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
I was able to solve the problem. Here is the code
 
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
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 360
1 Gihan Liyanage 332
2 ClimerChinna 222
3 OriginalGriff 206
4 Richard MacCutchan 170
0 Sergey Alexandrovich Kryukov 8,298
1 OriginalGriff 7,112
2 CPallini 2,598
3 Richard MacCutchan 2,005
4 Abhinav S 1,788


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100