Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET jQuery
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(" });");
            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.
Posted 22-May-13 17:54pm
Sergey Alexandrovich Kryukov at 23-May-13 0:17am
No you don't. You don't call jQuery method from code behind.
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.
Rate this: bad
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
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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\");},");
            Page.ClientScript.RegisterStartupScript(typeof(Page), "dgUpdate", sb.ToString(), true);
But here is another problem..It does not work on Content page of Master page

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 540
1 CPallini 290
2 OriginalGriff 265
3 ChauhanAjay 124
4 George Jonsson 120
0 OriginalGriff 6,474
1 Sergey Alexandrovich Kryukov 6,190
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522

Advertise | Privacy | Mobile
Web02 | 2.8.140916.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