Enable/Disable 选中单选按钮上的 RadDatePicker
Enable/Disable RadDatePicker on Radio Button Checked
我在 RadioButton CheckedChanged 方面遇到了一些问题。我有三个单选按钮、一个 RadDatePicker、一个文本框和一个按钮。我只是想根据所选的单选按钮使用文本框中给定的值来搜索数据。我的问题是第三个单选按钮,即 "dateCreated"。我想在选择第三个单选按钮时启用 RadDatePicker。我还需要在后面的代码中执行此操作,而不是使用 Javascript 或任何其他方法。请帮助。
这是我的代码:
.aspx
<table>
<tr>
<td style="font-family: Calibri; font-weight: 400; font-style: normal; text-transform: none; color: #FFFFFF;" colspan="2">
</td>
<td class="style19" align="left" colspan="2" style="font-family: Calibri; font-weight: 400; font-style: normal; text-transform: none; color: #FFFFFF">
<asp:Label ID="searchTitle" runat="server" CssClass="style47" Font-Bold="False" Font-Names="Traditional Arabic" Font-Size="Medium" Font-Strikeout="False" ForeColor="#006699" Style="font-size: x-large; font-family: 'Myriad Pro'" Text="Search Non-Disclosure Document"></asp:Label>
</td>
</tr>
</table>
<table style="font-family: Calibri">
<tr>
<td class="style75">
</td>
</tr>
<tr>
<td class="style81">
</td>
<td class="style84">
</td>
<tr>
<td bgcolor="#EEF4FD" class="style77">
<asp:Label ID="ndaSearchTitle" runat="server" Text="Search NDA by :"></asp:Label>
</td>
<td bgcolor="#EEF4FD" class="style87">
</td>
<td bgcolor="#EEF4FD" class="style83">
<asp:RadioButton ID="nameSearch" runat="server" Checked="true" GroupName="searchRad" Text="Company Name" />
</td>
</tr>
<tr>
<td bgcolor="#EEF4FD" class="style77">
</td>
<td bgcolor="#EEF4FD" class="style87">
</td>
<td bgcolor="#EEF4FD" class="style83">
<asp:RadioButton ID="countrySearch" runat="server" GroupName="searchRad" Text="Country Incorperated" />
</td>
</tr>
<tr>
<td bgcolor="#EEF4FD" class="style77">
</td>
<td bgcolor="#EEF4FD" class="style87">
</td>
<td bgcolor="#EEF4FD" class="style83">
<asp:RadioButton ID="dateSearch" runat="server" GroupName="searchRad" Text="Date Created" oncheckedchanged="dateSearch_CheckedChanged" />
<telerik:RadDatePicker ID="RadDatePicker2" runat="server"
DateInput-DateFormat="dd-MM-yyyy" Skin="Default" style="margin-left: 0px" Width="45%" Enabled="false">
</telerik:RadDatePicker>
</td>
</tr>
<tr>
<td bgcolor="#93B4DF" class="style3" colspan="3" style="font-family: Calibri; font-size: large; font-weight: normal; height:20px;">
</td>
</tr>
<tr>
<td bgcolor="#EEF4FD" class="style77">
</td>
<td bgcolor="#EEF4FD" class="style87">
</td>
<td bgcolor="#EEF4FD" class="style83">
<asp:TextBox ID="ndaSearchBox" runat="server" Width="350px"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Search" />
</td>
</tr>
</tr>
</table>
aspx.cs
protected void dateSearch_CheckedChanged(object sender, EventArgs e)
{
if (dateSearch.Checked == true)
{
RadDatePicker2.Enabled = true;
}
else
{
RadDatePicker2.Enabled = false;
}
}
尝试添加 autopostback 属性
<asp:RadioButton ID="dateSearch" runat="server" GroupName="searchRad" Text="Date Created" oncheckedchanged="dateSearch_CheckedChanged" autopostback="true" />
我在 RadioButton CheckedChanged 方面遇到了一些问题。我有三个单选按钮、一个 RadDatePicker、一个文本框和一个按钮。我只是想根据所选的单选按钮使用文本框中给定的值来搜索数据。我的问题是第三个单选按钮,即 "dateCreated"。我想在选择第三个单选按钮时启用 RadDatePicker。我还需要在后面的代码中执行此操作,而不是使用 Javascript 或任何其他方法。请帮助。
这是我的代码:
.aspx
<table>
<tr>
<td style="font-family: Calibri; font-weight: 400; font-style: normal; text-transform: none; color: #FFFFFF;" colspan="2">
</td>
<td class="style19" align="left" colspan="2" style="font-family: Calibri; font-weight: 400; font-style: normal; text-transform: none; color: #FFFFFF">
<asp:Label ID="searchTitle" runat="server" CssClass="style47" Font-Bold="False" Font-Names="Traditional Arabic" Font-Size="Medium" Font-Strikeout="False" ForeColor="#006699" Style="font-size: x-large; font-family: 'Myriad Pro'" Text="Search Non-Disclosure Document"></asp:Label>
</td>
</tr>
</table>
<table style="font-family: Calibri">
<tr>
<td class="style75">
</td>
</tr>
<tr>
<td class="style81">
</td>
<td class="style84">
</td>
<tr>
<td bgcolor="#EEF4FD" class="style77">
<asp:Label ID="ndaSearchTitle" runat="server" Text="Search NDA by :"></asp:Label>
</td>
<td bgcolor="#EEF4FD" class="style87">
</td>
<td bgcolor="#EEF4FD" class="style83">
<asp:RadioButton ID="nameSearch" runat="server" Checked="true" GroupName="searchRad" Text="Company Name" />
</td>
</tr>
<tr>
<td bgcolor="#EEF4FD" class="style77">
</td>
<td bgcolor="#EEF4FD" class="style87">
</td>
<td bgcolor="#EEF4FD" class="style83">
<asp:RadioButton ID="countrySearch" runat="server" GroupName="searchRad" Text="Country Incorperated" />
</td>
</tr>
<tr>
<td bgcolor="#EEF4FD" class="style77">
</td>
<td bgcolor="#EEF4FD" class="style87">
</td>
<td bgcolor="#EEF4FD" class="style83">
<asp:RadioButton ID="dateSearch" runat="server" GroupName="searchRad" Text="Date Created" oncheckedchanged="dateSearch_CheckedChanged" />
<telerik:RadDatePicker ID="RadDatePicker2" runat="server"
DateInput-DateFormat="dd-MM-yyyy" Skin="Default" style="margin-left: 0px" Width="45%" Enabled="false">
</telerik:RadDatePicker>
</td>
</tr>
<tr>
<td bgcolor="#93B4DF" class="style3" colspan="3" style="font-family: Calibri; font-size: large; font-weight: normal; height:20px;">
</td>
</tr>
<tr>
<td bgcolor="#EEF4FD" class="style77">
</td>
<td bgcolor="#EEF4FD" class="style87">
</td>
<td bgcolor="#EEF4FD" class="style83">
<asp:TextBox ID="ndaSearchBox" runat="server" Width="350px"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Search" />
</td>
</tr>
</tr>
</table>
aspx.cs
protected void dateSearch_CheckedChanged(object sender, EventArgs e)
{
if (dateSearch.Checked == true)
{
RadDatePicker2.Enabled = true;
}
else
{
RadDatePicker2.Enabled = false;
}
}
尝试添加 autopostback 属性
<asp:RadioButton ID="dateSearch" runat="server" GroupName="searchRad" Text="Date Created" oncheckedchanged="dateSearch_CheckedChanged" autopostback="true" />