hi
i have checkboxes , textboxes and drop down list boxes in an aspx web page, how do i get the data that is being entered by the user. and where should i write the code or it
thanks
appreciate a reply
thanks
hi
i have checkboxes , textboxes and drop down list boxes in an aspx web page, how do i get the data that is being entered by the user. and where should i write the code or it
thanks
appreciate a reply
thanks
If you are using a code-behind page (example.aspx.cs), you can access those objects and their data.
For example...
textBox1.text, or dropDown1.selectedValue
In C#, this will loop throuh all controls and get their values ... you need to do something with it them though.
private void GetControlValues(Control parent)
{
foreach (Control c in parent.Controls)
{
if (c is DropDownList)
{
string ddlValue = ((DropDownList)(c)).SelectedValue;
}
if (c is TextBox)
{
string txtbox = ((TextBox)(c)).Text;
}
if (c is CheckBox)
{
bool value = ((CheckBox)(c)).Checked;
}
GetControlValues(c);
}
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.