Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server , +
Dear Friends,
 
am working on Asp.net, c#, SqlServer 2005.
 
I have Two Textboxes FromDate and ToDate and I have two Dropdwonlist lists with Month & Year.
 
I have Radiobuttonlist on my webpage, In this i have two items with Enable option.
 
When I select one option enable, it should ENABLE two dates textboxes and DISABLE two dropdownlists.
 
and When I select 2nd option enable, it should ENABLE two dropdownlist and DISABLE two dates textboxes.
 
so please help me,
 
This is my code. and Also i gave AutoPostBack = true for radiobuttonlist.
 
protected void RBLoginHistorySelection_SelectedIndexChanged(object sender, EventArgs e)
   {
       if (RBLoginHistorySelection.SelectedItem.Selected == true)
       {
           TxtFromDate.Enabled = true;
           TxtToDate.Enabled = true;
 
           DDLMonth.Enabled = false;
           DDLYear.Enabled = false;
 
           
 

       }
 
       else
       {
           TxtFromDate.Enabled = false;
           TxtToDate.Enabled = false;
 
           DDLMonth.Enabled = true;
           DDLYear.Enabled = true;
 

          
       }
 
           }
 

 

Please help, Thanks in Advance.
Posted 25-Feb-13 21:41pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try this code:
 
<asp:radiobuttonlist id="RadioButtonList1" runat="server" autopostback="true" xmlns:asp="#unknown">
        onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
<asp:listitem text="Enable Text"></asp:listitem>
<asp:listitem text="Enable DDL"></asp:listitem>
</asp:radiobuttonlist>
    
 
<asp:textbox id="TextBox1" runat="server" xmlns:asp="#unknown"></asp:textbox>
    
<asp:dropdownlist id="DropDownList1" runat="server" xmlns:asp="#unknown"></asp:dropdownlist>
 
 
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (RadioButtonList1.SelectedItem.Text == "Enable Text") // Enable text box
        {
            TextBox1.Enabled = true; // this is a just an example, place your controls here.
            DropDownList1.Enabled = false;
        }
        else if (RadioButtonList1.SelectedItem.Text == "Enable DDL") // Enable Dropdown
        {
            TextBox1.Enabled = false;
            DropDownList1.Enabled = true;
        }
        else
        {
            TextBox1.Enabled = false;
            DropDownList1.Enabled = false;
        }
    }
  Permalink  
Comments
Software Engineer 892 at 26-Feb-13 3:02am
   
Thank you So Much my dear Friend, Its working.
Vani Kulkarni at 26-Feb-13 3:07am
   
Great!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 26 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100