Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a webpage where i am using asp timer with its tick event along with modal popup for some information to display on page load of a page . now my problem is when the page gets loaded the timer tick event is called and pop up message is displayed from ajax modal pop up extender .but when i click cancel button of popup the popup reappears without getting closed. is this beacuase of timer tick or something else pls help me out with this





Here is my code :

ASP.NET
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div style="removed:absolute; removed 266px; removed 293px;">
<asp:panel  class="popupConfirmation" id="DivConfirmation5" 
	 runat="server">
   <div class="popup_Container">
        <div class="popup_Titlebar" id="Div14">
            <div class="TitlebarLeft">
              Message</div>
            <div class="TitlebarRight" önclick="$get('ButtonDeleteCancel').click();">
            </div>
        </div>
        <div class="popup_Body">
            <p>
             <asp:Label ID ="lblrecharge" runat="server">      <%--<asp:HyperLink  ID="hyplogin" runat="server"  NavigateUrl="~/RechargeOption.aspx">RECHARGE NOW</p>--%>
        </div>
        <div class="popup_Buttons">
          <%--  <asp:Button ID="RechargeNow" runat="server" OnClick="RechrgeNowC()" Text="Recharge Now" />--%>
            <input id="RechargeNow" type="button" value="Recharge Now" style="display:none;" />
              <asp:Button ID="re" runat="server" PostBackUrl="~/RechargeOption.aspx" Text="Recharge Now" Height="30" />    
            <input 
                id="NotNow" type="button" value="Not Now"  önclick="return NotNow_onclick()" style="height:30px;" /></div>
    </div>

       <%-- --%>
       <asp:ScriptManager ID="sc" runat="server">
      <cc1:ModalPopupExtender ID="mpe5"   runat="server" 
TargetControlID="Button3"
    PopupControlID="DivConfirmation5"
    BackgroundCssClass="ModalPopupBG" 
    DropShadow="true" 
    OkControlID="RechargeNow" 
   
    CancelControlID="NotNow"
    PopupDragHandleControlID="Panel3" >
     <input 
                id="Button3"   runat="server" type="button"  style="display:none;"  />
    
    <asp:Button ID="Button2" runat="server" Text="Button" Visible="false"  />
    </div>
 
 
    <asp:Timer ID="tm" runat="server" Enabled="true" Interval="1000"    OnDisposed="Timer_Disposed" OnTick="Timer_Tick" >

    <asp:UpdatePanel ID="up"   runat="server">
        <triggers>
        <asp:AsyncPostBackTrigger ControlID="tm" EventName="Tick" /></triggers>
        
        <div style="removed:absolute; removed 240px; removed 470px; height: 50px; width: 320px;">
   
            
           <asp:Label ID="lbtime" runat="server" Font-Bold="true" ForeColor="Black" >
    <br />
<asp:Label ID="lbtime0" runat="server" Font-Bold="true" ForeColor="Black" >

         
            </div>
            
             


<div style="position:absolute; top: 310px; left: 440px; width:420px; height: 400px;"
 
        id="pic1"   visible="true"
          runat="server">






when i click not now button the modal popup reappears .here you can see i am running a lebelled asp timer

code behind is as follows

C#
 protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            lblrecharge.Text = "HELLO " + Request.Cookies["USERNAME"].Value + " YOU HAVE " + Request.Cookies["pointsreq"].Value + " LESS POINTS IN YOUR ACCOUNT TO PROCEED RECHARGE YOUR ACCOUNT ";
 
            try
            {
               mpe5.Show();
            }
            catch (Exception)
            { }

          //  Response.Write("<script>alert('HELLO " + Request.Cookies["USERNAME"].Value + " YOU HAVE " + Request.Cookies["pointsreq"].Value + " LESS POINTS IN YOUR ACCOUNT TO PROCEED RECHARGE YOUR ACCOUNT');</script>");
            pic1.Visible = true;
            tm.Enabled = true;
}

catch(Exception ex){}
}



protected void Timer_Tick(object sender, EventArgs e)
  {
//Timer tick event handling

}
Posted
Updated 17-Jan-14 1:32am
v3

1 solution

Hi,

Timer_Tick will be triggered for each and every second because of the Timer Interval ="1000".

Suppose you want to display the Modal pop for once then you check the condition in Page_Load like below

C#
try
{
  if(!IsPostBack)
  {
    mpe5.Show();
  }
}
catch (Exception)
{ }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900