By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

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

P: n/a
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...

Jul 28 '06 #1
Share this Question
Share on Google+
11 Replies


P: n/a
hey pls reply if u hv any idea...its kindaa urgent...
saurabh wrote:
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...
Jul 28 '06 #2

P: n/a
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" wrote:
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...

Jul 29 '06 #3

P: n/a

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 wrote:
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" wrote:
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...
Jul 29 '06 #4

P: n/a
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" wrote:
>
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 wrote:
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" wrote:
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...
>
>

Jul 29 '06 #5

P: n/a
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 wrote:
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" wrote:

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 wrote:
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" wrote:
>
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...
Jul 29 '06 #6

P: n/a
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.

"saurabh" wrote:
>
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 wrote:
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" wrote:
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...
>
>

Jul 29 '06 #7

P: n/a
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" wrote:
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 wrote:
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" wrote:
>
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 wrote:
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" wrote:

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...
>
>
>
>

Jul 29 '06 #8

P: n/a
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 wrote:
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.

"saurabh" wrote:

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 wrote:
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" wrote:
>
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...
Jul 29 '06 #9

P: n/a
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" wrote:
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 wrote:
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.

"saurabh" wrote:
>
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 wrote:
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" wrote:

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...
>
>
>
>

Jul 29 '06 #10

P: n/a
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 wrote:
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" wrote:
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 wrote:
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.
>
"saurabh" wrote:
>

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 wrote:
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" wrote:
>
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...


Jul 29 '06 #11

P: n/a
email me at sw@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.

"saurabh" wrote:
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 wrote:
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" wrote:
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 wrote:
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.

"saurabh" wrote:

>
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 wrote:
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" wrote:

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...
>
>
>
>
>
>

Jul 29 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.