sowmyaa guptaa sowmyaa guptaa - 2 months ago 13
ASP.NET (C#) Question

Dynamic modal dialogue box using jQuery in ASP.NET on button click

I want to display a modal dialog box when I click the button and I take the content of that dialog box from another ASPX page. But when I click the button, although the modal dialog box appears but my code in my code behind file for that button click doesn't run. How do make both of them possible together?

This is my jQuery code:

$("[id*=Button1]").live("click", function ()
{
$('<div>').dialog({
modal: true,
open: function () {
$(this).load('WebForm3.aspx');
},

buttons: {


Close: function () {
$(this).dialog('Close');

}

},

height: 600,

width: 800,

title:

'These chemicals are short! Please order the need amount!'
});
return false;

});


After this I want to run my
Button1_OnClick()
event in my aspx.cs code behind file. How can I achieve this?

Answer

You could try something like this:

$(document).ready(function(){
   $.ajax({
      url: "yourPageWhereToLoadData.aspx",
      success: function(data){
        $("#dialog").html(data);
      }
   });   
 });