Solved

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

Posted on 2012-03-12
3
279 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
Comment Utility
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
Comment Utility
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
Comment Utility
Helpful
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
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…

763 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

10 Experts available now in Live!

Get 1:1 Help Now