Click here to Skip to main content
Rate this: bad
good
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 at 9-Nov-12 2:55am
   
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  
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  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 460
1 Sergey Alexandrovich Kryukov 336
2 Shai Vashdi 294
3 OriginalGriff 280
4 Abhinav S 160
0 Sergey Alexandrovich Kryukov 9,185
1 OriginalGriff 5,315
2 Peter Leow 4,040
3 Maciej Los 3,535
4 Abhinav S 3,308


Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid