ASP.Net MVC 2.0 Client-Side Validation Posting Back
صفحه اصلي

ASP.Net MVC 2.0 Client-Side Validation Posting Back

I have been trying this based on Scott Gu's blog:

My problem is that although my scripts are running (checked in firebug) and I don't get any errors. My page is still going to the server. I have javascript enabled too ;)

I have the following view code:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Part1a.ViewModels.ProductModel>" %> 


<script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>    <script src="../../Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>   <h2>Create Product</h2>      <% Html.EnableClientValidation(); %>  <% using (Html.BeginForm()) {%>                    <fieldset>         <legend>Fields</legend>                     <%= Html.LabelFor(model => model.Owner) %>                 <%= Html.EditorFor(model => model.Owner) %>          <%= Html.ValidationMessageFor(model => model.Owner)%>            <p>             <input type="submit" value="Create" />         </p>     </fieldset> <% } %>  <div>     <%: Html.ActionLink("Back to List", "Index") %> </div> 

And have used Data Annotations:

[DataType(DataType.Text)] [DisplayName("Owner")] [Required] [StringLength(60)] public string Owner { get; set; } 

I'm also using Entity Framwork 4.0.

Does anyone have any idea why my page is still posting back?

Many Thanks


Adding Include Files to the Add Controller T4 Templates in ASP.NET MVC


is there a way to programatically set a filter in jquery jqgrid?
This is consistent with behavior I've been receive ting in ASP.NET MVC since I started using it over a year ago. MVC utilising WCF I haven't actually tried the RTM of 2.0, although I'm hearing this it's the same there as well- the client side validation emitting just doesn't work.. Which strategy to choose for building web based business application This thread here addresses the issue, and suggests you receive the scripts from MVC Futures, which I've also seen before. ASP.NET MVC output cache with dynamic fragment. Redirect site from to in mvc This link might also help: Jquery thickbox to work with Url.Action link in mvc That link above leads to an article this suggests you use the CDN versions of the scripts. Structuring several mostly-static pages in ASP.NET MVC I haven't tried this yet- it might job better for the reason this you're guaranteed to receive a current, supported script..

68 out of 100 based on 53 user ratings 728 reviews