views:

133

answers:

5

Locally it works, I know its the "it works on my machine" syndrome but i cant see why.

Simple web page, fields, required field validators, such as

<asp:textbox id="tbEmail" runat="server" CssClass="field"></asp:textbox>              <asp:requiredfieldvalidator id="Requiredfieldvalidator2" runat="server" Display="Dynamic" ControlToValidate="tbEmail" ErrorMessage="Email is required" CssClass="required"></asp:requiredfieldvalidator>

button with

<asp:button id="btnSendRequest" runat="server" Text="Submit" CausesValidation="True"></asp:button>

Locally it triggers and the code doesnt run, on the deployed version the validators dont fire and the code runs.

Should be simple but ive been staring at it for too long.

Thanks people - Tariq

A: 

I'm not sure if this is relevant for your version of .NET but you might have to run aspnet_regiis -i on the server to install the scripts for validation. Double-check this, please, before doing anything :)

I hope this sends you in the right direction.

http://msdn.microsoft.com/en-us/library/k6h9cz8h(VS.80).aspx

Eric Willis
The scripts are only required for client-side validation, and I don't see that in his code. I had problems with aspnet_regiis -i not installing the scripts in the past, and had to install them manually, though.
cdonner
@cdonner: an asp:requiredfieldvalidator should validate both client-side and server-side.
Henk Holterman
+1  A: 

I was thinking the same thing - the asp_regiis will create the aspnet_client folder in the root of your site. Also watch for javascript errors being reported, they will help in the diagnosis.

A: 

In a situation like this, I find it helpful to compare the raw HTML output you get locally with the output on the deployed server. You are probably missing the validation javascript on the deployed version, as Eric pointed out... but this will tell you for sure.

Bryan
A: 

The difference might be that on your local test you are getting the client side validators triggered and on the server only the server side. Make sure you add an IsValid if to your method, like:

void MyClickHandler(object sender, EventArgs e)
{
   if( IsValid)
   {
      //rest of the code
   }
}
eglasius
A: 

Install Fiddler: Fiddler and watch the traffic. Is it getting any 404 or 500 HTTP errors while loading your page? It's probably trying to load the necessary client-side validation files but running into problems.

Nicholas H