views:

127

answers:

2

Hey there.

I have an aspx page with one form submitting to itself. In the form there are 2 divs with various input fields, text, etc. Div1 is hidden via css by default. There is a submit button which postbacks to same page. How do I get the button to alter the css display value to "block" so div1 is now visible?

I can get it to the point where onclick it momentarily displays but because it needs to reload the page it defaults to hidden. Is there a way I can alter the inline css of the target page after submit?

info and controlstext field, etc.

So upon submit, this page should render with div1 visible by changing the inline css.

What's the best approach?

Thanks.

A: 

Use the same ASP code that processes whatever form you're submitting to also alter the CSS of the page.

Amber
Thanks, but for example I think I've tried that by using this for example: OnClientClick="div1.style.display='block'"However, I don't know how to make that change stick after page reload.
Sy Naka
Again, you have to change the actual code of the page provided by the server - client-side scripting requests *don't* persist across page reloads by their very nature. The other option would be to submit the form via AJAX so that the page as a whole isn't actually reloaded.
Amber
Ahh, I am starting see. So, I have access to the .aspx source but not the code behind if it's still possible to do it through server code do you know of any examples? Or references on how to prepare a rather complicated web form for AJAX processing?
Sy Naka
If you have access to the .aspx you should be able to do everything you need there, unless the form processing is being done by an intermediate script that redirects back to the page (and thus wouldn't include the fact that the form was submitted)?
Amber
No the scripts are within the page so access is not an issue. I need a kickstart and am clearly out of my range here. Could you assist me by elaborating somewhat on the steps I need to take?
Sy Naka
So in general, what you want to be looking for are the POST (GET?) variables submitted by the form, and in addition to processing those normally, you'd also set a flag that tells the part of the page outputting HTML back to the browser to write out `display:block` instead of `display:none` in the proper place. (Or write an inline style that overrides the property for the element.)
Amber
Much appreciated, now I know what to do so I'll just try to work out the how. Thanks.
Sy Naka
A: 

Hello

I was wondering if you've found a way of doing it.

Please let me know.

G.

Gaets