How to pass an ID in hidden variable.

  • Thread starter Thread starter Frank Rizzo
  • Start date Start date
F

Frank Rizzo

Ok, this is probably so simple...
Anyway, I'd like to pass a value in the hidden variable. I have code
like this:

<form...>
<input type="Hidden" name="zzz" value="1">
...
</form>

I want to replace the value with another when the page gets generated in
the code behind file. How do I do such a thing?

Regards
 
I'd try to avoid that if at all possible, spoofing hidden fields is a known
hack and I was at DevDays ASP.NET Security discussion and they were
recommended against using Hidden fields for input. I think Session State
should get you what you need and session variables are really easy to use.
Are you familiar with them? If not, I'd really suggest checking them out.

Cheers,

Bill
 
Use an HtmlInputHidden Control.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
He didn't mention whether this information is sensitive or not, only that it
is in a hidden form field. There are plenty of good reasons for putting data
that you don't want displayed into a hidden form field. ViewState, for
example, comes to mind...

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
"That's FRANK RIZZO, I said!!!!"

Sorry I couldn't resist the Jerky Boy reference.
No offense intended for the original poster Frank (the former Philly,PA
Mayor?)
It's Friday, you know..

Carry on!
 
Peter said:
"That's FRANK RIZZO, I said!!!!"

Sorry I couldn't resist the Jerky Boy reference.
No offense intended for the original poster Frank (the former Philly,PA
Mayor?)
It's Friday, you know..

All, you silly little freak. You gonna answer the question or not?
 
In your example...
<input type="Hidden" name="zzz" value="1">
add an id attribute, i.e. id="zzz" and the runat=server, attrribute/value
pair.

Afterwards, if the VS.NET editor does not already do so, you should add the
following delcaration
to your code behind file:
protected System.Web.UI.HtmlControls.HtmlInputHidden zzz;

You will now have server-code access to the hidden html field.

Peter
 
Back
Top