473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

access html controls from C# in code behind

ASP.Net and C#

I am having trouble determining how to manipulate html controls via javascript AND access those same controls in the C# code behind. Here's the scoop:

I am making an advanced search page, consisting of a table where each row has (in this order):
- checkbox – to indicate whether to return the column
- label
- textbox – to enter search criteria

On some rows, though, I replaced the textbox with radio buttons so users can search on True and False. At first I used ASP radio button controls, but I changed them to html controls so I could control them with javascript – so when the user UNchecks a checkbox, I want the corresponding radio buttons to both be unselected. So I made the checkbox and radios be html controls. Works great.

The problem: I'd like to build the SQL statement in C# in the code behind, but I don't know how to get the state of the html checkboxes and radio buttons to the code behind page.

I know I can do something similar to what I want if the html control is a textbox. I know I can access the value by:
Request["control's ID"].ToString()
but I can't get the checkboxes and radios.

Any suggestions?
Apr 17 '08 #1
1 3444
Mr Gray
47
You can use the server controls e.g.:

Expand|Select|Wrap|Line Numbers
  1. <asp:radiobuttonlist id="rbl1" runat="server"> 
  2.  
as you fisrt intended and you can access it in the client side by using this in the cs file:

Expand|Select|Wrap|Line Numbers
  1. rbl1.ClientID;
  2.  
or if it is a dynamically created list you can use:

Expand|Select|Wrap|Line Numbers
  1. rbl1.UniqueID;
  2.  
This way in the server side code you can access the values as you would normally:

Expand|Select|Wrap|Line Numbers
  1. rbl1.SelectedIndex;
  2.  
I know the code is not entirely correct but it will help you search for more ideas.
Apr 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: SStory | last post by:
Doing pages for contract..... If I make an ASPX file that does certain things, how simple would it be for a person who know nothing about it to modify the user interface without bothering the...
0
by: bill yeager | last post by:
I have a datalist displaying parent information and a datagrid presenting child information. The data is being rendered just fine. The datagrid has template columns on it that I cannot gain access...
5
by: siaj | last post by:
Hello All, Can any one give me a clue when to use Web Server controls/ HTML server controls/HTML Controls. As I understand .. HTML controls should be used if u dont need to refer it in the code...
2
by: fxs | last post by:
Hello, I have the following controls on an aspx page: 2 html radio button controls, 1 asp:label control and 1 asp:button control.... <INPUT id="rdo1" type="radio" name="grp1"...
2
by: N. Demos | last post by:
I have a user control with code behind of which two instances are created/declared in my aspx page. The aspx page has code behind also, as I need to access methods of the usercontrols on page...
5
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact...
3
by: Mr Newbie | last post by:
I am messing around with Web User Controls at present and (think) I have discovered the following. 1.) The identifier for the control in the code behind must match the ID for the control on the...
5
by: Easystart | last post by:
Hi, Sorry for my English. English is not my native tougue. I am working in MS Access 2000 with a SQLServer 2000 Backend database. MS Access 2000 is my GUI front end that has SQLServer linked...
4
by: viveklinux | last post by:
Hi , I have a table which needs to be populated at runtime. Is there a way to do this without using a server side control like repeater or datagrid ? How can an HTML control be accessed in code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.