最简单的ASPX.cs后台写个alert("a") 就行,还有前台aspx怎么调用,但IE首页察看源代码不会显示出来的。

解决方案 »

  1.   

    后台:
    Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "function test(){alert('a');}", true);前台加一个Button点击调用:
    <input id="Button1" type="button" value="button" onclick="test()" />
      

  2.   


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Info", "function ShowMes(mes){alert(mes);}", true);
            }
        }<asp:Button runat="server" Text="Button" OnClientClick="ShowMes('hi');" />察看源代码不会显示出来的?放到js文件,然后再HTML中包含
      

  3.   

    Response.Write("<script>alert('a');</script>");
      

  4.   


    <%@ 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>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Button ID="butBack" runat="server" Text="Button"  />
            <asp:Button ID="butGo" runat="server" Text="Button" onclick="butGo_Click" />
        </div>
        
        </form>
    </body>
    </html>后台using System;public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.butBack.Attributes.Add("style","display:none");
        }
        protected void butGo_Click(object sender, EventArgs e)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('a');document.getElementById('butBack').click()", true);
        }
    }