.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

custom validator firring on text changed

Posted By:      Posted Date: September 21, 2010    Points: 0   Category :ASP.Net

hi all i have a custom validator i have written a javascript method for this validator;

this validator has been pot on a textbox that has auto post back is true .... now this validation  fires when the post back happens...

i dont want it to fire on the post back but only on button click

please suggest 

thanks in advance 


View Complete Post

More Related Resource Links

Custom Validator


I need to validate a field that depends from a selection of a dropdownlist.

Like, if on dropdown the selected value is 'N' then validate. But it it's 'S', ignores validation;

Is there a way to do this with custom validator ??

I tried but, it's not working.

function chkEndereco(source, args){
   var cmbOnde = $('select[id$=comboOnde]');
   if(cmbOnde.val() == 'N')
      args.IsValid = (args.Value == '')
   if(cmbOnde.val() == 'S')
     args.IsValid = true

<asp:TextBox ID="Endereco" name="endereco" runat="server" AutoCompleteType="none" autocomplete="off" />
                                    <ajaxToolKit:TextBoxWatermarkExtender ID="wmEndereco" runat="server" TargetControlID="Endereco" WatermarkText="Endereço (rua, avenida, etc)" />
                                    <asp:RequiredFieldValidator ID="rqEndereco" runat="server" ErrorMessage="Ops! Faltou o endereço." EnableClientScript="true" ControlToValidate="Endereco" Display="None"/>
                                    <asp:CustomValidator ID="crqEndereco" runat="server" ErrorMe

Creating a Validator class for a custom activity

I created a new Workflow Activity Library and then added a new Activity called BindForm2Activity. After that I added a new class called BindForm2Validator and then placed an attribute to the BindForm2Activity to link it to the validator class.   Here is the code for each of the classes:   BindForm2Activity.xoml.cs: Code Snippet   using System;using System.ComponentModel;using System.ComponentModel.Design;using System.Collections;using System.Drawing;using System.Linq;using System.Workflow.ComponentModel.Compiler;using System.Workflow.ComponentModel.Serialization;using System.Workflow.ComponentModel;using System.Workflow.ComponentModel.Design;using System.Workflow.Runtime;using System.Workflow.Activities;using System.Workflow.Activities.Rules; using FormsCollection;using Utils; namespace ActivityLibrary{    [ActivityValidator(typeof(BindForm2Validator))] public partial class BindForm2Activity : SequenceActivity {        public static DependencyProperty FormToBindProperty = System.Workflow.ComponentModel.DependencyProperty.Register("FormToBind", typeof(FormsCollection.Form2), typeof(BindForm2Activity));         [Description("Form to bind a datasource to it ")]        [Category("BindForm2ToDataSource")]        [Browsable(true)]        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]        public FormsCollection.Form2 Form

custom validator

Is it possible to pass the maximum character length to validateCharacter, rather than just have it set in stone.<asp:CustomValidator ID="ValCharacter" ControlToValidate="txtCharacter"  OnServerValidate="validateCharacter"  Text="Too many characters" runat="server" Display="Dynamic" />        Protected Sub validateCharacter(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)        Dim iChars As Integer = 500        If args.Value.Length > iChars Then            args.IsValid = False        End If    End Subthanks.

Custom Validator on DDL&Textbox values

I need to write a 2 custom validators that works as follows: I have a formview (Formview1) with an EditItemTemplate. The validators need to validate values in "DropDownList1" and a textbox called "EndUserGUIDTextBox" If the value in DDL1 is ("Assigned" or "Assigned to End User") and the value of EndUserGUIDTextBox is ("unassigned" or "pending" or NULL) then I need a validator to fire and return {"GUID must be assigned when status is" & DLL1 value}. If the value in DDL1 is ("In Stock" or "In Repair") and EndUserGUIDTextBox is NOT ("unassigned" or "pending" or NULL), then I need a validator to fire and return {"GUID must not be assigned when status is" & DLL1 Value}. The validators needs to run and show in the formview when the UpdateButton in my Formview is clicked. I'm doing this in VB. Real noobie here! All help appreciated. Thanks,

Raise OnPropertyChanged event when Text Box Text has changed

Hi there I have a Wrapped Text Box that is bound to a Public String Property. I have a related OK Button that should be Enabled when the text changes to indicate there are 'items' in the Text Box. The problem is that the set accessor of the property (and thus OnPropertyChanged) is not being called until focus is lost from the text box - and I would like the Ok Button to be enabled before then. What is the the best way to raise the set when the Text Box text has changed? (A List Box is not an option) Thanks very much Joe

Wave to Text - Need help with custom grammar

I created a wav to text conversion using a ISpeechRecoContext and it works, but it is not precised. I was hopping to add a custom grammar to it but im not sure how to. Any ideas? Here is a WPF MainWindow.xaml.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Microsoft.Win32; using SpeechLib; namespace WaveToText { public partial class MainWindow : Window { private ISpeechRecoContext WaveRecognizer = null; private SpFileStream InputWAV = null; private ISpeechRecoGrammar Grammar = null; public MainWindow() { InitializeComponent(); } private void ExitButtonClick(object sender, RoutedEventArgs e) { this.Close(); } private void ConvertButtonClick(object sender, RoutedEventArgs e) { ResultTextBox.Text = ""; OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = "Select a Speech file"; dialog.Filter = "Wave Files (.WAV)|*.wav"; // Filter files by extension dialog.InitialDirectory = Environment.CurrentDirectory + "\\Content"; Nullabl

Custom Validator inside PasswordRecovery...

Hello,   I am using a PasswordRecovery Control and have changed one of the validators to a custom Validator, however, OnServerValidate neer seems to get called.   Can someone tell me how to get the OnServerValidate to work correctly?   Thanks.

Can't Get Text From Custom Wizard Step


I'm trying to get the text values from each textbox in a custom created createuserwizard step however i keep returning null for each textbox however the default step & text boxes (ie. UserName, Password, Email, etc, etc) i can get the text value with no problem



            <asp:WizardStep ID="CreateUserWizardStep0" runat="server">

Implementing custom ValidationFor to show an error icon with a tooltip instead of just text for c


I got the problem that my implementation (see source below) only shows the validation error message after server side validation an NOT

after clientside validation! My questions is, how can you extend or implement to show the validation error message also on client-side validation.

Unfortunately I have not found any other info source about this subject, so any help will be very much appreciated!

 public static string ErrorMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression)
            string modelName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(ExpressionHelper.GetExpressionText(expression));
            FormContext formContext = htmlHelper.ViewContext.FormContext;

            if (!htmlHelper.ViewData.ModelState.ContainsKey(modelName) && formContext == null)
                return null;

            ModelState modelState = htmlHelper.ViewData.ModelState[modelName];
            ModelErrorCollection modelErrors = (modelState == null) ? null : modelState.Errors;
            ModelError modelError = ((modelErrors == null) || (modelErrors.Count == 0)) ? null : modelErrors[0];

            if (modelError == null && formContext == null)

jquery - span text changed event


is there a jquery event that is fired when the text of a span element is changed? The change event does not apply to <span> elements. I see reference to "text changed", but $('#PriceCond').bind('textchange', function(event, prevText) { ... }) ; does not work either.



     <input type="button" id="TestButton" value="Test" />

     <span id="PriceCond"></span>

<script type="text/javascript">
  $(document).ready(function ()

    var clickFunc =
          function ()
            var s1 = $('#PriceCond').text();
            $('#PriceCond').text(s1 + 'x');

    var priceChangeFunc =
          function ()
            alert('in priceChangeFunc');





ASP.NET MVC2 Custom routing with wildcard or free text url


I have a requirement to add specific functionality to an asp.net mvc2 web site to provide addtional SEO capability, as follows:

The incoming URL is plain text, perhaps a containing a sentence as follows

"http://somesite.com/welcome-to-our-web-site" or "http://somesite.com/cool things/check-out-this-awesome-video"

In the MVC pipeline, I would like to take this URL, strip off the website name, look up the remaining portion in a database table and call an appropriate controller/view based on the content of the data in the table. All controllers will simply take a single parameter bieng the unique id from the lookup table. A different controller may be used depnding on different urls, but this must be derieved from the database.

If the url cannot be resolved a 404 error needs to be provided, if the url is found but obsolete then a 302 redirect needs to be provided.

Where the url is resolved it must be retained in the browser address bar.

I have had a look at the routing model, and custom routing and can't quite work out how to do it using these, as the controller would not be predefined, based on a simple route. I am also unsure of what to do to provide 404, 302 back to the headers also. Perhpas I need a custom httpmodule or similar but going there went beyond my understanding.

This must be possible someho

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?



How can I add a SharePoint Rich text editor in my custom application page?


I want to have a richtext editor in my custom application page.

Can I use the richtext editor  bulit-in in SharePoint?

I tried add this code in my aspx but it doesn't render the control but throw a error

<SharePoint:RichTextField ID="DefaultValue" runat="server" ControlMode="New" FieldName="Title"></SharePoint:RichTextField>

Anyone helps?

Custom Validator



I have a C# web form (within a master page) and textbox - how do I validate it so that any input has to have a "AR" or "BR" prefix. I have started something along these lines:

                ARF Number
                <asp:CustomValidator ID="ValidatorArf" runat="server" ErrorMessage="PMO Ref!" ClientValidationFunction="jSValidate"
                    ControlToValidate="TextBoxArfNo" ValidationGroup="ValidationGroupCreateDesign"></asp:CustomValidator>
                <asp:TextBox ID="TextBoxArfNo" runat="server" MaxLength="50" />

Is this the best way forward? How do I write the validation script?

Thanks in advance!

Small problem with displaying custom calendar cell text from db in Safari


using VS2010

I'm using the calendar control to create a simple event calendar. I want to add a small bit of custom text just below the date of any cell that contains an event on that date.

The code:

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
      string connString = ConfigurationManager.ConnectionStrings["CalendarConnectionString1"].ToString();
      SqlConnection myConnection = new SqlConnection(connString);
      SqlDataAdapter myAdapter = new SqlDataAdapter("GetEvents", myConnection);
      DataSet myDataSet = new DataSet();
      myAdapter.Fill(myDataSet, "Table");
      //If the month is CurrentMonth
      if (!e.Day.IsOtherMonth)
        foreach (DataRow dr in myDataSet.Tables[0].Rows)
          if ((dr["Date"].ToString() != DBNull.Value.ToString()))
            DateTime dtEvent = (DateTime)dr["Date"];
            if (dtEvent.Equals(e.Day.Date))
              e.Cell.BackColor = Color.MediumAquamarine;
              Label label = new Label();
              label.Text = "</br>";
              label.Text += dr["Title"].ToString();              

Removing standard text from custom feedback process email notification


My workflow has a Start Feedback Process action, which contains some pre-defined instructions. One of my instructions is to use a particular link to open the workflow history page – I have added this to force the user to open the form via the workflow history page (we're using Forms Services) because the email’s default link opens the form in the InfoPath client, not the browser. It also allows the user to be returned to the page where they will complete their workflow task (we're trying to make navigation as easy for them as possible).

Although I have defined my own set of instructions, the email notification I receive includes some standard text that links to the InfoPath form’s xml file. I don’t want users inadvertently clicking the “To complete this task…” link at the bottom of the email and having the form open in InfoPath. Here is an example of the email I’m referring to:


gridview sort on changed cell text


I have a gridview that is being databound by an SQLdatasource and on  RowDataBound i am doing a calculation and then setting


e.Row.cells(17).text = Result


However, when I go to sort it on the website it sorts it based off the previous values.


Cell(17) from the datasource reads in all 1's. The numbers I change it to range from 0 to 15. So when I click sort nothing changes because it sees it as all 1's.

How can i make the gridivew sort off the changed text values?

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