现在的位置: 首页 > 综合 > 正文

服务器端 弹出确认框,选择确定,取消 实现不同效果

2013年09月30日 ⁄ 综合 ⁄ 共 1265字 ⁄ 字号 评论关闭
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ConfirmWeb.aspx.cs" Inherits="ConfirmWeb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>价格确定</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
        <asp:Button ID="TestBut" runat="server" onclick="TestBut_Click" Text="测试按钮" />
    </form>
</body>
</html>

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
/*
 *说明:关于服务器端发问题 
 *日期:2011-09-10
 */
public partial class ConfirmWeb : System.Web.UI.Page,IPostBackEventHandler
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public void RaisePostBackEvent(string eventArgument)
    {
        switch (eventArgument)
        {
            case "确定":
                this.TestBut.ForeColor = Color.Green;
                return;
            case "取消":
                this.TestBut.ForeColor = Color.Red;
                return;
        }

    }

    protected void TestBut_Click(object sender, EventArgs e)
    {
        string s = "if(confirm('后台已经处理了一部分计算,结果是xxxxx。要继续吗?')){0};else {1};";
        ScriptManager.RegisterStartupScript(this, typeof(ConfirmWeb), "计算中",
            string.Format(s, this.ClientScript.GetPostBackEventReference(this, "确定"), this.ClientScript.GetPostBackEventReference(this, "取消")),
            true);
        int i = 9 + 4;
        Response.Write(i.ToString());
    }
}

【上篇】
【下篇】

抱歉!评论已关闭.