Skip to content

Reading same textbox value each time from jquery popup

I have JQuery Popup whchi has a textbox. JQuery Popup trigger on OnClick event of a Checkbox.


<div id="popupdiv" title="Basic modal dialog" style="display: none"> Enter Password
<asp:TextBox ClientID="pass" ClientIDMode="static" runat="server" class="textcss" ></asp:TextBox></div>
<div id="DiscountEnd" style="display: none"></div> 
<asp:CheckBox ID="DiscountAtEnd" Text="Offer Discount" style="margin-left:10px;float:left;margin-top:3px;padding-right:27px; " ForeColor="#008269" Font-Bold="false" runat="server" AutoPostBack="True" OnClick="return DiscountAtLast(this);"/>                        
<asp:Button ID="btnDiscountAtEnd" runat="server" style="display:none;" Text="Button" OnClick="btnDiscountAtEnd_Click" />

My effort is to receive textbox value in server side C# Code and display it using an other jquery popup

Server Side Code C#

string discountEnd = Request.Form["discount_end"];    
ScriptManager.RegisterStartupScript(this, this.GetType(), "p", "<script>MessageBox('" + discountEnd + "');</script>", false);


My server side code can receive JQuery popup textbox value but every time i get the same value which was entered at first time after page load. I thhink there is some variable initialization but could not figure out

enter image description here


 function DiscountAtLast(chk) {
    $(function () {
        var discount_end = document.createElement("INPUT");
        discount_end.type = "hidden"; = "discount_end";

        if (chk.checked) {
                title: "Login Info",
                resizable: false,
                height: "auto",
                width: 400,
                buttons: {
                    Cancel: function () {
                        discount_end.value = $("[id*=pass]").val();

                        return false;

                    Ok: function () {
                        discount_end.value = $("[id*='pass']").val()
                        __doPostBack('<%=btnDiscountAtEnd.UniqueID%>', "");

                        return true;



Value receive at server side C# should be same as per textbox input value each time


I did not initialize my dialog i.e popupdiv

put $("[id*=popupdiv]").empty();just before return statement of JQuery Script