Click here to Skip to main content
12,300,240 members (55,144 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
first i have disabled textbox on page load, after clicking on radiobutton i want enable it and have to store clicked value of radio button in database
Posted 8-Nov-12 20:51pm
Comments
Nelek 9-Nov-12 2:55am
   
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

disable text box in not ispostback and enable it in raidobutton check change event for that u have to set autopostback true of radiobutton and i suggest u to put it in updatepanel....
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

public partial class RadioButton : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        TextBox1.Enabled = false;
    }
    protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
    {
        TextBox1.Enabled = true;
        TextBox1.Text = "I Am Male";
        string value = RadioButton1.Text;
        SqlConnection sqlconn = new SqlConnection("server=.\\sqlexpress;database=practice;integrated security=true;");
        SqlCommand sqlcomm = new SqlCommand("insert into insertvalue(radiobtnvalue) values(@a)", sqlconn);
        sqlconn.Open();
        sqlcomm.Parameters.Add("@a", SqlDbType.VarChar, 10).Value = value.ToString();
 
        sqlcomm.ExecuteNonQuery();
        sqlconn.Close();
        Response.Write("Value Saved");
    }
}

Source-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadioButton.aspx.cs" Inherits="RadioButton" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 87px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
        <table class="style1">
            <tr>
                <td class="style2">
                    Select Value</td>
                <td>
                    <asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True"
                        oncheckedchanged="RadioButton1_CheckedChanged" Text="Male" />
                </td>
            </tr>
            <tr>
                <td class="style2">
                    Name</td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
 
    </div>
    </form>
</body>
</html>

Sql part-

create table insertvalue(radiobtnvalue varchar(10))
select * from insertvalue
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160525.2 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2016
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