Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

changing value of html control from c# code in asp.net website

2 views
Skip to first unread message

saurabh

unread,
Jul 28, 2006, 11:50:52 AM7/28/06
to
Can anybody tell me how to change the value of an html control from the
c#....
eg i hv one asp.net radio button control and one html hidden
variable...
so on page load in case the radio button is checked i want to set this
hidden variable to 1 else 0...

I am not getting what to write in Page_Load(object sender,
System.EventArgs e) function to change the value of this html
variable...

saurabh

unread,
Jul 28, 2006, 6:42:48 PM7/28/06
to
hey pls reply if u hv any idea...its kindaa urgent...

Sean

unread,
Jul 29, 2006, 1:01:02 AM7/29/06
to
I think it might be easier just to use a server control becuase otherwise for
the most part the server doesnt even know it exists.
Depending on your needs that might be the best solution.

even if you went the route of having the server re-create the html control
on each load/postback it would take as much server "power" as it would to
just use a server control

saurabh

unread,
Jul 29, 2006, 10:09:58 AM7/29/06
to

as per requirments this might not be possible in my case....Does any
body has idea at any one of the following:
1) To check if a server control radiobutton checked or not , using the
javascript, each time page is loaded....If u know tell me wht all steps
need to be taken.
2) or to change the value of a hidden html variable from inside the c#
code that we write in asp.net website....
-----------------

Sean

unread,
Jul 29, 2006, 10:56:02 AM7/29/06
to
1. getting access to values of serverside controls using javascript is a
subject that was lightly touched on in one of my books called "ASP.Net 2.0
Advanced Application Design" and its labeled as "expert" content. Its also a
very messy and long process from the best I can tell.
If you set a server control autopostback = true then the second the user
checks that checkbox your server side will know its been checked. That said
autopostback makes a round trip to the server which is usually not an issue
but sometimes its perfered the user doesnt see a refresh of the page unless
they have to.
2. I have no idea what you are talking about here. HTML variable?

saurabh

unread,
Jul 29, 2006, 11:01:43 AM7/29/06
to
by html variable i mean a hidden html variable or say a textbox....is
thr any way to change the text of a text box from the c# code?? point
it tht textbox is not a server control , so textbox.text="blahblah"
wont work...

Sean

unread,
Jul 29, 2006, 11:01:02 AM7/29/06
to
just so i get an idea of your background do you know what viewstate is?

This will help me no repeat information that you already know.

Sean

unread,
Jul 29, 2006, 11:19:02 AM7/29/06
to
I have used webserver controls and hidden them on the page for similar
reasons however for a client side control all values are lost on each post to
the server unless you keep the value in a cookie, viewstate, sessionstate etc.

That is why I asked if you know what viewstate is. If you dont, then there
is a bit of a learning curve on how to keep values in the web applications

saurabh

unread,
Jul 29, 2006, 1:36:59 PM7/29/06
to
yeah exactly this is the prblm i am facing....after each trip to server
my html hidden control looses its value....if i am able to store this
value i think my problem will be solved...
no boss i dnt know abt this viewstate and all....i am kindaa new is
asp.net :(

Sean

unread,
Jul 29, 2006, 1:55:01 PM7/29/06
to
fair enough on viewstate that gives me a good idea in the area we are talking
about.

My question at this point would be why do you require a clientside HTML
checkbox instead of a serverside checkbox?

<asp:CheckBox ID="CheckBox1" runat="server" />

above will maitain state of value automatically :)

saurabh

unread,
Jul 29, 2006, 2:44:13 PM7/29/06
to
hey its kindaa difficult to explain u my prob this way...can u gimme ur
messenger contact(if u dnt mind)....will tell u thr...
hey i am working on this html variable in a javascript....if i put
checkbox instead of tht it wont be possible to manipulate tht asp
checkbox frm javascript written in html control

Sean

unread,
Jul 29, 2006, 3:07:04 PM7/29/06
to
email me at s...@technologycertified.com

for grins see the app I am currently working on
http://technologycertified.com

I have some issues with the test grid and I dont know how far it goes so
results right now are somewhat unpredictable.

0 new messages