0

I create a popup based on this post
but i want to create it based on visitor

I use below code in index.aspx page:

<div id='message' style="display: none;">
    <span>Wellcome 
        <%=UserName%></span> <a href="#" class="close-notify" onclick="closeNotice()">X</a>
</div>

and I show pop-up using jquery :

<script type="text/javascript">

$(document).ready(function() {
    $("#message").fadeIn("slow");

});

function closeNotice() {
    $("#message").fadeOut("slow");
}
</script>

now i want show this pop up only when user enter OR when CheckBox1.Checked value in "editor.aspx" is true...but time pop-up display every time that page load(even if user don't log in )

AminM
  • 1,658
  • 4
  • 32
  • 48
  • Because you are firing the fade in at load (document ready). What you need to do is have document ready call the "pop-up" on event firing. Figure out what actions you want to cause the pop-up to load and add the message fade in/out to an .OnClick event in the document ready function. – Brian May 21 '12 at 16:35
  • complete senario is based on stackoverflow pop-up...when user have new message pop-up show...when website administrator send message to user pop-up show.....also i say example in my question:is say "when CheckBox1.Checked value in "editor.aspx" is true(editor.aspx is website administrator page) pop-up must show in index.aspx... – AminM May 21 '12 at 17:11
  • If I understand the comment it still doesn't change things. you want to fire the check on page load (document ready) but you don't want to fire the action to show the div unless there is something to show or on a click event. The way you have it you will show the message div every time whether there is something to show or not. – Brian May 21 '12 at 17:26
  • Wrap your javascript above & possibly the message div as well in a check. Checkbox1 saves it's state somewhere, so if that state is true, then include the code, otherwise exclude it – Simon Halsey May 21 '12 at 18:05
  • @ somon: i use AS.NET and its compenent – AminM May 22 '12 at 05:42

1 Answers1

0

Why not create a Javascript variable and set it's value on !IsPostBack.

<script type="text/javascript">

var postBack = <%=IsPostedBack%>// you can use a variable from codebehind

if(postBack == false) $("#message").fadeIn("slow");

$("#message").fadeOut("slow");

</script>

Inside Page_Load function set IsPostedBack.

Ravi Vanapalli
  • 9,805
  • 3
  • 33
  • 43
  • what happened if page is not post back but user have message??do you read my question?? – AminM May 22 '12 at 20:18
  • How is it possible we are using variable "IsPostedBack" which is set in Page_Load function. How are you maintaining CheckBox1 value in "editor.aspx" for Index.aspx? Must be using session right then use that value for the condition as well. – Ravi Vanapalli May 23 '12 at 07:56
  • Based on wikipedia "the contents of the form are **POSTed back** to the same URL as the form"...now is it postback if user load page for first time? – AminM May 23 '12 at 15:18