0

我正在尝试使用 Visual Studio 2012 为我的 ASP.NET 空网站使用另一个模板。因此,我使用不同的模板将早期项目中的一些代码复制并粘贴到该项目中,现在我收到此错误:

ASP.site_master' does not contain a definition for 'btnRegister_Click' and no extension method 'btnRegister_Click' accepting a first argument of type 'ASP.site_master' could be found (are you missing a using directive or an assembly reference?)

这是我的代码:

 <div id="login-box" class="login-popup">
                <a href="#" class="close"><img src="http://localhost:12345/CAPSTONE/images/process-stop.png" class="btn_close" title="Close Window" alt="Close" /></a>
                  <form class="signin">
                        <div class="control-group normal_text"><h3>My Site Login</h3></div>
                            <asp:Panel ID="pnlError" runat="server" Visible="false">
                            <div class="alert alert-error">
                            <strong>Error!</strong> Invalid username / password.
                        </div>
                        </asp:Panel>
                        <asp:Panel ID="pnlConfirmed" runat="server" Visible="false">
                        <div class="alert alert-success">
                            <strong>User Activated!</strong> You may now login.
                        </div>
                        </asp:Panel>
                        <asp:Panel ID="pnlReset" runat="server" Visible="false">
                        <div class="alert alert-success">
                            Your password has been changed. You may now login.
                        </div>
                        </asp:Panel>
                        <div class="control-group">
                        <div class="controls">
                            <div class="main_input_box">
                                <span class="add-on"><i class="icon-user"></i></span><asp:TextBox ID="txtEmail" runat="server" MaxLength="70" placeholder="Email Address" />
                                <span class="add-on"><i class="icon-lock"></i></span><asp:TextBox ID="txtPassword" runat="server" MaxLength="50" TextMode="Password" placeholder="Password" />
                            </div>
                        </div>
                </div>
                <div class="form-actions">
                    <span class="pull-left"><asp:Button ID="btnRegister" runat="server" 
                        class="btn btn-inverse" Text="Register" onclick="btnRegister_Click" /></span>
                    <span class="pull-right"><a href="ForgotPassword.aspx">Forgot Password</a>&nbsp;
                        <asp:Button ID="btnLogin" runat="server" 
                        class="btn btn-success" Text="Login" onclick="btnLogin_Click" />
                    </span>
                </div>

我应该怎么办?

4

1 回答 1

1

在母版页的代码隐藏文件中,编写如下内容:

protected void btnRegister_Click(object sender, EventArgs e)
{
    // do something
}
于 2013-07-26T04:01:25.337 回答