Click here to Skip to main content
15,850,548 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi Everyone

I have Following function
public void MsgBox(System.Web.UI.Page aspxPage, string strMessage)
   string strScript = "<script language=JavaScript>alert('" + strMessage +"')</script>";
        aspxPage.RegisterStartupScript("Junipers", strScript);


now I am Call this fuction like MsgBox(this,"My Name is Vishal");
but suppose i want to pass another page(Default.aspx) instead of this keyword then how?

pls hel me

Vishal Jodh
Updated 20-Nov-12 0:03am

1 solution

Hi Vishal.

You can try this code:

Page page = (Page)HttpContext.Current.Handler;
MsgBox(page, "I'm a message!");
Share this answer
vishal jodh 20-Nov-12 5:01am    
Hi gilvani Sir

currently I am index.aspx page but I want to pass Default.aspx page to MsgBox Method.
gilvani 20-Nov-12 5:20am    
Hhhmmmm! I think that might help you. But I'm not sure!

Type type = System.Web.Compilation.BuildManager.GetCompiledType("~/Default.aspx");
Default form = (Default)Activator.CreateInstance(type);
MsgBox(form.Page, "I'm a message!");

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