|
-
Nov 19th, 2007, 10:21 AM
#1
Thread Starter
Junior Member
Keeping a Div Visable after postback
I'm having issues with figuring out a way to keep a div visible after a post back.
I have a button on the form, when clicking the button a div that was style="visibility:hidden;" is set to style="visibility:visible" via java script.
Inside of this div is a asp.net Calender control, when I switch months the control posts back and the div is hidden again. How do I keep the div visible until a date is selected on the calender?
Thanks,
Bradley
-
Nov 19th, 2007, 01:30 PM
#2
Re: Keeping a Div Visable after postback
If your div is built as a server control (i.e. <div id="myDiv" runat="server") then you can do a check on the page's Load event for a post back:
Code:
If IsPostBack Then
'whatever checks to see if it should still be visible
End If
-
Nov 19th, 2007, 02:43 PM
#3
Thread Starter
Junior Member
Re: Keeping a Div Visable after postback
Okay I have tried to Check if the visibility is set or not on the pageload
Code:
if Page.IsPostBack then
'DCalStart is the Div id
If DCalStart.Style.Value.Contains("visible") Then
DCalStart.Style.Value = "display: inline; visibility: visible;"
Else
DCalStart.Style.Value = "display: none; visibility: hidden;"
End If
End If
But no matter when I check it, it always comes back as being hidden. Am I checking the wrong place?
-
Nov 19th, 2007, 02:55 PM
#4
Re: Keeping a Div Visable after postback
I'd suggest monitoring progress with session variables or something similar. If the page is set to load with visibility:hidden, then that's what'll always return. Page values aren't a good thing to monitor progress with.
-
Nov 19th, 2007, 03:02 PM
#5
Thread Starter
Junior Member
Re: Keeping a Div Visable after postback
Well that's a funny thing, right now they are set to load with visibility set to visible, and they still show up as hidden after any post back. I'll give the Session variable a try and see if I get better results with that approach.
-Bradley
-
Nov 19th, 2007, 03:24 PM
#6
Thread Starter
Junior Member
Re: Keeping a Div Visable after postback
Can you show me a brief example of this or point me to a good reference of how to accomplish this? I thought I understood Session variables but I guess I don't. How do I a session variable to remember if a Div is visible or not? I understand how to access the value, but how do I set it on the client before the post back?
-
Nov 19th, 2007, 03:29 PM
#7
Re: Keeping a Div Visable after postback
If it's a step-by-step operation that the user is being led through, just track how far they've come with an int or something like that.
-
Nov 19th, 2007, 03:58 PM
#8
Re: Keeping a Div Visable after postback
Why use Session variables? If the Calendar control causes the Postback a Calendar event will fire. Since the user was able to click the calendar, the Div is visible. Set the style in the Calendar event...
-
Nov 19th, 2007, 04:42 PM
#9
Thread Starter
Junior Member
Re: Keeping a Div Visable after postback
Thanks brucevde that solution worked like I was hoping it would. I don't know why I didn't think of that. Guess I was trying to make it harder than it needed to be.
-Bradley
-
Nov 19th, 2007, 04:52 PM
#10
Hyperactive Member
Re: Keeping a Div Visable after postback
You already have an answer but I'll post it anyway
You might want to build a simple pop up calendar control.
Pop & size it & position it. Then use window.opener.forms(0).... to set the date where you want it.
There are several examples listed on various sites, unfortunately most constipatingly (should be a word ) complex (or in C#)
I'll post some code if that's what your trying to do.
Last edited by Rocketdawg; Nov 19th, 2007 at 04:54 PM.
Reason: Already solved
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|