Location 消息框类

Posted zengxh

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Location 消息框类相关的知识,希望对你有一定的参考价值。

using System;
using System.Web;
using System.Web.UI;
using System.Text.RegularExpressions;

namespace HuoLi.Common
{
 /// <summary>
 /// Location 的摘要说明。
 /// </summary>
 public class Location
 {
  public Location()
  {
   //
   // TODO: 在此处添加构造函数逻辑
   //
  }

  /// <summary>
  /// 根据值弹出提示对话框
  /// </summary>
  /// <param name="ret">传入的值</param>
  /// <param name="msg">成功信息</param>
  /// <param name="err">失败信息</param>
  /// <param name="page">定向的页面</param>
  public static void Judge(int ret,string msg,string err,string page)
  {
   if (ret>0)
   {
    MsgBoxToPage(msg,page);
   }
   else
   {
    MsgBox(err);
   }
  }
  /// <summary>
  /// 定向,自身关闭.
  /// </summary>
  /// <param name="page"></param>
  public static void open(string page)
  {
   System.Web.HttpContext.Current.Response.Write("<script language="javascript">window.open(‘"+page+"‘,"查看资料","toolbar=yes,location=no,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes");</script>");
  }
  /// <summary>
  /// 定向,自身关闭.
  /// </summary>
  /// <param name="page"></param>
  public static void openClose(string msg,string page)
  {
   System.Web.HttpContext.Current.Response.Write("<script language="javascript">alert(‘"+msg+"‘);window.open(‘"+page+"‘,"","toolbar=yes,location=no,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes");window.opener=null;window.close();</script>");
  }

  /// <summary>
  /// 定向,自身关闭.
  /// </summary>
  /// <param name="page"></param>
  public static void location(string page)
  {
   System.Web.HttpContext.Current.Response.Write("<script  language=‘javascript‘>window.location.href=‘"+page+"‘;</script>");
   return;
  }

  
  /// <summary>
  /// 定向,自身关闭.
  /// </summary>
  /// <param name="page"></param>
  public static void history()
  {
   System.Web.HttpContext.Current.Response.Write("<script  language=‘javascript‘>window.history.back(-1);</script>");
  }
  
  /// <summary>
  /// 定向,自身关闭.
  /// </summary>
  /// <param name="page"></param>
  public static void MsgBox(string msg)
  {
   System.Web.HttpContext.Current.Response.Write("<script  language=‘javascript‘>alert(‘"+msg+"‘);</script>");
//   System.Web.HttpContext.Current.Response.Write("<script>alert(‘aaa‘);</script>");
   return;
  }

  /// <summary>
  /// 定向,自身关闭.
  /// </summary>
  /// <param name="page"></param>
  public static void GoBackToPage(string page)
  {
   System.Web.HttpContext.Current.Response.Write("<script  language=‘javascript‘>location.href=‘"+page+"‘;self.close();</script>");
   //   return;
  }

  /// <summary>
  /// 定向
  /// </summary>
  /// <param name="page"></param>
  public static void MsgBoxToPage(string msg,string page)
  {
   System.Web.HttpContext.Current.Response.Write("<script language=‘javascript‘>alert(‘"+msg+"‘);location.href=‘"+page+"‘;</script>");
   //   return;
  }

  /// <summary>
  /// 定义登陆页,跳出Frame
  /// </summary>
  /// <param name="page"></param>
  public static void LocationToPage(string msg,string page)
  {
   System.Web.HttpContext.Current.Response.Write("<script  language=‘javascript‘>alert(‘"+msg+"‘);window.parent.document.location.href=‘"+page+"‘;</script>");
   //   return;
  }
  /// <summary>
  /// 定义登陆页,跳出Frame
  /// </summary>
  /// <param name="page"></param>
  public static void lointimeout(string page)
  {
   System.Web.HttpContext.Current.Response.Write("<script  language=‘javascript‘>window.parent.document.location.href=‘"+page+"?err=timeout‘;</script>");
   //   return;
  }

  /// <summary>
  /// 页面输出错误
  /// </summary>
  /// <param name="errorStr"></param>
  public static void ShowError(string errorStr)
  {
   System.Web.HttpContext.Current.Response.Write("ERROR : "+errorStr);
   return;
  }

  /// <summary>
  /// 一个含有“确定”,点击后关闭自己,刷新父窗口警告框
  /// </summary>
  /// <param name="_Msg">警告字串</param>
  /// <returns>警告框JS</returns>
  public static void alert_reloadwin(string _Msg)
  {
   System.Web.HttpContext.Current.Response.Write("<script  language=‘javascript‘>alert(‘"+_Msg+"‘);window.opener.location=window.opener.location;window.opener=null;window.close();</script>");
//   string StrScript;
//   StrScript = ("<script language=javascript>");
//   StrScript += ("alert(‘" + _Msg + "‘);");
//   StrScript += ("window.opener.location.href=window.opener.location.href;window.close();");
//   StrScript += ("</script>");
//   System.Web.HttpContext.Current.Response.Write(StrScript);
  }

  /// <summary>
  /// 使控件获得焦点
  /// </summary>
  /// <param name="Ctl_Name">获得焦点控件Id值</param>
  /// <param name="page">Page类</param>
  public static void GetFocus(string Ctl_Name,Page page)
  {
            //page.ClientScript.RegisterStartupScript(Ctl_Name, "<script  language=‘javascript‘>document.forms(0)." + Ctl_Name + ".focus(); document.forms(0)." + Ctl_Name + ".select();</script>");
            page.ClientScript.RegisterStartupScript(page.GetType(), Ctl_Name, "<script  language=‘javascript‘>document.forms(0)." + Ctl_Name + ".focus(); document.forms(0)." + Ctl_Name + ".select();</script>");
        }

  /// <summary>
  /// 一个含有“确定”,点击返回先前的网页警告框
  /// </summary>
  /// <param name="_Msg">警告字串</param>
  /// <param name="BackLong">要倒退几步</param>
  /// <returns>警告框JS</returns>
  public static void alert_history(string _Msg,int BackLong)
  {
   string StrScript;
   StrScript = ("<script language=javascript>");
   StrScript += ("alert(‘" + _Msg + "‘);");
   StrScript += ("history.go(‘" + BackLong + "‘)");
   StrScript += ("</script>");
   System.Web.HttpContext.Current.Response.Write(StrScript);
  }
 }
}

 

以上是关于Location 消息框类的主要内容,如果未能解决你的问题,请参考以下文章

在MFC中:静态文本类;按纽类;编辑框类;滚动条类;列表框类;组合框类等所对应的类名以及其功能

在 Spark Scala 中使用自定义数据框类时任务不可序列化

Python Qt GUI设计:QLineEdit和QTextEdit文本框类(基础篇—13)

Python Qt GUI设计:QLineEdit和QTextEdit文本框类(基础篇—13)

文本框类控件

Bootstrap 的模态框类