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
Solved

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

Posted on 2012-03-12
3
286 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
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

808 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