本文整理汇总了C#中System.Web.UI.Page.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Page.ToString方法的具体用法?C# Page.ToString怎么用?C# Page.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.Page
的用法示例。
在下文中一共展示了Page.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Check
/// <summary>
/// 验证用户是否有当前权限
/// </summary>
/// <param name="page"></param>
/// <returns></returns>
public static bool Check(Page page)
{
if (page.Session["UserID"] == null)
{
page.Session["ReturnUrl"] = page.ToString().Substring(4, page.ToString().Length - 9).Replace("details", "").Replace("_", "/") + ".aspx";
MSG.AlertReturn(page, "您的登陆已超时,请重新登陆!", "../default.aspx");
//page.Response.Write("<script language='javascript'>");
//page.Response.Write("parent.location.href='../default.aspx';");
//page.Response.Write("</script>");
return false;
}
string UserID = page.Session["UserID"].ToString().Trim();
DataSet ds = new DataSet();
//ASP._1_default_aspx
string sql = "Select Distinct a.ID From UserRole a,RoleRight b, TbRight c Where a.UserID='" + UserID + "' "
+ "And a.RoleID=b.RoleID And b.RightID=c.ID And 'ASP.'+REPLACE(REPLACE(c.PageName,'/','_'),'.','_')='" + page.ToString().Replace("details", "") + "'";
ds = DBA.DbAccess.GetDataSet(CommandType.Text, sql);
if (ds.Tables[0].Rows.Count <= 0)
{
//page.Response.Redirect("default.aspx");
page.Response.Write("<script language='javascript'>");
page.Response.Write("parent.location.href='../default.aspx';");
page.Response.Write("</script>");
return false;
}
return true;
}
示例2: AppendScript
/// <summary>
/// 向当前页面动态输出客户端脚本代码
/// </summary>
/// <param name="javascript">javascript脚本段</param>
/// <param name="page">Page类的实例</param>
/// <param name="afterForm">是否紧跟在<form>标记之后输出javascript脚本,如果不是则在</form>标记之前输出脚本代码</param>
public static void AppendScript(string javascript, Page page, bool afterForm)
{
if (afterForm)
{
page.ClientScript.RegisterClientScriptBlock(page.GetType(), page.ToString(), javascript);
}
else
{
page.ClientScript.RegisterStartupScript(page.GetType(), page.ToString(), javascript);
}
}
示例3: WriteException
public static void WriteException(string errorType, Page pageName, HttpContext context , Exception exceptionMessage)
{
LINQ_WebsiteDataContext db = new LINQ_WebsiteDataContext();
try
{
string errorDescription = "";
string exceptionMsg = exceptionMessage.ToString();
//TODO set error level based on exception keyword or sql error level
int? errorLevel = 0;
string pn = "";
int webUser = (int)context.Session["userid"];
string browserName = GetBrowserName(context.Request.UserAgent.ToString());
pn = pageName.ToString();
db.WriteError(webUser, pn, exceptionMsg, errorDescription, errorType, errorLevel, browserName);
}
catch(Exception ex)
{
EmailError(ex);
}
}