在用showModalDialog弹出的框中  怎么用JS调用一个按钮事件啊?
在其他页面中我是用   document.all.Button2.click();   的  为什么到了这里就不行了呢?

解决方案 »

  1.   

    一样的。
    document.all("button1").click();
      

  2.   

    document.getElementById("Button2").click();
      

  3.   

    你是在父页面中调用showModalDialog弹出框中的按钮吗?
      

  4.   

    Test1.htm<script>
    function test()
    {
    alert("Hello world!");
    }function click()
    {
      window.showModalDialog("Test3.aspx",window);
    }
    </script>
    <body onload="javascript:click();">
    </body>
    Test3.aspx<%@ Page Language="C#" AutoEventWireup="false" debug="true" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
    <html>
      <head>
        <title>CSharpTemp</title>
        <meta name=vs_defaultClientScript content="JavaScript">
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function test()
    {
    document.all("Button1").click();
    }
    //-->
    </SCRIPT>    <script runat="server">
    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面 if( !IsPostBack )
    {

    }
    } override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    private void InitializeComponent()
    {    
    this.Load += new System.EventHandler(this.Page_Load);
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    } private void Button1_Click(object sender,EventArgs e)
    {
    Response.Write("我被点击了!");
    }

    </script>  </head>
      <body>
        <form id="Form1" method="post" runat="server">
    <asp:Button id="Button1" runat="server" Text="按钮"></asp:Button>
    <INPUT TYPE="button" value="点击我" onclick="test()">
        </form>
      </body>
    </html>