弹出文本框值始终为null [英] popup textbox value is always null
本文介绍了弹出文本框值始终为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试制作小弹出窗体。当用户点击显示弹出窗口按钮时,弹出窗口将显示两个字段1.)编号2.)电子邮件和两个按钮发送和取消。
我希望用户填写时任何两个字段或两个字段....然后单击发送按钮然后在相应代码后面的代码将执行。
但是如果我检查后面的代码中的文本框值显示为null。
< script type = text / javascript跨度>>
$( function (){
$(' #<%= btnclick.ClientID%>')。click( function (){
$(< span class =code-string> #popupdiv)。dialog({
title: 将详细信息发送到移动/电子邮件,
宽度: 500 ,
身高: 250 ,
modal: true ,
buttons :{
发送: function (){
$( [id * = btnSend])。click();
},
关闭: function (){
$( this )。dialog(' close');
}
}
});
return false ;
});
})
< / script>
< div id = popupdiv title = 基本模态对话框 样式 = display:none >
< 表 border = 0 >
< tr >
< td >
收件人编号:
< / td >
< td >
< asp:TextBox ID = txtRecipientNumber < span class =code-attribute> runat = server MaxLength = 10 > < / asp:TextBox >
< / td >
< / tr >
< tr >
< td >
收件人电邮:
< / td & gt;
< td >
< asp:TextBox ID = txtRecipientEmail runat = server MaxLength = 50 > < / asp:TextBox >
< / td >
< / tr >
< tr >
< td > < / td >
< td > < asp:Label ID = Label1 runat = server < span class =code-attribute>文本 = 成功 > < / asp:Label > < / td >
< / tr >
< / table >
< / div >
< asp:按钮 ID = btnclick runat = server 文本 = 显示弹出窗口 / >
< asp:按钮 ID = btnSend runat = server style = display:none 文本 = 发送 OnClick = btnSend_Click OnClientClick = return validate(); / >
protected < span class =code-keyword> void btnSend_Click( object sender,EventArgs e)
{
尝试
{
if (txtRecipientNumber .Text!= )
{
// 如果此文本框不为空,则此代码将执行。
}
< span class =code-keyword> if (txtRecipientEmail.Text!= )
{
// 如果此文本框不为空,则此代码将执行。
}
}
catch (例外)
{
Label1.Text = 出了点问题。稍后再试!!!;
Label1.ForeColor = System.Drawing.Color.Red;
}
}
解决方案
( function (){
(' #<%= btnclick.ClientID%>')。click( function (){
( #popupdiv )。对话框({
title: 将详细信息发送到移动/电子邮件,
宽度: 500 ,
height: 250 ,
modal: true ,
按钮:{
发送: function (){
I am trying to make small popup form. When user click on "Show Popup" button, a pop up will show with two fields 1.) number 2.) email and two buttons "Send" and "Cancel".
I Want when user fill any of the two fields or both fields....and click on send button then at code behind corresponding code will execute.
But if i check the textbox value in code behind it shows null.
<script type="text/javascript"> $(function () { $('#<%=btnclick.ClientID%>').click(function () { $("#popupdiv").dialog({ title: "Send details to Mobile/Email", width: 500, height: 250, modal: true, buttons: { Send: function () { $("[id*=btnSend]").click(); }, Close: function () { $(this).dialog('close'); } } }); return false; }); }) </script>
<div id="popupdiv" title="Basic modal dialog" style="display: none"> <table border="0"> <tr> <td> Recipient Number: </td> <td> <asp:TextBox ID="txtRecipientNumber" runat="server" MaxLength="10"></asp:TextBox> </td> </tr> <tr> <td> Recipient Email: </td> <td> <asp:TextBox ID="txtRecipientEmail" runat="server" MaxLength="50"></asp:TextBox> </td> </tr> <tr> <td></td> <td><asp:Label ID="Label1" runat="server" Text="Success"></asp:Label></td> </tr> </table> </div> <asp:Button ID="btnclick" runat="server" Text="Show Popup" /> <asp:Button ID="btnSend" runat="server" style = "display:none" Text="Send" OnClick="btnSend_Click" OnClientClick="return validate();" />
protected void btnSend_Click(object sender, EventArgs e) { try { if (txtRecipientNumber.Text!="") { //if this textbox is not empty then this code will execute. } if (txtRecipientEmail.Text!="") { //if this textbox is not empty then this code will execute. } } catch (Exception) { Label1.Text = "Something went wrong. Try again later!!!"; Label1.ForeColor = System.Drawing.Color.Red; } }解决方案(function () {
('#<%=btnclick.ClientID%>').click(function () {
("#popupdiv").dialog({ title: "Send details to Mobile/Email", width: 500, height: 250, modal: true, buttons: { Send: function () {
这篇关于弹出文本框值始终为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文