Hi Ken,
Would you mind explaining.
ASP.Net is built to run in a stateless HTTP environment. The client is
unaware of the server, and the server is unaware of the client. That is the
nature of HTTP, which is really a messaging protocol. The client sends a
Request to a web server for a specific resource (URL). The client Request is
a text message with headers that include a bit of information about the
client (IP address, browser type, etc) and the message itself. The server
receives the Request and processes it, returning the Response, which is
typically an HTML document, or some binary file. The server is unaware of
the client, and only has the single Request message to work with in
preparing the Response.
The ASP.Net object model is designed to emulate state by a rather
sophisticated collection of work-arounds, such as the server posting
JavaScript and hidden form fields containing state information to the
client, so that the client-side, server-generated JavaScript, together with
the form's POST contents (including the hidden form fields, such as
ViewState and Event-related fields) can REMIND the server of what part of
what conversation the client may be continuing (in a PostBack).
So, using JavaScript on the client that is not generated by the server can
have unexpected results, as it may bypass or override the ASP.Net
object-model's mechanisms for passing information back and forth between the
client and server.
That said, I believe you can do what you want to do, but keep this in mind
if, in the future, you see something unexpected as a result of client-side
JavaScript form manipulation. For example, changing the value of form fields
programmatically, may or may not be recognized by the server-side Page
class, although you can usually circumvent this by using the Request.Form
Collection separtely from the built-in event-handling mechanisms.
In this case, you're not modifying anything in any form fields, but just
showing and hiding them. Keep in mind, however, that if the user changes
their mind after filling in a form field, and then hides it, this doesn't
remove the value from the POST. Just some cautionary advice. Measure twice,
cut once!
The following link is to a tutorial on this subject that may be helpful to
you:
http://www.devx.com/webdev/Article/10483/1954?pf=true
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.