asp按钮onclick事件没有触发

时间:2012-10-15 19:19:00

标签: asp.net

asp按钮onclick事件未触发, 按钮(id =" submit")有一个onclick事件(Submit_Click),它不会在点击时触发。为什么???

<form enctype="multipart/form-data" method="post" action="javascript:;">
    <div class="content">
        <p>
            I am a returning customer</p>
        <b>E-Mail Address:</b><br />

        <asp:TextBox name="email" runat="server" ID="email"></asp:TextBox>
        <asp:RegularExpressionValidator ID="email_validation" runat="server" 
            ControlToValidate="email" ErrorMessage="enter a valid email" ForeColor="Red" 
            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
            ValidationGroup="email"></asp:RegularExpressionValidator>
        <br />
        <br />
        <b>Password:</b><br />
        <asp:TextBox runat="server" name="password" TextMode="Password"></asp:TextBox>
        <br />
        <a href="javascript:;">Forgotten Password</a><br />
        <br />
        <asp:Button ID="Submit" runat="server" CssClass="button" Text="Login" 
            onclick="Submit_Click" />
        <input type="hidden" value="http://www.przemyslawlobodzinski.pl/themes/megastore/index.php?route=account/account"
            name="redirect"/>
    </div>
</form>

1 个答案:

答案 0 :(得分:5)

表单缺少runat=server标记。

对于要触发服务器端事件的asp:Button,它需要采用设置了runat =“server”属性的形式。这适用于所有服务器控件。 (http://www.w3schools.com/aspnet/aspnet_forms.asp

您的表单似乎试图调用JavaScript。