Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.IO;
public partial class birth : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection();
    SqlCommand cmd = new SqlCommand();
    SqlDataAdapter da;
    string Z;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            
            Calendar1.Visible = false;
            Calendar2.Visible = false;
            TextBox28.Enabled = false;
            TextBox29.Enabled = false;
            TextBox30.Enabled = false;
            TextBox31.Enabled = false;
            TextBox32.Enabled = false;
            TextBox33.Enabled = false;
            TextBox34.Enabled = false;
            RadioButton3.Enabled=false;
            RadioButton4.Enabled=false;
            RadioButton5.Enabled=false;
            RadioButton6.Enabled=false;



        }



        }

//calender 1
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (Calendar1.Visible)
        {
            Calendar1.Visible = false;
        }
        else
        {
            Calendar1.Visible = true;
        }
    }
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        TextBox6.Text = Calendar1.SelectedDate.ToString("d");
        Calendar1.Visible = false;
    }
    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        if (e.Day.IsOtherMonth || e.Day.IsWeekend)
        {
            e.Day.IsSelectable = false;
        }
    }

    //calender 2
    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        if (Calendar2.Visible)
        {
            Calendar2.Visible = false;
        }
        else
        {
            Calendar2.Visible = true;
        }
    }
    protected void Calendar2_SelectionChanged(object sender, EventArgs e)
    {
        TextBox29.Text = Calendar2.SelectedDate.ToString("d");
        Calendar2.Visible = false;
    }
    protected void Calendar2_DayRender(object sender, DayRenderEventArgs e)
    {
        if (e.Day.IsOtherMonth || e.Day.IsWeekend)
        {
            e.Day.IsSelectable = false;
        }
    }

    //calender 3
    protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
    {

        if (Calendar3.Visible)
        {
            Calendar3.Visible = false;
        }
        else
        {
            Calendar3.Visible = true;
        }
    }
    protected void Calendar3_SelectionChanged(object sender, EventArgs e)
    {
        TextBox36.Text = Calendar3.SelectedDate.ToString("d");
        Calendar3.Visible = false;
    }
    protected void Calendar3_DayRender(object sender, DayRenderEventArgs e)
    {
        if (e.Day.IsOtherMonth || e.Day.IsWeekend)
        {
            e.Day.IsSelectable = false;
        }
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
       



        //radio

        TextBox3.Focus();
        SqlConnection con = new SqlConnection();
        string z;
        if (RadioButton1.Checked)
        {
            Z = RadioButton1.Text;
        }
        else
        {
            Z = RadioButton2.Text;

        }

        //checkbox
        StringBuilder sbUsersChoices = new StringBuilder();
        if (CheckBox1.Checked)
        {
            sbUsersChoices.Append(CheckBox1.Text);
        }
        if (CheckBox2.Checked)
        {
            sbUsersChoices.Append(CheckBox2.Text);
        }
        if (CheckBox3.Checked)
        {
            sbUsersChoices.Append(CheckBox3.Text);
        }
        Response.Write("Your SELECTION :" + sbUsersChoices.ToString()); 



        /*
        con = new SqlConnection("Data Source=\\sqlexpress;Initial Catalog=civil;Integrated Security=True");
        con.Open();
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;


        string query = "insert into tbl_Contact([Name],[Email],[Message]) values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "')";
        
        cmd.CommandText = query;
        cmd.ExecuteNonQuery();
        ScriptManager.RegisterStartupScript(this, GetType(), "SHOW", "alert('send successfully.....!')", true);

        con.Close();

        Label1.Text = "data inserted successfully.....";

        TextBox1.Text = "";
        TextBox2.Text = "";
        TextBox3.Text = "";*/
        
       

        //file upload
        if (FileUpload1.HasFile)
        {
            String filename = Path.Combine(Server.MapPath("~/Files"), FileUpload1.FileName);
            FileUpload1.SaveAs(@"C:\Users\a\Documents\Visual Studio 2010\WebSites\new\imageuploaded"+FileUpload1.FileName);
            Label1.Text = "File Uploaded:" + FileUpload1.FileName;
        }
        else
        {
            Label1.Text = "No File Uploded";
        
        }

    }

    protected void RadioButton3_CheckedChanged(object sender, EventArgs e)
    {

        if(RadioButton3.Checked==true)
            {
            
            RadioButton3.Enabled = true;
            TextBox28.Enabled = true;
            TextBox28.Focus();
            TextBox29.Enabled = true;
            TextBox30.Enabled = true;
        
    }
    protected void RadioButton4_CheckedChanged(object sender, EventArgs e)
    {
        if (RadioButton4.Checked == true)
        {

            RadioButton4.Enabled = true;
            TextBox31.Enabled = true;
            TextBox32.Enabled = true;
            TextBox33.Enabled = true;
            TextBox34.Enabled = true;
          
            


        }
    }
    protected void RadioButton5_CheckedChanged(object sender, EventArgs e)
    {
        if (RadioButton5.Checked == true)
        {

            RadioButton5.Enabled = true;
            



        }
    }
    protected void RadioButton6_CheckedChanged(object sender, EventArgs e)
    {
        if (RadioButton6.Checked == true)
        {

            RadioButton6.Enabled = true;
            



        }
    }
}
Posted
Updated 30-Sep-15 21:23pm
v2
Comments
Thanks7872 1-Oct-15 3:24am    
Posting such huge code dumps is meaning less. Nobody will be interested in answering such questions.
Sarath kumar.N 1-Oct-15 3:44am    
you can do it using jquery
Ehsan Sajjad 1-Oct-15 3:58am    
post the relevant code only don't post all the code
Naveen.Sanagasetti 1-Oct-15 4:45am    
Already you are enabling textbox based on radio button selection; then what's the issue on that. Are you getting any error.

Posting this much code didn't get me anything, but as you have asked in your question, try this:
C#:
C#
protected void RadioButton_CheckedChanged(object sender, EventArgs e)
{
    myTxt.Enabled = true;
}

or using jQuery:
JavaScript
$("#radioButton").change(function() {
    $("#myTxtBox").removeAttr("disabled");
});

-KR
 
Share this answer
 
Just Add This Code to Your Page.
C#
protected void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)
 {
          if(RadioButtonList1.SelectedItem.Text=="Comapany")
          {
                   Textbox1.Enable=true;
           }
         else
         {
                  Textbox1.Enable=false;
         }

}
 
Share this answer
 
v2
By Using Jquery You Can also Enable or Disabling a Text box(If My Solution Look Useful to U Thn Plz Accept My Answer)
XML
<head runat="server">
    <title>Untitled Page</title>
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $('#Radiobtn1 input').change(function() {
                if ($(this).val() == 0) {
                    $("#Textbox1").css("display", "block");
                }
                else {
                    $("#Textbox1").css("display", "none");
                }
            });
        });
    </script>
</head>
<body>
    <form id="login_form" runat="server">
        <asp:RadioButtonList ID="Radiobtn1" runat="server">
            <asp:ListItem Text="True" Value="0"></asp:ListItem>
            <asp:ListItem Text="False" Value="1"></asp:ListItem>
        </asp:RadioButtonList>
        <asp:TextBox runat="server" style="display:none" ID="Textbox1" Width="50px"></asp:TextBox>
    </form>
</body>
</html>
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900