易截截图软件、单文件、免安装、纯绿色、仅160KB

ASP.NET中常用的用来输出JS脚本的类

在ASP.NET中我们经常需要输出一些JS脚本,比如弹出一个警告窗口,返回到历史页面等JS功能,我看到网上好多这方面的代码,以下代码是其中之一。
整个程序的代码如下:
复制代码 代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
/// <summary>
/// 弹出JavaScript小窗口
/// </summary>
/// <param name="js">窗口信息</param>
public static void Alert(string message, Page page)
{
#region
string js = @"<Script language='JavaScript'>
alert('" + message + "');</Script>";
//HttpContext.Current.Response.Write(js);
if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "alert"))
{
page.ClientScript.RegisterStartupScript(page.GetType(), "alert", js);
}
#endregion
}
/// <summary>
/// 弹出消息框并且转向到新的URL
/// </summary>
/// <param name="message">消息内容</param>
/// <param name="toURL">连接地址</param>
public static void AlertAndRedirect(string message, string toURL, Page page)
{
#region
string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>";
//HttpContext.Current.Response.Write(string.Format(js, message, toURL));
if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "AlertAndRedirect"))
{
page.ClientScript.RegisterStartupScript(page.GetType(), "AlertAndRedirect", string.Format(js, message, toURL));
}
#endregion
}
/// <summary>
/// 回到历史页面
/// </summary>
/// <param name="value">-1/1</param>
public static void GoHistory(int value, Page page)
{
#region
string js = @"<Script language='JavaScript'>
history.go({0});
</Script>";
//HttpContext.Current.Response.Write(string.Format(js, value));
if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "GoHistory"))
{
page.ClientScript.RegisterStartupScript(page.GetType(), "GoHistory", string.F


相关文档:

ASP.NET 操作MySQL数据库的方法说明

using System;
using System.Data;
using System.Diagnostics;
using System.Collections.Generic;
using MySql.Data.MySqlClient;
namespace System
{
 /// <summary>
 /// Description of MySqlDBUtil.
 /// </summary>
 public class MySqlDBUtil
 {
  &nbs ......

Paging long articles in ASP.NET using C#

Paging long articles in ASP.NET using C#
Long articles are better broken into bite-sized chunks over several pages. With static HTML, this is easily achieved by dividing the article into logical separations and creating separate .htm files for each. Here's how to do it using C# for an article that ......

错误记录:ASP.NET(C#)中未能加载自定义类型(类)

环境:ASP.NET(C#),Visual Studio 2010。
提示:未能加载类型“EMS.App_Code.PersonalInfo”。如果该类型位于App_Code文件夹中,请检查它是否已编译。如果该类型位于已编译的程序集中,请检查该程序集是否被该项目引用。
处理:
自己做得一个小程序,取名EMS,并在App_Code文件夹下建立了类PersonalInfo、Sal ......

asp.net“服务器应用程序不可用” 解决方法

引起这个的原因大概是现安装了.Net Framework后装的IIS导致.Net没有在IIS里注册。
在网上找了很久都是说从.net命令行工具里运行aspnet_regIIS /i就可以了(或者在类似下面的目录:C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i),但是自己试了很多次都不行,后来发现还是要先卸载再安装,重新创建为 ......

asp.net构建Web服务基础(含SOAP相关知识)

WSDL:是一个用来描述Web服务和说明如何与Web服务通信的XML语言。 怎样向别人介绍你的Web service有什么功能,以及每个函数调用时的参数等等。
 
web服务:进行web上数据交换的方法。能够以纯xml方式通信。
 
SOAP:简单对象存取协议。可看做xml方言; 以SOAP信封来传递和响应文本(包含:首部、主体)HTTP P ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号