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

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

Compare Validator not displaying message after postback

Posted By:      Posted Date: October 07, 2010    Points: 0   Category :ASP.Net

Hi all,

I have compare validators that I build on the fly in code behind that validate textboxes that are also built up in the code behind:

CompareValidator CV = new CompareValidator();
CV.ID = "CV" + parameter.Name;
CV.Type = ValidationDataType.Date;
CV.Operator = ValidationCompareOperator.DataTypeCheck;
CV.ErrorMessage = "* Invalid date";
CV.Display = ValidatorDisplay.Static;
CV.ControlToValidate = parameter.Name;
CV.ValidationGroup = "valGroup1";
CV.Style["font"] = "Arial";
CV.Style["color"] = "Red";
CV.Style["font-size"] = "10px";
CV.EnableClientScript = true;


These work fine until a postback occurs. After a postback they still validate the form (i.e. they don't let you postback) but the error message won't display. Can anybody please help?


View Complete Post

More Related Resource Links

Set up a validator that compare the value of the current field with an other (using Dynamic Data)

Hi! Most of it is in the title : I'd like have a validator on the DateTime_Edit template for example that allows to compare this field with an other DateTime field. My problem is when I am in the DateTime_Edit template of my "master field" (the one I want to check), how can I access to the other field given the architecture of Dynamic Data FieldTemplates? But perhaps I'm not thinking in a good way on this control. Any advice will be welcome. Thanks Raphaelp

displaying error message - Telerik MVC grid - AJAX mode

I want a common solution for handling error messages ON telerik mvc grid in ajax inline and popup edit modes. I am not talking about error messages that are related to single input field. These are business error messages that come back to grid from DB upon clicking grid edit or insert buttons. I want to dispaly error message and not loose data in input fields, bcaz in some cases we are talking about more than 20 fields. 1) I want to know the best way to handle error messges received from backend while using telerik mvc grid. 2) Is it possbile to display error message in a message dialog box?

Locking Page with progress message on postback

I have implemented a lockscreen based on the following articlehttp://www.4guysfromrolla.com/articles/121708-1.aspxIt does work for the most part but there are a couple of scenarios it causes issues and we ended up having to disable it.  Here is one example where it has issues.With a button on a page clicking the button calls the javascript to "lock" the screen with an overlay and show the progress message.In the button click I have the following code Response.ClearContent() Response.ContentType = "application/pdf" Response.AddHeader("content-disposition", "attachment;filename=TestFile.pdf") Response.WriteFile(Server.MapPath("TestFile.pdf")) Response.Write(Date.Now.ToLongDateString() & " " & Date.Now.ToLongTimeString()) Response.End() which will display the file download dialog box which is what I want.  What happens though is that my lock screen stays on in this scenario because with my button click code I'm overriding the response.  Is there an easy way around this?  The only way I have figured out is have my button click write out some javascript to open a new window that calls a .aspx page which has the button click code shown above in it to write out the file or have an invisible iframe on the page and load the .aspx with the button click code shown above.  Any other way ar

How to use compare validator with dd/MM/yyyy format of date

Hi all,  I have a form of leave application that has 2 dates, start date and end date. now i'm using the dd/MM/yyyy format for the date entry and i need to Validate end date like end date must me greater than or equal to start date. i want to do that with compare validator but its not working properly because of the Date  formats controls are using.    Currently i'm using textbox with Calendar extender ajax toolkit control.    So please help me if anybody have some hints.    Thanks in advance.

how to apply styles on the message displayed by asp.net required field validator control?

 Hi,I want to apply styles on the message (i.e. Name field is required) display by the asp.net required field validator control.Styles=border, padding, background-color, font-color, font-weight, img etcAnd I also want highlight the border or asp.net textbox and asp.net dropdown list with which this control is associated.  RequiredFieldValidator does not have style property !Can anyone let me know how can I do this???Regards,Dazy

displaying message for showing girdview records


i am using asp.net gridview control and i have Eight thousand records, than i am using paging techniquies on each page 10 records displayed now i want to display message YOU ARE VIEWING RECORD FROM 0 to 10 OUT OF 8000

when i jump page number second than message displayed YOU ARE VIEWING RECORDS FROM 10 TO 20 OUT OF 8000

Custom Validator and Postback


Hello frnds

I have used custom validator in my asp.net website

I am using server side validation 

my page contains a textbox (txtName), and 2 combobox (CmbState and CmbCity) and some more controls

Now i want to validate my page using custom validator only when save button is clicked.

one of my combobox has implemented SelectedIndexChanged event. so whenever i change a value in that combobox, instead of firing SelectedIndexChanged event, my validation is fired and it is displaying error message of custome validator.

i want to do validation only when save button is clicked and not when postback is done by any of my controls on that page.

How can i do this? is there any way to do this?



Compare validator type nvarchar


Hello  i am using sql datasource to fill my 2 dropdownlist 


first dropdownlist1                                  Second Dropdownlist2

       week1                                                    week1

       week2                                                    week2


can anyone help me please - validator in modal popup prevent my button from postback


i have a very strange problem

for some reasons
i m forced to use the following solution

i have a situation that includs
a validation control
inside a usercontrol
that is loaded on the page using a modalpopup
when i click a button from inside a gridview

the problem is that the button inside the modalpopup
never fire the server code behind
as if the validator prevent it from doing so

my example website is uploaded here


anybody help me please


Compare validator /Range validator does not work while using localization



I have a requirement of converting existing english form to multi lingual form.I am currently converting english form to spanish form.

Everything works except the date formats.

The range validator is not working in a spanish form but works in a english form.

I have set the maximum and minimum value in page load as below in the english form

Heres how i have set the values

rndateval.MinimumValue = DateTime.Now.AddYears(-50).ToShortDateString();

rndateval.MaximumValue = DateTime.Now.AddDays(20).ToShortDateString();

But the range validator does not work

Please help me in resolving the issue .

Compare validator in a Gridview EditItemTemplate


I am trying to use a compare validator in the EditItemTemplate for the Gridview.

I would like to set the Maximum value for the validator at runtime e.g. Page_Load


Is there a way to set the Maximum value for a "Template field" dynamically at load time


Snippet of code:

 <asp:TemplateField HeaderText="Birth Year" SortExpression="MemberBirthYear">
                           <asp:TextBox ID="eitMemberBirthYear" runat="server" CssClass="eitField"
                              Text='<%# Bind("MemberBirthYear") %>' Width="60px"></asp:TextBox>
                           <asp:RequiredFieldValidator ID="Re

Compare Validator Problem?



I would like to compare a textbox against a value. I want to show validatorcalloutextender if value in Textbox lessthan specific value in validator.Here is the code:

<asp:CompareValidator ID="CompareValidator3" runat="server" ControlToValidate="TextBox2"
            Type="Double" ValueToCompare="1" Text='<img src="Images/validation_error.png">'

Compare Validator

I am using Compare Validator for Comparing Dates. But it doesn't work for MM/dd/yyyy format. It works for dd/MM/yyyy. Why so, as the US format for date is "MM/dd/yyyy" ? Also SQL Server saves dates in MM/dd/yyyy format by default. And why compare validator is working for dd/MM/yyyy? It should not work in both cases or it should work in both cases. Don't you think it should be fixed? Why to waste time for making Custom Validator?

Gmail internal chat like message box

This article provides you with the multi-functional message box window through which the usability of the web-site or any web application increases.

.Configurable MessageBox window with AJAX Support
.can set maximum number of message boxes to be visible
.can define the auto reload time, for single message, for all messages or no reload
.can create messages through a single function call
.can define auto hide time for each messages

Displaying SharePoint lists in Web Parts

When you create a built-in or custom list in Microsoft Windows SharePoint Services, Windows SharePoint Services creates a Web Part, a basic building block of a SharePoint site, to display that list. These Web Parts are called List View Web Parts. Windows SharePoint Services stores List View Web Parts in the site collection Web Part gallery. (The site collection Web Part gallery is the most central gallery of Web Parts for a work group. By default, the gallery name is the name of the site, such as "Our Team Site Web Part Gallery." )

jQuery $(document).ready() and ASP.NET Ajax asynchronous postback

Many call it the ASP.NET jQuery postback problem, but using the technique below should make it no problem anymore. $(document).ready() isn't called after an asynchronous postback. What this means? You lose the functionality that should be executed within $(document).ready() after an UpdatePanel rendered its contents after an asynchronous postback.

Displaying Row Details Tooltip on GridView using JQuery

Continuing exploring JQuery! I decided to implement a feature to display some kind of details related to a row displayed on GridView. For example when displaying employees details on GridView some information might not fit in the GridView because it will make it huge and wide. These infomration can be diplayed as Tooltip. Or when you want to display a picture and some kind of formated text to be diplayed as tooltip when mouse hover on the image.
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