为什么程序无法检测是否选择了该选项? [英] Why the program cant detect if the option is selected?
本文介绍了为什么程序无法检测是否选择了该选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个文件,file.aspx和file.aspx.cs.在.aspx我有
< asp:RadioButtonList ID = < span class =code-keyword> inputOKToEmailDispatchService runat = server >
< asp:ListItem 值 = 是 文字 = 是 > < / asp:ListItem >
< asp:ListItem 值 = 无 文字 = 否 > ; < / asp:ListItem > ;
< / asp:RadioButtonList >
和aspx.cs我有
string selectedValue = inputOKToEmailDispatchService.SelectedItem.Text;
或
string selectedValueSomething = inputOKToEmailDispatchService.SelectedValue.ToString();
其中是问题?如果选择(检查)radiobuttonlist中的任何项目,则代码不会检测到。
谢谢:)
解决方案
所以,你已经创建了一个名为 inputOKToEmailDispatchService 的控件,在postpack上,未设置 inputOKToEmailSupplier 。不知道为什么?
我的解决方案是:
file.aspx
< tr >
< td < span class =code-attribute> width = 25% align = right valign = middle > 联系供应商:< / td >
< td width = 75% align = left valign = < span class =code-keyword> middle >
< asp:radiobutton id = inputOKToEmailSupplierYes runat = server groupname = inputOKToEmailSupplier text = 是 已选中 = true xmlns:asp = #unknown > < / asp:radiobutton >
< asp:radiobutton id = inputOKToEmailSupplierNo runat = 服务器 groupname = inputOKToEmailSupplier text = 无 xmlns:asp = #unknown > < / asp:radiobutton >
< label visible = false id = suppWar style = color:red runat = 服务器 > < / label >
< / td >
</ tr >
和file.aspx.cs
#region OKToEmailSupplier
if (inputOKToEmailSupplierYes.Checked)
{
ContactSupplier = 1 跨度>;
}
else if (inputOKToEmailSupplierNo.Checked)
{
ContactSupplier = 0 ;
}
#endregion
在Page_Load中,我调用了setFieldsToDefault();,其中我将所有属性设置为null值。我认为这是问题所在: )
Hi, i have 2 files, file.aspx and file.aspx.cs. In .aspx i have
<asp:RadioButtonList ID="inputOKToEmailDispatchService" runat="server">
<asp:ListItem Value="Yes" Text="Yes"></asp:ListItem>
<asp:ListItem Value="No" Text="No"></asp:ListItem>
</asp:RadioButtonList>
and in aspx.cs i have
string selectedValue = inputOKToEmailDispatchService.SelectedItem.Text;
or
string selectedValueSomething = inputOKToEmailDispatchService.SelectedValue.ToString();
Where is the problem? The code dont detect, if the any item in radiobuttonlist is selected (checked).
Thanks :)
解决方案
So, you've created a control called inputOKToEmailDispatchService and on postpack, the inputOKToEmailSupplier is not set. Wonder why?
My solution is:
file.aspx
<tr> <td width="25%" align="right" valign="middle">Contact supplier:</td> <td width="75%" align="left" valign="middle"> <asp:radiobutton id="inputOKToEmailSupplierYes" runat="server" groupname="inputOKToEmailSupplier" text="Yes" checked="true" xmlns:asp="#unknown"></asp:radiobutton> <asp:radiobutton id="inputOKToEmailSupplierNo" runat="server" groupname="inputOKToEmailSupplier" text="No" xmlns:asp="#unknown"></asp:radiobutton> <label visible="false" id="suppWar" style="color:red" runat="server"></label> </td> </tr>
and file.aspx.cs
#region OKToEmailSupplier if (inputOKToEmailSupplierYes.Checked) { ContactSupplier = 1; } else if(inputOKToEmailSupplierNo.Checked) { ContactSupplier = 0; } #endregion
In Page_Load i called thesetFieldsToDefault();, where i put all attributes to "null" value.. I think that was the problem :)
这篇关于为什么程序无法检测是否选择了该选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文