日期:2014-05-17 浏览次数:20558 次
<%@ WebHandler Language="C#" Class="Style_Sheet_Attachment_Del" %>
using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
public class Style_Sheet_Attachment_Del : IHttpHandler {
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
try
{
if (context.Request.QueryString["Style_Sheet_Attachment_Id"] == null)
{
context.Response.Write("<script>alert('请以 QuantityString 方式传入 Style_Sheet_Attachment_Id'); window.history.go(-1);</script>");
}
else
{
string cmdText = "DELETE FROM Style_Sheet_Attachment WHERE Id = @Id";
DataHelper.SqlHelper.ExecuteNonQuery(CommonFun.ConnectionString, CommandType.Text, cmdText, new SqlParameter("@Id", context.Request.QueryString["Style_Sheet_Attachment_Id"]));
context.Response.Write("<script>alert('删除成功!'); window.history.go(-1);</script>");
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
}
public bool IsReusable {
get {
return false;
}
}
}
<%@ WebHandler Language="C#" Class="Style_Sheet_Attachment_Del" %>
using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
public class Style_Sheet_Attachment_Del : IHttpHandler {
public void ProcessRequest(HttpContext context)
{
try
{
if (context.Request.QueryString["Style_Sheet_Attachment_Id"] == null)
{
context.Response.Write("<script>alert('请以 QuantityString 方式传入 Style_Sheet_Attachment_Id'); window.history.go(-1);</script>");
}
else
{
string cmdText = "DELETE FROM Style_Sheet_Attachment WHERE Id = @Id";
DataHelper.SqlHelper.ExecuteNonQuery(CommonFun.ConnectionString, CommandType.Text, cmdText, new SqlParameter("@Id", context.Request.QueryString["Style_Sheet_Attachment_Id"]));
context.Response.Write("<script>alert('删除成功!'); window.history.go(-1);</script>");
}
}
catch (Exception ex)
{
context.Response.Write(ex.Message);
}
}
public bool IsReusable {
get {
return false;
}
}
}
------解决方案--------------------
直接把context.Response.ContentType = "text/plain";去掉就可以
恩 对的
不然直接输出文本