Click here to Skip to main content
15,040,212 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to show ModalPopUpExtender in Page Load?

I'm Using Asp.net with C# as code behind. I want to show a terms & conditions pop up after login (redirected to next page and its page load)
Posted

We can write a function in Java script as


C#
function PageLoad()
        {
            document.getElementById("btn").click();
        }



and call it in Page Load as

<body onload="PageLoad()" >

and place a button control in page.

& for ModalPopUp,

VB
<ajaxToolkit:ModalPopupExtender ID="ModalPopUp" runat="server" BackgroundCssClass="modalBackground"
                cancelcontrolid="CancelButton" dropshadow="true" okcontrolid="OkButton"
            popupcontrolid="Panel1"  targetcontrolid="btn">


btn is ID of button control.


It will work.
   
Try this in your Page_Load Event.
C#
ModalPopUpExtender1.Show();


--Amit
   
Comments
KuttiSankar 18-Jun-13 6:36am
   
No im asking how to call it in page load event? wat will be target control id?

<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" >


This is my code and what i can put target control id for triggering the pop up in page load event?
_Amy 18-Jun-13 6:39am
   
Panel will be the best option. You can use a panel to do the same.
KuttiSankar 18-Jun-13 6:42am
   
Yes i have panel also but i want to know how to trigger it while page load?
_Amy 18-Jun-13 6:44am
   
Try this in your Page_Load:
ModalPopUpExtender1.TargetControlID = YourPanelID.ClientID;
ModalPopUpExtender1.Show();
--Amit
KuttiSankar 18-Jun-13 6:47am
   
Error:
Object reference not set to an instance of an object.
_Amy 18-Jun-13 6:49am
   
Which line? Can you show your code?
KuttiSankar 18-Jun-13 6:49am
   
ModalPopupExtender1.TargetControlID=Panel1.ClientID;
ModalPopupExtender1.Show();

this only i have written in page load.
_Amy 18-Jun-13 6:52am
   
Debug the code. Check your Panel/ModalPopupExtender and find why it is coming null.
KuttiSankar 18-Jun-13 6:55am
   
can u tell me ur mail id and then i can mail my code?
_Amy 18-Jun-13 6:56am
   
No, sorry. You can check my profile.
KuttiSankar 18-Jun-13 6:58am
   
fine thanks

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