Click here to Skip to main content
15,907,905 members
Please Sign up or sign in to vote.
1.73/5 (3 votes)
See more:
I am using modal popup in which i have one textbox, On click on send button it is executing the code behind functionality but not fetching textbox value.

JavaScript
<link type="text/css" rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script type="text/javascript">
        $(function () {
        $('#btnclick').click(function () {
            $("#popupdiv").dialog({
                title: "Send details to email address",
                width: 400,
                height: 200,
                modal: true,
                buttons: {
                    Send: function () {
                        $("[id*=but_send]").click();
                    },
                    Close: function () {
                        $(this).dialog('close');
                    }
                }
            });
        });
    })
    </script>

ASP.NET
<div id="popupdiv" title="Basic modal dialog" style="display: none">
Enter email address
<asp:TextBox ID="txt_email" runat="server" class="textcss" ></asp:TextBox>
<asp:Label ID="lbl_status" runat="server" CssClass="red" Text=""></asp:Label>
</div>
<asp:Button ID="but_send" runat="server" Text="Send" style = "display:none" OnClientClick="return sendvalidate();" onclick="but_send_Click" />

C#
protected void but_send_Click(object sender, EventArgs e)
    {
        string email = txt_email.Text;
    }
Posted
Comments
Interesting... What value you have in that TextBox?
Raj Negi 8-May-14 2:34am    
email address enter by user
Sunasara Imdadhusen 8-May-14 3:07am    
Can you please provide Page_Load code here!!
Raj Negi 8-May-14 4:23am    
there is nothing in page load

check the value in hidden field 'hndtxt_email.Value'
 
Share this answer
 
Comments
Raj Negi 12-May-14 8:58am    
i put debugger and it shows null.
use a hidden field to submit client side value to server

XML
.aspx Code
--------------
<link type="text/css" rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
    $(function () {
        $('#btnclick').click(function () {
            $("#popupdiv").dialog({
                title: "Send details to email address",
                width: 400,
                height: 200,
                modal: true,
                buttons: {
                    Send: function () {
                        $("[id*=hndtxt_email]").val($("[id*=txt_email]").val());
                        $("[id*=but_send]").click();
                    },
                    Close: function () {
                        $(this).dialog('close');
                    }
                }
            });
        });
    })
</script>
<div id="popupdiv" title="Basic modal dialog" style="display: none">
    Enter email address
    <asp:textbox id="txt_email" runat="server" class="textcss"></asp:textbox>
    <asp:label id="lbl_status" runat="server" cssclass="red" text=""></asp:label>
</div>
<asp:button id="but_send" runat="server" text="Send" style="display: none" onclientclick="return sendvalidate();"
    onclick="but_send_Click" />
<asp:hiddenfield id="hndtxt_email" runat="server" />


.cs Code
--------------
protected void but_send_Click(object sender, EventArgs e)
    {
        string email = hndtxt_email.Value;
    }
 
Share this answer
 
Comments
Raj Negi 12-May-14 8:14am    
Thanks for reply but not working, it still fetching null value. plz help

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