ASP.NET RadioButton Derived Control with Value

Sometimes you put up with things unconsciously until one day you think, hang on, why don't I just to "x." So what I am referring to is simply that the ASP.NET RadioButton control does not have a property for Value.  I have no doubt that this is purposeful, but either way, I required a RadioButtonControl with a value Property. 

Hide Code [-]
using System.Web.UI.WebControls;

/// <summary>
/// Summary description for ValueRadioButton
/// </summary>
public class ValueRadioButton : RadioButton
{
    private string m_value;

    public string Value
    {
        get { return m_value; }
        set { m_value = value; }
    }

    public ValueRadioButton()
    {
        //
        // TODO: Add constructor logic here
        //
    }
}
{..} Click Show Code

 

Cheers,

 

Andrew :-)

Published Monday, May 05, 2008 12:07 AM by REA_ANDREW

Comments

# re: ASP.NET RadioButton Derived Control with Value

Sunday, May 04, 2008 9:57 PM by pbz

If you need that value after postback then you need to store the "value" in the ViewState...

# re: ASP.NET RadioButton Derived Control with Value

Sunday, May 04, 2008 10:22 PM by REA_ANDREW

I create a variable, private with public accessor, as type ValueRadioButton.  Then in the RadioButton CheckChanged event, I assigned the sender object as the value of this variable.  I can then get the selected object and value.

Andrew :-)

# re: ASP.NET RadioButton Derived Control with Value

Thursday, July 24, 2008 3:39 PM by Jonathan Fleury

Exactly what I needed  !!! Thanks a lot

Leave a Comment

(required) 
(required) 
(optional)
(required)