views:

124

answers:

3

I'm using the default validation that comes with .NET

The problem I am having is that even with JavaScript enabled on my browser, a basic validation is still allowing postback.

    <asp:TextBox ID="TextBox1" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Button" />

My App is usihg UrlRewriting.Net... could this be the problem?

<urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString" xmlns="http://www.urlrewriting.net/schemas/config/2006/07"&gt;
    <rewrites>
        <!--Fix the WebResource JS Error-->
        <add name="WebResourceFix" virtualUrl="^~/WebResource.axd(.*)" rewriteUrlParameter="IncludeQueryStringForRewrite" destinationUrl="~/WebResource.axd$1" ignoreCase="true"/>
        <!--Fix the ScriptResource JS Error-->
        <add name="ScriptResource" virtualUrl="^~/ScriptResource.axd(.*)" rewriteUrlParameter="IncludeQueryStringForRewrite" destinationUrl="~/ScriptResource.axd$1" ignoreCase="true"/>
        <!--Allow Extensionless Pages-->
        <add name="pageExtensionless" virtualUrl="^~/(.+)$" redirectMode="Permanent" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/$1.aspx" ignoreCase="true"/>
    </rewrites>
</urlrewritingnet>
+1  A: 

Here are some suggestions on debugging problems like this:

  1. Use Fiddler or some other HTTP debugger to ensure that the page is correctly downloading the external JavaScript files used to provide client-side validation, and that these client-side files are being correctly returned from the server (that is, that they are not returning 404 or some other HTTP error code).
  2. Use Firebug to set a breakpoint and step through the JavaScript execution.
Scott Mitchell
A: 

In your RequiredFieldValidator I would suggest that you try setting EnableClientScript="true". Hopefully that will fix the problem.

James
+2  A: 

Try adding CausesValidation = True on your button.

<asp:Button ID="Button1" runat="server" Text="Button" CausesValidation="True" />
Phaedrus
I have never had to do that before. This is a new one to me. Usually CausesValidation is enabled by default.
rockinthesixstring
I agree, that's odd. I wonder if the textbox is inheriting a "CausesValidation=False" from a container control...
Mark Kadlec
I don't have any "CausesValidation" anywhere in my site.
rockinthesixstring
Sorry.. I "Answered" too soon. Turns out the Google Maps Control I got from CodePlex is causing the validation issues. Not sure how to work around it.
rockinthesixstring