assigning variable's value to htmlinput

N

Newbie

hi all,

in a webform's codebehind, i have a variable (ie: nTotal). and in UI i have
a hidden htmlinput (ie: fld1).
Q: how to assign the value of nTotal to now i want to assign the value of
nTotal to fld1?

many thanks in advance,
andy
 
K

Karl Seguin

Andy:
You can't. This is a security feature of HTML and has nothing to do with
ASP.Net. html input values are read only. If they weren't, anyone could
put a hidden html input field and set the value like "c:\passwords.txt" and
when the user clicked any button they'd have their passworsd.txt file
uploaded without ever knowing it.

Karl
 
N

Newbie

hi all,

(a little correction to mistyped)

in a webform's codebehind, i have a variable (ie: nTotal). and in UI i have
a hidden htmlinput (ie: fld1).
Q: how to assign the value of nTotal to fld1?

many thanks in advance,
andy
 
B

Bob Barrows [MVP]

Karl said:
Andy:
You can't. This is a security feature of HTML and has nothing to do
with ASP.Net. html input values are read only. If they weren't,
anyone could put a hidden html input field and set the value like
"c:\passwords.txt" and when the user clicked any button they'd have
their passworsd.txt file uploaded without ever knowing it.
?
CMIIW, but that's only true if the input's type is file, and the form's
ENCTYPE attribute is "multipart/form-data".

You need to response.write the variable's value into the html:

<input type="hidden" value="<%=nTotal%>">

Bob Barrows
 
N

Newbie

Yes, it's work, Bob.

Thks a lot.

rgds,
andy

Bob Barrows said:
?
CMIIW, but that's only true if the input's type is file, and the form's
ENCTYPE attribute is "multipart/form-data".

You need to response.write the variable's value into the html:

<input type="hidden" value="<%=nTotal%>">

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
K

Karl Seguin

doh...for some reason I read that it was an HtmlFileInput control :)

anyways, why use the old ASP method of Response.WRite? Declare it as a
webcontrol and set the value programatically.

Karl
 
B

Bob Barrows [MVP]

Karl said:
doh...for some reason I read that it was an HtmlFileInput control :)

anyways, why use the old ASP method of Response.WRite? Declare it as
a webcontrol and set the value programatically.

I'm still in the learning phase myself. My mind is still firmly entrenched
in the classic ASP way of doing things.

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top