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: http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx

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


Create

<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

Ted


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

1:

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. Asp.net 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 www.a.com to a.com in asp.net mvc This link might also help: http://blogs.msdn.com/b/rickandy/archive/2009/10/03/client-side-validation-for-mvc-2-p2.aspx?wa=wsignin1.0. Jquery thickbox to work with Url.Action link in Asp.net 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

^