logo
down
shadow

Data Validation not working in Edit Mode


Data Validation not working in Edit Mode

By : ketan
Date : November 22 2020, 10:33 AM
this one helps. It seems that you are following the wrong approach
let us assume we have a class called users like following
code :
public class User: IValidatableObject
{
     public int Id{get; set;}
     public string UserName{get; set;}
     public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
     {
          if(string.IsNullOrEmpty(UserName))
               yield return new ValidationResult("Username field is required!", new string[]{"UserName"});
          else 
          {
               // check if another User has the same username already
               var db= new YourDbContext();
               var exists=db.Users.FirstOrDefault(t=>t.Id!=Id && t.UserName.ToLower()=UserName.ToLower());
               if(exists!=null)
                   yield return new ValidationResult("Username is already used by another user!", new string[]{"UserName"});
          }
     }
}


Share : facebook icon twitter icon
Datagrid Edit mode and data validation via service

Datagrid Edit mode and data validation via service


By : user3728649
Date : March 29 2020, 07:55 AM
hop of those help? (sorry for my bad english) I would recomend that you do not use the grid event to validate your data - do this on your POCO properties setter - its cleaner, easier to mantain and if you use this POCO with another control your validation will still work.
Since you need to access a service to validate the value, your best bet is to implement the interface INotifyDataErrorInfo, that allows you to make asynchronous validation, look here: http://weblogs.asp.net/fredriknormen/archive/2009/11/22/silverlight-4-and-asynchronous-validation-with-inotifydataerrorinfo.aspx and here http://www.silverlight.net/learn/data-networking/validation/asynchronous-data-validation
Jqgrid custom edit mode and validation

Jqgrid custom edit mode and validation


By : Nathanjoshua24
Date : March 29 2020, 07:55 AM
around this issue You can validate the form fields in the beforeSubmit function. In this function you can validate the fields and add the highlight class to the element you want. You can do something like this:
code :
beforeSubmit: function(postdata, formid){ 
       //more validations
       if ($('#exec').val()==""){
                $('#exec').addClass("ui-state-highlight");
                return [false,'ERROR MESSAGE']; //error
      }
      return [true,'']; // no error
 },
How to exclude a perticular field from unique validation in edit mode in cakephp3.0 validation

How to exclude a perticular field from unique validation in edit mode in cakephp3.0 validation


By : user6349560
Date : March 29 2020, 07:55 AM
like below fixes the issue I want to validate a field called survey_id which is an input from user for uniqueness. It is working properly and giving the correct response when adding the new record, but when I tried to edit this record it is giving an error [unique] => Provided value already exist. So what I want is to exclude the survey_id of the current record from uniqueness check and if user input some other value for survey_id it should check for uniqueness search. , It will work with this validation rule
code :
$validator
        ->requirePresence('survey_id', __('msg_required'))
        ->notEmpty('survey_id', __('msg_required'))
        ->maxlength('survey_id', 32, __('msg_maxlength'))
        ->alphaNumeric('survey_id', __('msg_surveyid_format'))
        ->add('survey_id', 'custom', [
            'rule' => function ($value, $context) {
              if (!empty($context['data']['projectId'])) { $values = array($context['data']['projectId']); } else { $values = array(); }
              $data = $this->getSurveyId($value, $values);
              return (!empty($data)) ? false : true;
            },
              'message' => __('msg_surveyid_exsist')]);

        return $validator;
      }

public function getSurveyId($surveyId = null, $exclude = null) {

        $where = array('p.survey_id' => $surveyId);
        if (!empty($exclude) && is_array($exclude)) {
          $where[] = array('p.id NOT IN' => $exclude);
        }
        return $this->db->newQuery()
                        ->select('*')
                        ->from(['p' => 'projects'])
                        ->where($where)
                        ->execute()
                        ->fetch('assoc');
      }
Kendo validation message in inLine Edit mode kendo grid not working through Data annotation

Kendo validation message in inLine Edit mode kendo grid not working through Data annotation


By : Cuong Phong
Date : March 29 2020, 07:55 AM
I wish did fix the issue. For the validations to work for the columns using Editor Templates you need to add the following in your Editor Templates
.HtmlAttributes(Html.GetUnobtrusiveValidationAttributes("Validation",
code :
    (Html.AthenaTransportDdl("GetPricingPolicyTypes", "Enterprise", HttpVerbs.Post)
        .Name("PricingPolicyType")
        .DataTextField("Label")
        .DataValueField("Id")
        .AutoBind(false)
        .Filter("contains")
        .HtmlAttributes(Html.GetUnobtrusiveValidationAttributes("Validation",     
           ViewData.ModelMetadata))  
.OptionLabel(Html.GetResource(AthenaWeb.Models.Common.XmlResourceNames.CommonXml, "PricingPolicyTypeOptionLabel"))
    )
Excel VBA data validation swap only working in debug mode

Excel VBA data validation swap only working in debug mode


By : Mogtan Mog Tan
Date : March 29 2020, 07:55 AM
like below fixes the issue for the input here everyone. It appears that excel 2013 has had an issue with the kind of list name that goes into these combo boxes for data validation. I used the solution here:
http://blog.contextures.com/archives/2014/09/18/worksheet-combo-box-problem-in-excel-2013/
Related Posts Related Posts :
  • Stop Continuation Task upon exception thrown from parent task
  • Is there a way to make msbuild write error output to stderr?
  • Unit testing: TDD with POCO Objects with navigation properties (relationship fixup)
  • GridSplitter disables my RowDefinition style
  • Memory leak only in Release mode
  • how to read specified string from url
  • how to store html code EMail template in a string variable or textbox c#
  • Set Selected Date to TimePicker wpf (TimePickers inside DataTemplate)
  • How to draw line in Silverlight Specifying Height?
  • Stored procedure executes but does not update data
  • ASP.NET ListBox Trouble
  • Why does C# also not allow empty conditions in while loops?
  • Unable to get a block of code into my regex match groups
  • What is difference between dbcontext.Add and dbcontext.AddObject
  • How do I update the file version number of C# DLL without recompiling?
  • Value for html control always null
  • HttpClient hangs when timeout is setting (Windows Phone)
  • Handle Multiple Form tag in asp.net page?
  • create word document with html content in c#
  • Confusion about Find And Replace
  • Format sms messages in Clickatell
  • Automated Function Overload
  • String to date in MS Access SQL statement gives type mismatch error
  • ShowDialog exiting on certain events
  • Is there a try Convert.ToInt32... avoiding exceptions
  • How to move wpf application into minimize tray at Window Start-up C#?
  • How to change display format of long variable?
  • How to use Addfields in MongoDB C# Aggregation Pipeline
  • MsTest TestCleanup method not called when an unhandled exception is thrown
  • missing last data when exporting gridview to excel
  • How to add array of objects to List in c#
  • Lambda Expression to order (sort) my list collection
  • Library for displaying music notation
  • How to compare two dictionaries in c# and get the output as True and False after validation
  • specify fields to be serialized with JSON
  • How do you obtain the content of a specific node using XmlDocument in C#?
  • How to ignore the first line in a csv file when you read the csv file in C#
  • c# - Problem calling public void from class
  • How to tell a class which objects it should create? Type vs. object confusion :(
  • Save CheckBox state to xml
  • WIX CAQuietExec NETSH Command Fails
  • Issues sending http put request every 60 seconds to RoR app
  • ConfigurationManager.ConnectionStrings.ConnectionString Issue
  • Real size WPF controls for printing
  • How to cancel properly?
  • C# String multiplication error
  • Using Solrnet and Assigning Attributes with Entity Framework Generated POCOs
  • Regex pattern for single backslash
  • TextBox: insert spaces for credit card number?
  • C# DLL loaded for exe-application is not found when launching similar DLL by rundll32.exe
  • Debug a Windows Service with WCF library
  • Open a file from an external assembly?
  • Servicestack RegistrationFeature Unable to bind request
  • Index was outside the bounds of the array confusion
  • Error in Xml to List code. The ':' character, hexadecimal value 0x3A, cannot be included in a name
  • I am trying to do a while loop with a string conditional statement in C#
  • C# 'Cannot access a disposed object. Object name: 'SslStream'.'
  • How to make Gecko use seperate CookieContainer per instance?
  • C# Advanced form "please wait"
  • Send and Receive data C# using network stream
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org