Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now