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

I have Following function
C#
public void MsgBox(System.Web.UI.Page aspxPage, string strMessage)
{
   string strScript = "<script language=JavaScript>alert('" + strMessage +"')</script>";
   if(!aspxPage.IsStartupScriptRegistered("Junipers"))
        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

Thnaks
Vishal Jodh
9028668365
Posted
Updated 19-Nov-12 23:03pm
v3

1 solution

Hi Vishal.

You can try this code:

Page page = (Page)HttpContext.Current.Handler;
MsgBox(page, "I'm a message!");
 
Share this answer
 
Comments
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);
form.ProcessRequest(HttpContext.Current);
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