C# .NET - the page.RegisterStartUpScript is not working

Asked By balaji mogadali on 05-Mar-11 01:55 AM
 Page.RegisterStartupScript("PWDScrpt", "<script language=javascript>window.showModalDialog('popup.aspx','','dialogHeight:260px;dialogWidth:564px;center:yes');</script>");


Above script is not working to invoke a new window
pls mention any alternative code 

With Regards
M.Balaji
Jatin Prajapati replied to balaji mogadali on 05-Mar-11 04:45 AM
Hi,
The Page.RegisterStartupScript() method is deprecated. The Page.ClientScript.RegisterStartupScript is now available for this.
So, please use this Page.ClientScript.RegisterStartupScript method for this.


Thanks.
Ramendra Kumar replied to balaji mogadali on 05-Mar-11 04:54 AM
if u have update pannel and script manager then that code won't work u need to write like this
ScriptManager.RegisterStartupScript(this, GetType(), "chkwerwediv", "changediv()", true);
Anoop S replied to balaji mogadali on 05-Mar-11 05:26 AM
When I tested your code, my browser's pop-up blocker triggered...I allowed the pop-up and it worked.

When I did it this way, the pop-up blocker did not trigger:

  
<script language="javascript" type="text/javascript">
    function DoIt()
    {
    window.showModalDialog('Popup.aspx', 'dialogHeight:260px;dialogWidth:564px;status:no');
    }
 
<asp:Button ID="Button1" runat="server"  Text="Button"  OnClientClick="DoIt();"/>
Reena Jain replied to balaji mogadali on 05-Mar-11 06:06 AM
hi,

the syntax is
Page.RegisterStartupScript(type,string,string);
so you have to write like that model..
eg:
Page.RegisterStartupScript(me.getype(),"msg1","alert()");

hope this will help you