.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

how to get and set radiobutton value without using text property?

Posted By:      Posted Date: September 06, 2010    Points: 0   Category :ASP.Net
I need 10 radiobuttons, but I do not want to use radiobutton list and I am not able to use Text property since I mark the Text for radiobutton in another row. All the radiobuttons' text are set as empty string. How can I get and set the value for the radiobuttons. Thanks.  <div>             <div> &nbsp;</div>            <div>                <span>1</span>&nbsp;&nbsp;                <span>2</span>&nbsp;&nbsp;                <span>3</span>&nbsp;&nbsp;            </div>            <div>                <span>4</span>&nbsp;&nbsp;                <span>5</span>&nbsp;&nbsp;            &n

View Complete Post

More Related Resource Links

How Do I Not Include: myControl.GetType.GetProperty("Text") When No Property Window Setting?

Hi All, Posted below is code I'm using to generate a list of controls that have either a "Text" or "Caption" property. However, for certain controls in the resulting list, the property setting (Text/Caption) does not appear in the "Property Window" of the IDE when that control is selected. One example of this is the Systems.Windows.Forms.PictureBox control. Is there a way I can determine this and if so - how do I exclude these control(s) from my list?     Private Sub cmdValidateControls_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdValidateControls.Click         txtResults.Clear()         For Each ctrl As Object In Me.Controls             LogControl(ctrl)         Next     End Sub     Private Sub LogControl(ByVal ctrlIn As Object)         If System.Diagnostics.Debugger.IsAttached Then             If (Not ctrlIn.GetType.GetProperty("Text") Is Nothing) Or (Not ctrlIn.GetType.GetProperty("Caption") Is Nothing) Then                 txtRes

Textbox Text Property

I am new to VB and I have read that if I don't explicity cast variable types it will eat up performance. I have been casting certain objects, such as values from data readers, but I was wondering if the object has a property that says it is a string, like the textbox "Text" property, if I need to still cast that as a string.   Right now my code says "txtSearch.Text" but should I be using "txtSearch.Text.ToString()"?   Thanks in advance for the help!

Generic Casting to access Text property


I have a situation where I'm iterating through all the controls on a form, specifically looking out for any of these three types of controls:  Labels, TextBoxes, CheckBoxes

I can, of course, get the type of the control and then use a Switch-Case construct to cast labels as Labels, textboxes as TextBoxes, and checkboxes as CheckBoxes.

But I'm wondering if there's a way to do something with one or two lines of code to gain access to the Text property of each of these controls?

I'm guessing this isn't possible but thought I'd ask to be sure,


Modal Popup - Unable to set label text property



I have ajax accordion with 6 panes with an user control inside each of it.
 In the first pane I have a form view user control and have a modalpopup to
display error message. The same method is used in all other panes.

On page load I was able to set the label text property and it properly shows in modal popup.

However whenever I do some validation and update label text property, the modal popup
shows up but the label text property is not updated. It works in all other panes.

The only difference is the user control in the pane is inside of a update panel. If I remove the

update panel every thing works fine. But I need the update panel to avoid full post back.

How do I set the label text property inside of a modal popup.

Sections of code below:




protected void Page_Load(object sender, EventArgs e)
        lblNewMessage.Text = "Error";

 protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
	 if (!doValidate() ) { return; }
    public bool doValidate()
        if (!psClassUtil.check_isnull_or_empty(firstName, 30, "N"))
            lblNewMessage.Text = "First Name is required (Maximum 30 characters)."; // does not 

Override ComboBox Text property after selected an item


Hi All

I tried many ways , but have non can successfully alter the combo box Text after selected an item from drop down, and I want to make sure this is just not possible.

This is what I need, if after I selected an item - "1 apple" from the drop down, i want the combo box shows text, "1". I tried write code in different eventhandlers, overrider Text property, clear items . non of those way can achieve this.

 public class AccountComboBox : ComboBox
    public override string Text
        return base.Text;
        if (this.SelectedItem != null)

          base.Text = SelectedItem.ToString().Remove(this.SelectedItem.ToString().IndexOf(" "));

Need Custom Text Box Control with DataSource,TableName,ColumnName Property


I need to create one custom text box control which should be bind with data base.

I am referring following link...


I used DataBoundControl to create my control but i am not able to do it properly.

    public class SimpleTextBoxControl : DataBoundControl
        private TextBox nameTextBox;

        public string DataTextField
                object o = ViewState["DataTextField"];
                return ((o == null) ? string.Empty : (string)o);

Binding RadioButton to an Enum property



Hi guys,

I have noticed a weird behavior on databinding some radiobuttons to an enum property.

- an enum dependency property on a Window (eg: property Test of type Visibility);
- three radiobuttons to display and select the value of the property, one for every enum value (eg: Visible, Hidden and Collapsed)
- a converter that converts and converts back the value of the property to the radiobutton's IsChecked property

The weird behavior is that when I click on a radiobutton the value of the property changes, but if I assign via code a new value directly to the property, the radiobuttons get disconnected from the property, resulting in not changing anymore the value of Test property when a radiobutton is clicked.

I created a test project in which you can select, using the radio buttons, the value of the Test property, and if you click the 'Test' button, the value is assigned to the Test property by code.
In the second part of the window there is the same thing with the SelectedIndex property of a ListBox, bound to a TestIndex property, this time without a converter.

If you launch the project, and first of all click on the Test button, the value of the property changes, but now, if you change the selection on the radiobuttons, the property never changes again if you click 'Visible' or 'Hidden'

overriding Text property of an inherited label



I'm writing a new control that inherits a Label.  this control is intended to maintain a fixed string value of "Text" but display whatever contracted portion of the original text will fit inside the bounds limited by this control's width.  e.g. if "Engineers are the modern wizards" doesn't fit within the width allowed the text displayed is contracted to "Enginrs ar th modrn wzrds".

public class LabelTextAdjustToSize : Label
string[] strWords;
string strSplit = " .,:;-+=-_!?";
string strVowels = "aeiouyAEIOUY";
string[] strDiphthongs = { "ae", "oi", "ou", "ie." };
public string _strText;

public override string Text

Web Part Custom Property Text Values Showing Up on Page


I've created a basic Web Part in a .wsp and defined two custom web properties.

However, whatever value I place in these text values when in the edit mode show up on the Page beneath the Web Part name.  Why?  How do I not show the value of Properties outside of the Modify Property window?

HTML and using Resource file in TEXT property



Is it possible to add HTML tags/markup and using Resource file explicitly in the TEXT property of a server control?

Right now I have the following and I'm able to style it with css:


<asp:ValidationSummary ID="vsUser" runat="server" DisplayMode="BulletList" EnableClientScript="False" ShowMessageBox="False" CssClass="validationsummary" HeaderText="<div class="vsheader"><label>Error Occurred</lable></div>" />

I would like to be able to do something like:

<asp:ValidationSummary ID="vsUser" runat="server" DisplayMode="BulletList" EnableClientScript="False" ShowMessageBox="False" CssClass="validationsummary" HeaderText="<div class="vsheader><label><%$ Resources:Resource, ValidationSummaryHeaderUser %></label></div>" />

Thanks in advance

How to change default category for the Text Box Property NUMBER across multiple textboxes


I'm using SSRS R8 and have several reports with numerous NUMERIC textboxes.  The default NUMBER category that SSRS applies is "Default", which applies no formating to the number values shown in the textbox.  When the report executes, it displays these values with 4 decimal places (e.g. 123.1234).  The customer requires 2 decimal places (e.g. 123.12). 

This can be easily fixed by changing the category for the NUMBER Text Box Property from "Default" to "Number", with "Decimal Places" set to 2.

The trouble with doing it this way is that each report has over a hundred such textboxes (there are 15 such reports), and to change each textbox individually would be timeconsuming and error prone.  The intuitive way to do this would be to select multiple textboxes that I want to set the NUMBER category for, right click, select Text Box Properties, and set the NUMBER category accordingly.  However when I right click the multi-selected text boxes, I see the Text Box Properties option greyed out.

Is there a different way to do this?

RadioButton inside GridView, How to get it work as normal

Did you tried before to drag a RadioButton control inside a Gridivew templatefield, and then you attempt to select these RadioButtons , you will notice that the behavior of RadioButton control will be changed and it will work just like the behavior of checkbox control! the user will be able to select more than one radiobutton in the grid!

RadioButton Groups, Table Rows And NamingContainers in asp.net

The RadioButtonList. Very handy for inviting users to select just one item from a list although because of the screen real estate it takes up, used less and less in favour of the DropDownList. In plain HTML, the browser knows to enforce the unique selected value amongst a list of radio buttons because they all have the same value for their name attributes.

RadioButton Groups, Table Rows And NamingContainers

(In which AJAX-enhanced CheckBoxes become more useful than RadioButtons but inheritance saves the day, and a simple RadioButton-derived control establishes the purpose of a control's naming container)

The RadioButtonList. Very handy for inviting users to select just one item from a list although because of the screen real estate it takes up, used less and less in favour of the DropDownList. In plain HTML, the browser knows to enforce the unique selected value amongst a list of radio buttons because they all have the same value for their name attributes.

AutoCompleteStringCollection for text box in DataGridView 2.0

I have been searching for a way to have autocomplete in a DataGridTextBox
object. There does not appear to be an obvious way to do this like you would
for a TextBox outside of a grid using the AutoCompleteCustomSource. Any
thoughts on how I can add this collection? :)

Built-in Functions - Text and Image Functions in SQL Server

Text and image functions operate on TEXT, NTEXT and IMAGE data types. These data types are deprecated with SQL Server 2005 and should be replaced by VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) when possible. Alternatively you can also consider storing large string values using XML data type. Text and image functions are nondeterministic.

Future versions of SQL Server will not support TEXT, NTEXT and IMAGE data types. Columns with TEXT / NTEXT data type do not support commonly used string functions such as LEN, LEFT, RIGHT, etc. Furthermore, due to the large size of TEXT data you''re likely to see performance issues if you store such data in the database. However, at times you can''t help but use the TEXT / NTEXT / IMAGE data types (for example when supporting 3rd party databases when you cannot change the schema) - this is when text and image functions come in handy.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend