How to maintain the display state of a <div> element?

M

msch-prv

How to maintain the display state of a <div> element?

Is there a simple way to maintain the display state of a <div>
element? On my page, a
div block can be hidden/shown by js function showhide(). I would like
to maintain the block's display state when the page is posted back.
I'm having difficulties to retrieve the div style attributes from the
viewstate: Me.divProdCat.Style.Item("display") always returns the same
attribute.

Is there a more straightforward approach? Thanks for any hints.

Categories</a>

<div id="divProdCat" style="margin-top:5px;display:none;"
runat="server" >
....
</div>
 
P

PJ on Development

Hi,

The problem with the DIV is that it has no properties sent back to the
server. If you take a look at the Request.Form.AllKeys you'll notice
that there is no item represent the div.

Although ASP.NET has many server controls that help us to build a vast
number of web applications, the browser is still dumb, i.e. it will
only send to the server the items that are INPUT and/or SELECT items.

So to maintain the state of the DIV you need to include a hidden field
in your div that will house the state of the element. And parse it
accordingly on the post back.

An web user control might be a good place to start (but t.b.h. I never
tried to create a container web user control)

Take a look at the documentation and feel free to ask away.

Regards,

Paulo Santos
http://pjondevelopment.50webs.com
 

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,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top