It works fine but measure problem is for every post back that popup div displying automatically.
I believe this is your issue that you are talking of.
Now, two things.
1. You should use
display style
attribute instead of visibility attribute. Display will hide/show keeping the control on the page. Setting, visible property does not render the control at all which makes it impossible to access on client side.
2. Your div display is reset on postback as the state is not maintained automatically here. You changed the display of it client side which server is not aware of. To persist the set property on postback, you need to track the change made and set it again on server side. One of the ways to do it:
a. Keep a
hidden field
on your page. (make it server control if using input of hidden type) (Default it to true - which means show div)
b. Use this hidden field as a flag - true/false: true for display, false for hide
c. When you are hiding the div from client side (code
f1()
above), set the hidden field too. Set 'false' when hiding the div.
d. During postback, in your page_load, check the value of hidden field. Based on the value of hidden field, set the display attribute of div.
Something like:
if(hdnField.Value == "false")
Popupdiv.Attributes.Add("style", "display:none");
Try!
[SNS] Code updated.