Click here to Skip to main content
12,246,032 members (33,806 online)
Rate this:
 
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 18:54pm
Comments
   
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;
}
   
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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160426.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2016
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