button click executes postback page not valid

  • Thread starter Thread starter John Bonds
  • Start date Start date
J

John Bonds

I'm having a dumb problem

I put a few TextBoxes on a page and a few RequiredFieldValidators and a
button. For some reason when I click the button, my browser still makes a
round trip (postback) to the server and comes back with the proper
validation error messages. I want the validation to be CLIENT-SIDE. I'm sure
I'm doing something lame. Here's the page

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Maestro Glass Administration Login</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body topMargin="0">
<form id="frmLogon" method="post" runat="server">
<TABLE id="htblLogin" cellSpacing="1" cellPadding="1" width="300"
align="center" border="0">
<TR>
<TD colSpan="2" height="200"></TD>
</TR>
<TR>
<TD style="HEIGHT: 23px" align="right">User Name:</TD>
<TD style="HEIGHT: 23px"><asp:textbox id="tbxUserName"
runat="server"></asp:textbox><asp:requiredfieldvalidator id="reqUserName"
runat="server" ErrorMessage="A username is required" Font-Size="14px"
ControlToValidate="tbxUserName">*</asp:requiredfieldvalidator></TD>
</TR>
<TR>
<TD align="right">Password:</TD>
<TD><asp:textbox id="tbxPassword"
runat="server"></asp:textbox><asp:requiredfieldvalidator id="reqPassword"
runat="server" ErrorMessage="A password is required" Font-Size="14px"
ControlToValidate="tbxPassword">*</asp:requiredfieldvalidator></TD>
</TR>
<TR>
<TD align="right"></TD>
<TD>&nbsp;&nbsp;&nbsp;<INPUT type="reset"
value="Clear">&nbsp;&nbsp;&nbsp;
<asp:button id="btnLogon" runat="server" Text="Logon"
CausesValidation="True"></asp:button></TD>
</TR>
<TR>
<TD align="left" colSpan="2">
<asp:ValidationSummary id="valErrorSummary" runat="server"
Width="300px" HeaderText="***ERROR***"></asp:ValidationSummary></TD>
</TR>
</TABLE>
</form>
</body>
</HTML>

What am I doing wrong?

Thanks,
John
 
I tried that but it is still making a round-trip to the server. I just found
out that the server side code is running as well so my validators seem to be
broken.

Any help is appreciated!

John
 
Hi,

if you are using IE 4.0 onwards, you can write client side javascript to
validate the controls without having a postback.

Regards
Joyjit
 
For anyone else who is interested, my server side javascript files were
missing.
They are supposed to be in here: DOMAINROOT\aspnet_client\system_web

Check this if your pages are posting to the server even though Page.IsValid
on the client-side is false.

John
 
Back
Top