.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Client validation, scrollTo override...

Posted By:      Posted Date: August 27, 2010    Points: 0   Category :ASP.Net

Using VS2005 (.NET 2.0), VB code behind,

I have a page with several required field validators + validation summary control(s). As noted in this post - when the client side validation runs the page gets scrolled to the top (window.scrollTo(0,0)). To change this behavior I implemented the second suggested alternative - I placed the following code at the bottom of my page:

    <script type="text/javascript">
        //Redefine the the window.scrollTo during the ValidationSummaryOnSubmit execution to avoid
        //  having the page scroll to the top...
        //  adapted from:http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=299399
        var ValidationSummaryOnSubmitOrig = ValidationSummaryOnSubmit;
        var ValidationSummaryOnSubmit = function() {
            var scrollToOrig = window.scrollTo;
            window.scrollTo = function() {}; //override with todo nothing
            var validationGroup = null;
            if (arguments.length>0) { //check for optional parameter
                if (arguments[0]) {
                    validationGroup = arguments[0];

View Complete Post

More Related Resource Links

JQuery vs MS client validation


I have been trying both MicrosoftMvcJQueryValidation.js and MicrosoftMvcValidation.js.

The former does not support validation summarie, while the latter does.

Neither one of them seems to be able to deal with System.ComponentModel.DataAnnotations.DataType markings on the client side. It somewhat defeats the purpose of having the attributes on the server side. I know the validation on the server side works, but I need it to work on the client too.

Is there an easy way to make the client side validation for that work?

Are there any updates to these javascript libraries that I am may not be aware of?

sslstream client certificate validation error

Hi,I have taken server and client program from MSDN2 for sslstream. in that code client certifiacte authetication is made false  i want to enable that and do the code i have done some modification to the code but is giving error "RemoteCertificateNotAvailable" and i think that its not getting the client certificate at server side.So please can any one help me to do client server program using sslstream in which client certificate also needs to be validated.I am attaching my modified code of MSDN2Server sideusing System;using System.Collections;using System.Net;using System.Net.Sockets;using System.Net.Security;using System.Security.Authentication;using System.Text;using System.Security.Cryptography.X509Certificates;using System.IO;namespace Examples.System.Net{    public sealed class SslTcpServer     {        static X509Certificate serverCertificate = null;        // The certificate parameter specifies the name of the file         // containing the machine certificate.        // The following method is invoked by the RemoteCertificateValidationDelegate.        public static bool ValidateClientCertificate(              object sender,              X509Certificate certificate,              X509Chain chain,              SslPolicyErrors sslPolicyErrors)        {            SslPolicyErrors errors = sslPolicyErrors;            if (errors != SslPolicyErrors.None)            {

CheckBoxList client-side validation

How can I validate on client side if a CheckBoxList has at least one item? (is not empty)

Data Annotation not triggering the client side validation when used on an overriden model property

Hi all, This is a saga from a post that was recently answered:http://forums.asp.net/t/1598187.aspxMy main problem is the lack of client side validation when we use a child model class, the server side validation works like a charm whether you use the virtual/override solution or the new attribute on the child class with the getter and setter linking the property to the base class's one.The client side validation does not work with none of the solutions presented below.This is a sample code of the first solution: [Serializable] public class DateViewModel { ... [Display(typeof(App_GlobalResources.Messages), "Date_Year")] public virtual int? Year { get; set; } ... } [Serializable] public class BirthDateViewModel : DateViewModel { ... [Display(typeof(App_GlobalResources.Messages), "Date_Year")] [YearRange(ErrorMessageResourceType = typeof(App_GlobalResources.Messages), ErrorMessageResourceName = "Validation_Range")] public override int? Year { get; set; } ... } This is a code sample of the second solution : [Serializable] public class DateViewModel { ... [Display(typeof(App_GlobalResources.Messages), "Date_Year")] public int? Year { get; set; } ... } [Serializable] public class BirthDateViewModel : DateViewMod

Client side validation using Client OM in sharepoint 2010

Hi, Can we use Client Object Model for Client side validation? Suppose, i have a SharePoint 2010 List. While adding a new item in that list, i want to check for Title is already available or not, person has posted any item earlier or not..that kind of stuff. Could i check this at client side rather than ItemAdding Event, so that i can reduce the network traffic? Thanks in advanced. Hardik Shah Solution Developer.

Event receiver validation client message


Is thera a way to display a client message if validation sets. (java script or inline validation error message)

properties.Status = SPEventReceiverStatus.CancelWithError;

properties.Cancel =



properties.ErrorMessage =


Client Side Validation with jQuery


I have used client side validation with Ajax before.  Now I need to do client side validation with jQuery.

I am referencing jQuery 1.4.2 and jQuery.validation version 1.7.

I have added <% Html.EnableClientValidation(); %> to the view.

I have added Html.TextBoxFor and Html.ValidationMessageFor to the view.

Client side validation still does not work.

If I understand correctly, I also need to include MicrosoftMvcJQueryValidation.js.  This file was not installed with VS 2010 ultimate.  I have heard that it is available on the Futures project, but the links to the site are broken.

Do I need MicrosoftMvcJQueryValidation.js to make client side validation work?

If so, where do I find the current version of MicrosoftMvcJQueryValidation?  Why isn't it readily available for download or included with VS 2010?

If not, what do I do next to get client side validation to work?

I know that I could manually add calls to jQuery validation, but that is far from ideal - especially since the Ajax v

MVC2 client validation with jquery dialog


i am trying to get mvc2 client validation working with a jquery dialog, i have pretty much been using the mvc music store example at http://www.asp.net/mvc. if i go to http://localhost/Build/Edit/11, client validation works, but it will not work in the jquery dialog. any ideas?

ViewActive.aspx - main page with a link to popup a form


function showModalEdit(id) {

            var $loading = $('<img src="<%= Url.Content("~/Content/Images/ui-anim_basic_16x16.gif") %>" alt="loading"/>');

            var $dialogEdit = $('<div id="dialogEdit"></div>').append($loading.clone());



                height: 768,

                width: 1024,

                autoOpen: false,

                title: "Modify Build",


client ip during custom user validation


There are a lot of similar questions on this forum but there is no exact one.

i try this

public class CustomUserValidator : UserNamePasswordValidator
   public override void Validate(string userName, string password)

OperationContext context = OperationContext.Current;
MessageProperties messageProperties = context.IncomingMessageProperties;
RemoteEndpointMessageProperty endpointProperty = messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
return endpointProperty.Address;



but OperationContext.Current is null in current context ...

Could somebody help me ?

IDataErrorInfo client side validation


Is there a way for client side validation while using IDataErrorInfo?

MVC3 : Validation parameter names in unobtrusive client validation rules must start with a lowercase


I am migrating my application to MVC3 and getting this error message

Validation parameter names in unobtrusive client validation rules must start with a lowercase letter and consist of only lowercase letters or digits.

How can I ovoid it without going and modifying all my ViewModels

Tank you for your help 

Client-side validation confusion


There are three dropdownlists on one of the Views in my MVC application. If I try to submit the form before they have values, I get error messages for each, stating that they're required fields and they have the red border applied. All that is well and good, except that I don't have them marked with required attributes! Now I'm very confused as to where the rule is being applied, but haven't been able to track it down. Here's the View:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DSC.Data.Model.Admin.UserMgmt.AddNewUserContainer>" %>

<% using (Html.BeginForm("AddNewUser", "UserMgmt", FormMethod.Post)) { %>
                NT Login:
                <%: Html.HiddenFor(nt => nt.UserToAdd.NTLogin) %>

                <%: Model.UserToAdd.NTLogin %>
                First Name:
                <%: Html.EditorFor(model => model.UserToAdd.FirstName) %>
                <%: Html.ValidationMessageFor(model => model.UserToAdd.FirstName) %>

Client Side Validation - suppressing specific property errors


Hi there,

I have implemented some Client Side Validation in MVC via <%Html.EnableClientValidation(); %> I am using Metadata Descriptions an EF and it's working fine but one thing is driving me crazy!!

I have a Price field that is a number (double) and I have some metadata errors for it for range and required but MVC is adding in this validation "The field Price must be a number." which would be fine except!! when I type 20.     (note the decimal point) this validation fails with a popup "The field Price must be a number." then when I type another number e.g. 20.0 it goes away again.

Is there some way to ignore/suppress non custom property validation errors??



Client certificate validation fails in TransportWithMessageCredential


We have a windows client connecting to a Windows service calling a WCF Service. We need client certificate validation along with client username/password validation. However setting sbe.RequireClientCertificate = true; in the service gives a connection timeout error and by not setting it, the custom certificate validator is not called.  Also if code to assign certificate in client logic is commented there is no exception thrown. I need a validation for certificate as well as message (UserName/Password). Can you please help? I am attaching the code below:

Service code:


 WCFSettings settings = new WCFSettings();



                    _serviceHost = new ServiceHost((typeof(GDService)));

                    EndpointAddress epAddr = new EndpointAddress(settings.EndpointAddress);



ASP.NET validation controls are removing client event handlers.


 Below is a tiny section of code to highlight a problem that I am currently having. The textbox has an onblur event (the workings of the onblur event are irrelevant), and an associated RequiredFieldValidator. This code functions exactly as it should. However, if in the body onload event I simply raise an alert of the innerHTML of tr1 or td1, the onblur event does not appear (but it does work, and can be seen when I view source in IE7). If I remove the RequiredFieldValidator, the onblur event handler is shown in the alert, or if I retain the validator but change onblur to onfocus, then the event handler also appears in the alert. I need this to work as when the user increases the Quantity, duplicates of the table row are added (I have tried both cloneNode, and setting the innerHTML of each new table cell to that of the original, but as my alert proves, the onblur event handler is not included in what is copied). The same problem also occurs with onchange for select tags with validators. I am using Visual Studio 2008 (.Net 2), IE7 and IIS 7.

<tr id="tr1" /> 
  <td id="td1" />Quantity <input id="txtQuantity" onblur="fnBlur(this)" type="text" maxlength="2" value="1" runat="server" />   
 <asp:RequiredFieldValidator id="reqQuantity"

Client side validation while "OK" button clicked in list in sharepoint 2007


Hi All,

while saving data to a list in sharepoint all the validation are server side ,can i do it client side in sharepoint 2007

Thanks and Regards Er.Pradipta Nayak

Client-Side validation errors but I don't know what they are?





I am using the jquery unobstrusive client-side validation for my "Create" form, and it is returning errors but I don't know what they are.


I put a ValidationMessage helper on each control on my Create, but the POST is getting canceled and I don't know why.  ValidationSummary is not filled out so I don't know how to troubleshoot the issue.

How do I go about troubleshooting it?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend