How to get value of html control?

D

dgk

Simple question. How do I get the value of an html textbox? This is
the guy:

<INPUT style="Z-INDEX: 113; LEFT: 657px; WIDTH: 78px; POSITION:
absolute; TOP: 62px; HEIGHT: 21px type="password" size="7"
name="pwtext">

It doesn't seem to become a session variable.
 
G

Guest

It wouldn't be in a session variable unless you wrote code that stored it in a session variable (which would have to have been before the control was rendered to the client.

The easiest thing would probably be to make it a Web Control, something like this

<asp:TextBox id="pwtext" style="Z-INDEX: 103; LEFT: 141px; POSITION: absolute; TOP: 27px" runat="server" TextMode="Password"></asp:TextBox

When your form is submitted back to the server, the value will be accessible in code-behind like this: TextBox1.Tex

If, for some reason, you don't want to use a Web Control, the text box value will be avaiable to your server-side application if it was included in a submitted form. Assuing METHOD=POST, you would be able to access it with the following expression: Request.Form.Item("pwtext")
 
M

Matt Berther

Hello dgk,

Assign it an ID and then do Request.Forms["pwtext"] in your codebehind.
 
D

dgk

It wouldn't be in a session variable unless you wrote code that stored it in a session variable (which would have to have been before the control was rendered to the client.)

The easiest thing would probably be to make it a Web Control, something like this:

<asp:TextBox id="pwtext" style="Z-INDEX: 103; LEFT: 141px; POSITION: absolute; TOP: 27px" runat="server" TextMode="Password"></asp:TextBox>

When your form is submitted back to the server, the value will be accessible in code-behind like this: TextBox1.Text

If, for some reason, you don't want to use a Web Control, the text box value will be avaiable to your server-side application if it was included in a submitted form. Assuing METHOD=POST, you would be able to access it with the following expression: Request.Form.Item("pwtext"))
Thanks, Request.Form.Item("pwtext")) does it.

I didn't even notice that the asp textbox had a password textmode or I
likely would have used it. But, I thought the general idea was to use
HTML controls wherever the extra overhead of server controls wasn't
needed. In this case I don't want it to maintain state and I don't
need to refer to it except to get the value. So is there a reason to
make it a server control?
 
L

Lau Lei Cheong

Or supply the tag with runat="server" parameter to make it HtmlControl will
do too.
Best of all, in this way only little coding is added but you'll then be able
to program all avaliable attribute of the password box.

Matt Berther said:
Hello dgk,

Assign it an ID and then do Request.Forms["pwtext"] in your codebehind.
Simple question. How do I get the value of an html textbox? This is
the guy:

<INPUT style="Z-INDEX: 113; LEFT: 657px; WIDTH: 78px; POSITION:
absolute; TOP: 62px; HEIGHT: 21px type="password" size="7"
name="pwtext">

It doesn't seem to become a session variable.
 

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,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top