how to get non server control values?

  • Thread starter Thread starter Francois
  • Start date Start date
F

Francois

Hi,

I have a form which contains some non server side controls.

I have seen in the generated HTML of a page that non server side controls
can be read by the server code (C# or VB.NET) as the the ASP.NET framework
itself generated non server side hidden fields used for the postaback.

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

I would like to myself use it but I did not find a way to access it. I tried
with the propoerty : request.Form but it seems empty as
Request.Form.HasKeys() returns false.

anyone can help me about how to read the different input fields (the body)
of the form in an old fashioned way (without using the server side
controls).

Thanks

Francois
 
Francois,

You have to add attribute runat="server".

Just to clarify terminology. Server can access only server-side controls.
That is not to be mixed with asp.net controls. Any control, even classic
html one, with attribute runat set to "server" is a server-side one.

Eliyahu
 
Actually there is no need to add the runat="Server". And my question was not
about how to access server side control but to access non server side
control. Sorry if i was not clear about that.

If you have some form fields or hidden fields that are not server control,
you can still access them through the Request.QueryString the Request.Form
collections.You will use the first collections in the case you submit the
form through a GET and the later if you submit the form through a POST.

As simple as that ! What i said in my first post was just stupid, it did not
work for me as i posted my form with a GET instead of a POST. It was just a
little thing i overlooked.

Of course this way to do is very particular to my specific problem. 99.9 %
of my code is using server control and then i don't need to do like that, i
just use the members of my code behind class to access the data of the form.
I just wanted to share this with people in case someone as the same problem
as me and need to access form fields that are NOT server controls and that
do not have "runat=server".

Cheers,

Francois
 

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

Back
Top