Click here to Skip to main content
15,895,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<script src="Scripts/jquery-ui.js" type="text/javascript"></script>
   <script src="Scripts/jquery-1.8.2.js" type="text/javascript"></script>
   <script type="text/javascript">
       function showmodalpopup() {
           $("#popupdiv").dialog({
               title: "jQuery Popup from Server Side",
               width: 430,
               height: 250,
               modal: true,
               buttons: {
                   Close: function () {
                       $(this).dialog('close');
                   }
               }
           });
       };
   </script>

XML
<form id="form1" runat="server">
   <div>
       <asp:TextBox runat="server" ID="txtText"></asp:TextBox>
       <asp:UpdatePanel>
           <ContentTemplate>
               <div id="popupdiv" title="Basic modal dialog" style="display: none">
                   <asp:Label runat="server" ID="lblTextboxValue"></asp:Label>
               </div>
           </ContentTemplate>
       </asp:UpdatePanel>
       <asp:Button ID="btnShowModal" runat="server" Text="Show Popup" OnClick="btnShowModal_Click" />
   </div>
   </form>



C#
protected void btnShowModal_Click(object sender, EventArgs e)
  {
      lblTextboxValue.Text = txtText.Text;
      //ScriptManager.RegisterStartupScript(this, GetType(), "Show Modal Popup", "showmodalpopup();", true);
      ClientScript.RegisterStartupScript(this.GetType(), "Popup", "showmodalpopup();", true);

  }







i want to show textbox value from texbox txtText in label lblTextboxValue and open popupdiv as popup using jquery



please help
Posted

1.In you ASP page, first you need to have to register/load the javascript that define the popup in window.onload event then like in the next example.

C#
window.onload = function () {
               $("#popupdiv").dialog({
               title: "jQuery Popup from Server Side",
               width: 430,
               height: 250,
               modal: true,
               buttons: {
                   Close: function () {
                       $(this).dialog('close');
                   }
             }
    });
};

2.Also in the same ASP script block (but NOT in the onload event!) to add a new script for opening the popup:
C#
function openPopup() {
    $("#popupdiv").dialog("open");
}

3.Finally in your C# code to invoke this 2nd javascript to activate the popup:
C#
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "openPopup();", true);
 
Share this answer
 
Comments
kedar001 9-May-14 1:40am    
thanks for your reply..<br>
now i'm getting an error "Object doesn't support property or method 'dialog'" on page load
Raul Iloc 9-May-14 2:52am    
You have to add reference to the used jquery library.<br>
In my project I am using the next libraries in this order: "jquery-1.5.2.min.js", "jquery-ui-1.8.11.min.js", so you are missing the first one!
kedar001 9-May-14 3:37am    
thanks
its WORKING NOW ...
Raul Iloc 9-May-14 7:01am    
Nice, welcome!
Please remove upadate panael or put your button in update panel
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900