2015-02-24 53 views
0

我對RadioButton CheckedChanged有點問題。我有三個單選按鈕,一個RadDatePicker,一個文本框和一個按鈕。我只是嘗試使用文本框中給定的值來搜索數據,具體取決於所選的單選按鈕。我的問題是第三個單選按鈕,它是「dateCreated」。我想在選擇第三個單選按鈕時啓用RadDatePicker。我還需要在代碼背後執行此操作,而不是使用Javascript或任何其他方法。請幫忙。在單選按鈕上啓用/禁用RadDatePicker檢查

這裏是我的代碼:

的.aspx

<table> 
    <tr> 
     <td style="font-family: Calibri; font-weight: 400; font-style: normal; text-transform: none; color: #FFFFFF;" colspan="2"> 
      &nbsp; 
     </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> 
       &nbsp;&nbsp; 
       <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; 
    } 
} 
+0

感謝,自動回完美的作品。 – ProblemChild 2015-02-24 07:52:25

回答

0

嘗試加入自動回屬性阿洛斯

<asp:RadioButton ID="dateSearch" runat="server" GroupName="searchRad" Text="Date Created" oncheckedchanged="dateSearch_CheckedChanged" autopostback="true" />