首页  /  留言  /  音乐  /  管理

ASP.NET的ScriptManager.RegisterStartupScript消息提示

前台代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>
    <script language="javascript" type="text/javascript">
    function show(str){
        alert(str);
        return;
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:TextBox ID="username" runat="server"></asp:TextBox>
                <asp:TextBox ID="pwd" runat="server" TextMode="Password"></asp:TextBox>
                <asp:Button ID="but" runat="server" Text="提交" onclick="but_Click" />
                <asp:Button ID="t" runat="server" Text="t" onclick="t_Click" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>
 


后台代码:

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Response.Write(DBHelper.getstr());
    }
    protected void but_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(),"", "show(‘ok‘)",true);
       
    }
    protected void t_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(),"", "show(‘t‘)",true);
    }
}
 

作者:Wilber 类别:编程学习 时间:2011/2/19 15:03:33 评论:0 点击326
标签:  ASP.NET,ScriptManager,RegisterStartupScript,消息提示
打印:  打印本页
字体:  
本页地址:  http://www.webczw.com/s/201121915033376896.html
上一篇:C#图片处理高级应用(裁剪,缩放,清晰度,水印)
下一篇:Transact-SQL声明变量关键字DECLARE

  评论    
当第一个评论者吧!抢沙发>>
  
昵    称: Wilber
形    象:
内    容:
验证码:   
以上网友发言只代表其个人观点,不代表伟博小城的观点或立场。
  Copyright © 2010 - 2016 WEBCZW.COM, All Rights Reserved
伟博小城  版权所有 网站统计
粤ICP备14091989号