Amit Kumar
Amit Kumar

Reputation: 19

asp button onclick event not firing

asp button onclick event not firing, the button(id="submit") has a onclick event (Submit_Click) , which is not firing on click. why???

<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>

Upvotes: 1

Views: 5810

Answers (1)

David
David

Reputation: 73564

The form is missing the runat=server tag.

For the asp:Button to trigger a server-side event, it needs to be in a form that has the runat="server" attribute set. This is true for all server controls. ( http://www.w3schools.com/aspnet/aspnet_forms.asp )

Your form seems to be trying to call JavaScript instead.

Upvotes: 5

Related Questions