如果直接在页面中使用Response.Write("");
来源:互联网 发布:fifaonline317数据更新 编辑:程序博客网 时间:2024/05/17 23:43
如果直接在页面中使用Response.Write("<script>alert('错误信息');</script>"); 点击确定以后,可能会造成页面“错位”;
把代码封装到一个类中(就叫PageHelper.cs吧),在其他页面也可以方便的调用;
例如在其他页面调用:Page.Alert(this,"错语信息"); 效果和上面的代码是一样的,要说不同点吧?就是这个写法比上面的完美好多。
调用的时候也可以有第二个参数,即转跳地址: Page.Alert(this,"警告提示~","~/Default.aspx");
/**
*
* 功明说明:页面助手类,实现弹出警告对话框;
*
* Design By: http://www.818u.com;
*
* 创建日期:2011-01-11
*
* */
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
namespace NewsSystem.CommonUtility
{
public static class PageHelper
{
public static void Alert(Page objPage, string message)
{
string key = "AlertMessage";
string script = string.Format("alert('{0}')", message);
objPage.ClientScript.RegisterStartupScript(typeof(Page), key, script, true);
}
public static void Alert(Page objPage, string message, string url)
{
string key = "AlertMessage";
string script = String.Format("alert('{0}');window.location='{1}';", message, url);
objPage.ClientScript.RegisterStartupScript(typeof(Page), key, script, true);
}
}
}
- 如果直接在页面中使用Response.Write("");
- 在非aspx.cs文件中使用response.write
- 在asp.net页中执行Response.Write("");页面变形的问题
- Servlet中直接response.getWriter().write() 输出乱码解决!
- asp.net中Response.write与Response.Redirect同时使用
- 在atlas(ajax)中请不要使用Response.Write,请使用ClientScript.RegisterClientScriptBlock替换
- 在atlas(ajax)中请不要使用Response.Write,请使用ClientScript.RegisterClientScriptBlock替换
- 为什么不直接使用Response.Write而要使用Response.Output.WriteLine
- 在类中使用response给页面反馈
- 在C#中使用Response.write返回的内容不要HTML
- UpdatePanel中Response.Write()
- response.write 页面变形解决办法
- response.write 页面变形解决办法
- 关于在Struts2的action中直接使用response的异步问题
- 在WebView的页面中直接使用res中的图片
- 直接使用Response.Write<script>弹窗脚本导致CSS失效
- response.write后页面变形的问题
- 页面Response.Write后样式丢失
- 【串口通信一】经过检验的串口通信协议
- JQUERY 的文本框回车 点击的BUG
- VC快捷键
- 新的角度看matrix相乘(分块相乘)
- vsFTPd 服务器初学者指南(欢迎大家参与补充)
- 如果直接在页面中使用Response.Write("");
- 几个常见的“算法”小程序
- 如何编写和调用资源文件
- webkit问题汇总
- 如何用 maven 同时 install jar 和 war
- C#编写GridView导出EXCEL
- Memcached 缓存系统
- MySql root 密码修改
- Enum使用实例