我在网上DOWN了一个现成的论坛,要添加到我的系统中.我想完成在我系统登陆后,连接到论坛页面的时候,取session传值到论坛的用户登陆框中,然后自动触发button的onclick事件.
    我想问的就是,在pageonload里面应该如何写代码,才能触发到onclick事件.
    谢谢!

解决方案 »

  1.   

    是form自动提交把,用javascript,然后<body onload="">就可以了
      

  2.   

    document.getElmentById('btnid').click();
      

  3.   

    document.all.btnLogin.click();-----难免有错,错了莫怪.
      

  4.   

    <script runat="server">    protected void Page_Load(object sender, EventArgs e)
        {
            textUser.Text = Request.QueryString[0];
            textPwd.Text = Request.QueryString[1];
            btLogin.Controls.Add(clicked);
            //Control.Equals(this.btLogin);
            //document.getElmentById('btLogin').click();
           在此处如何调用到btLogin的OnClick事件
        }
    </script><div class="headStateDiv" style="margin-left: auto; margin-right: auto;">
        <table style="width: 100%; height: 20px; border-collapse: collapse;" runat="server"
            id="tbNoLogin">
            <tr>
                <td style="height: 20px">
                    &nbsp;&nbsp;用户名:<asp:TextBox ID="textUser" runat="server" MaxLength="20" Height="13"
                        Width="60"></asp:TextBox>&nbsp; 密码:<asp:TextBox ID="textPwd" runat="server" 
                            Height="13" Width="80"></asp:TextBox>&nbsp;
                    <asp:CheckBox ID="chkRember" runat="server" Checked="false" Text="记住我" />&nbsp;
                    <asp:Button ID="btLogin" runat="server" Text="登陆" Height="19" OnClick="btLogin_Click"
                        CausesValidation="False" />&nbsp; <a href="<%=Page.ResolveUrl("reg.aspx")%>">新用户注册</a>&nbsp;<a href="userFindPwd.aspx">忘记密码</a>
                </td>
            </tr>
        </table>
      

  5.   

    //document.getElmentById('btLogin').click();document.getElmentById('btLogin').OnClick();
      

  6.   

    在<script runat="server">    protected void Page_Load(object sender, EventArgs e)
        {
            textUser.Text = Request.QueryString[0];
            textPwd.Text = Request.QueryString[1];
            btLogin.Controls.Add(clicked);
            //Control.Equals(this.btLogin);
            //document.getElmentById('btLogin').click();
           在此处如何调用到btLogin的OnClick事件
        }
    </script>
    脚本中根本没有document.getElmentById('btLogin').click();方法.
    要怎么做呢?
      

  7.   

    onKeydown="if(event.KeyCode==13)Form1.myButton1.Focus();"
    这样回车就会出发mybutton1 的Click事件.
      

  8.   

    RegisterStartupScript("", "<script language=javascript>document.all.Button1.click();</script>");