0
votes

I am having an empty div and i am using LOAD method of jquery and getting data from another aspx page. it works fine. it gets File upload and button control from that page. now when i click on the button my button code doesn't get called and my dialog gets close.

jQuery On Page1.aspx

var checkP = $('#<%= productName.ClientID %>').val();
checkP = checkP.replace(/\ /g, '-');
$("#midDiv").load("UploadImages.aspx?prodName=" + checkP + " #midDiv");
$("#midDiv").dialog();
//It Shows Dialog With File Upload Option & Button Option.

Page1.aspx

 <div id="midDiv">

</div>

Page2.aspx

<div id="midDiv">     
<asp:FileUpload ID="productsImages" CssClass="hid" runat="server" />     
  <asp:Button ID="Button1" runat="server" OnClick="uploadImageTemp" Text="Button" />      
</div>

Page2.aspx.cs //Code Behind

protected void uploadImageTemp(object sender, EventArgs e)
{
    //Some Work Here...
}

Is there any way that my button code gets called or is there any way to keep jQuery modal open ?

1
I do something similar with a Bootstrap Modal. What I do is add a data-attribute to the div(from the code behind, uploadButton) and then when the page is refreshed after postback I have jQuery search for the attribute and pop the modal.Tony
could you please show me how to perform this ? i tried every damn thing but none of them worked :(Fazil Mir
Check this answer: stackoverflow.com/a/59730/335905celerno

1 Answers

0
votes

Append your dialog in form like below.

var checkP = $('#<%= productName.ClientID %>').val();
checkP = checkP.replace(/\ /g, '-');
$("#midDiv").load("UploadImages.aspx?prodName=" + checkP + " #midDiv");
$("#midDiv").dialog().parent().appendTo($("form:first"));

Change your button control to link button control.

<div id="midDiv">     
<asp:FileUpload ID="productsImages" CssClass="hid" runat="server" />     
  <asp:LinkButton ID="Button1" runat="server" OnClick="uploadImageTemp" Text="Button" />      
</div>

Now call your code behind button click event.