where is __EVENTTARGET ?

M

Matthew.DelVecchio

hello,

i am attempting to get my asp.net form to "remember" scroll position on
post, as written in this short simple article:

http://www.dotnetjunkies.com/Article/E474B0FC-20D2-48B3-93B5-DC4CB3C4A1AB.dcik

....however, my page busts on the server request to
Request.Form["__EVENTTARGET"], saying it's not there. indeed, when i
view the html source of my asp.net form, there is no hidden input field
by that name. but according to the article, there should be these two:

<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />

i checked some of my other forms, didnt see it in those, either.

anyone know what's up?



thanks,
matt
 
L

Lau Lei Cheong

These 2 hidden controls will be added automatically by the ASP.NET parser at
runtime immediately after a <form runat=server> start tag, so you need not
bother with it. Just remember to have a server-side form included.
 
K

Ken Cox [Microsoft MVP]

You can only count on it being generated if at least one control that needs
it is on the page. For example, it will appear if a textbox has
AutoPostBack="True"

<asp:textbox id="TextBox1" runat="server"
AutoPostBack="True"></asp:textbox>

Ken
Microsoft MVP [ASP.NET]
 
M

Matthew.DelVecchio

im not sure you understand.... as i said, i have a webform. that,
inheritantly means i have the server-side form tags; but i do not see
the hidden fields.
 
M

Matthew.DelVecchio

i see. so it only shows up forms w/ AutoPostBack=true. ok.

hmm. well, for my need, i just want to have it there so that i can do
the hfref.location trick, as in the article. i only have text boxes in
my webform...nothing that has a need for AutoPostBack. is there another
to get those tags to show up? can i set autopostback to a non-visible
form element?


thanks,
matt
 
L

Lau Lei Cheong

A webform do not necessarily implies that it has a server-side form tag, so
it isn't inheritantly said.

It's legal to have <asp:Literal runat=server> at a webform outside a
server-side form tag, and I have a webform that uses <asp:panel
runat=server> to hide the server-side form tag on purpose.

And there's some people still want to access postback value of controls by
Request.Form[], not using the object modal. So I just wanted to make sure...
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top