Retrieving form data by name


A

andrewbb

This will likely be the dumbest question of the day, but:

Me.Request.Form.Item(3) 'works
Me.Request.Form.Item("txtName") 'doesn't work

Intellisense shows the full name of the key is:
ctl00$ContentPlaceHolder1$txtName

Why is the key not: txtName ?

Master:
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder
ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>

Page:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server">
<table style="width: 500px; height: 200px">
<tr>
<td style="width: auto;">
Email address:</td>
<td style="width: 192px;">
<asp:TextBox ID="txtEmail" runat="server"
MaxLength="50" Width="264px"></asp:TextBox></td>
 
Ad

Advertisements

G

Guest

You could read your value as
txtName.Text
or
Me.Request.Form.Item(txtName.ClientID)
 
G

Guest

Howdy Aidy,

Why if viewstate is enabled? It works even if ViewState is disabled, because
it's equivalent to Request.Form[txt.UniqueID]. TextBox uses viewstate only to
raise OnTextChanged event.

Regards
 
Ad

Advertisements

A

Aidy

I have to admit as I was typing I doubted that you needed the viewstate
enabled. As you said, it is needed for comparisons for raising events and
seld-populating but no much else

Milosz Skalecki said:
Howdy Aidy,

Why if viewstate is enabled? It works even if ViewState is disabled,
because
it's equivalent to Request.Form[txt.UniqueID]. TextBox uses viewstate only
to
raise OnTextChanged event.

Regards
--
Milosz


Aidy said:
Or just use

txtName.Text

if viewstate is enabled.

"Sergey Poberezovskiy" <[email protected]>
wrote
in message news:[email protected]
 
Ad

Advertisements


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

Top