如何将aspx页作为参数传递给C#函数 [英] How to pass aspx Page to C# function as a Parameter

查看:207
本文介绍了如何将aspx页作为参数传递给C#函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我具有以下功能

Hi Everyone

I have Following function

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);

}



现在,我将这种功能称为MsgBox(this,"My Name is Vishal");
但是假设我想传递另一个页面(Default.aspx)而不是此关键字,那又如何呢?

请帮我

致谢
维沙尔·乔德
9028668365



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

推荐答案

Vishal.

您可以尝试以下代码:

Hi Vishal.

You can try this code:

Page page = (Page)HttpContext.Current.Handler;
MsgBox(page, "I''m a message!");


这篇关于如何将aspx页作为参数传递给C#函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆