Solved

How to have a  modal pop up appear N seconds after page load

Posted on 2012-03-12
3
295 Views
Last Modified: 2012-03-16
Hi

I am trying to deploy a modal pop up in a .net page. I have succeeded in firing it from the page load event. But I really want it to appear, say, 5 seconds after the page has loaded.

How can I do this?

Here is how I am calling the pop up in code.

        If Page.IsPostBack = False Then
            LoadPopup()
        End If

   Protected Sub LoadPopup()
        mpe_Demo1.Show()
    End Sub

 <asp:Panel ID="p_MainContent" runat="server" CssClass="modalPopup"  >
            <div>
                <p>
                    Content goes in this panel</p>
                <asp:Button ID="btnOk" runat="server" Text="Ok" OnClick="Ok" />
                <asp:Button ID="btnCancel" runat="server" OnClick="Cancel" Text="Cancel" />
            </div>
        </asp:Panel>
        <asp:LinkButton ID="lnk_None" runat="server" Text="click" />
        <%--      --%>
        <cc1:ModalPopupExtender ID="mpe_Demo1" runat="server" TargetControlID="lnk_None"
            PopupControlID="p_MainContent" BackgroundCssClass="modalBackground" />
0
Comment
Question by:davnhm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 21

Expert Comment

by:Craig Wagner
ID: 37714548
You'd really be better served looking at a client-side technology to accomplish this. I'd suggested taking a look at jQuery and jQuery UI. In the $(document).ready() method you could start a timer and then open a jQuery UI modal dialog when the timer expires.
0
 
LVL 17

Accepted Solution

by:
jrm213jrm213 earned 500 total points
ID: 37714671
as CraigWarner suggested a client side script is should be used, the function you want in javascript is setTimeout. The first parameter is the function to perform when the timer expires and the second parameter is the number of milliseconds before running the function/method in the first parameter.

so for example if you were using jquery to display it you could do something like this

function show_dialog()
{
    $(".modalPopup").dialog({
                  height: 350, //modify here for your popups height
                        width: 3450, //modify here for your popups width
                  modal: true
            });
}

$(function() {
       setTimeout("show_dialog()",5000);
});
0
 

Author Closing Comment

by:davnhm
ID: 37729206
Helpful
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question