To make config transforms work with NLog you need to modify the config transform file slightly.
Edit the configuration in the transform file:
Now you can transform the nlog section in your config file like this:
To make config transforms work with NLog you need to modify the config transform file slightly.
Edit the configuration in the transform file:
Now you can transform the nlog section in your config file like this:
1: $.validator.addMethod('personalid', function (value, element, params) {
2: // Check if the field is optional
3: if (this.optional(element))
4: return true;
5:
6: // Do some validation here (return true or false).
7:
8: return true;
9: });
2: function (options) {
3: options.rules['personalid'] = {
4: param1: options.params.param1,
5: param2: options.params.param2,
6: param3: options.params.param3
7: };
8: options.messages['personalid'] = options.message;
9: }
10: );
2: {
3: private const string DefaultErrorMessage = "Invalid {0}";
4:
5: public string SomeParam { get; set; }
6:
7: public PersonalIdentityNumberAttribute()
8: : base(DefaultErrorMessage)
9: { }
10:
11: public override string FormatErrorMessage(string name)
12: {
13: // "name" is DisplayName of the property being validated.
14: // ErrorMessageString is set in constructor.
15: return string.Format(ErrorMessageString, name);
16: }
17:
18: protected override ValidationResult IsValid(object value, ValidationContext validationContext)
19: {
20: if (value == null)
21: return ValidationResult.Success;
22:
23: // Do some validation here, return ValidationResult.Success or new ValidationResult() for error.
24:
25: return new ValidationResult(FormatErrorMessage(validationContext.DisplayName));
26: }
27:
28:
29: public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
30: {
31: ModelClientValidationRule clientValidationRule = new ModelClientValidationRule
32: {
33: ErrorMessage = FormatErrorMessage(metadata.DisplayName),
34: ValidationType = "personalid"
35: };
36: clientValidationRule.ValidationParameters.Add("someparam", SomeProperty);
37:
38: return new[] {clientValidationRule};
39:
40: }
41: }
1: [Required(ErrorMessage = "Required")]
2: [PersonalIdentityNumber(SomeParam = "foo")]
3: [Display(Name = "Personal Identity Number")]
4: public string PersonalIdentityNumber { get; set; }
1: <div id="RegistrationPanel">
2: @using (Html.BeginForm("Save", "Registration"))
3: {
4: <div class="editor-label">
5: @Html.LabelFor(m => m.Name)
6: </div>
7:
8: <div class="editor-field">
9: @Html.TextBoxFor(m => m.Name)
10: @Html.ValidationMessageFor(m => m.Name)
11: </div>
12:
13: <input type="submit" value="Register" />
14: }
15: </div>
1: public class RegistrationModel
2: {
3: [Required(ErrorMessage = "Required field")]
4: [DisplayName("Name")]
5: public string Name { get; set; }
6: }
1: <script src="@Url.Content("~/Scripts/jquery-1.6.2.min.js")" type="text/javascript"></script>
2: <script src="@Url.Content("~/Scripts/jquery-ui-1.8.16.min.js")" type="text/javascript"></script>
3: <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
4: <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
5: <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
6: <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
1: var Registration = (function () {
2: var form;
3: var submitButton;
4:
5: return {
6: Init: function () {
7: form = $('#RegistrationPanel form');
8: submitButton = form.find('input[type=submit]');
9: submitButton.button();
10:
11: // Get jquery validator object
12: var validator = form.data('validator');
13: // Hook into the jquery validator showErrors event
14: validator.settings.showErrors = function () {
15: var nrOfInvalids = this.numberOfInvalids();
16: var buttonVerb = (nrOfInvalids > 0) ? 'disable' : 'enable';
17: submitButton.button(buttonVerb);
18: this.defaultShowErrors(); // also execute default action
19: };
20:
21: form.submit(function () {
22: if (form.valid()) {
23: $.post(form.attr('action'), form.serialize(), function (jsonData) {
24: // Notify user about success
25: },
26: 'json');
27: }
28: return false;
29: });
30: }
31: };
32: })();
33:
34: $(function() {
35: Registration.Init();
36: });
1: offsetParent: $('#gbox_gridId')
1: <table id="gridId"></table>
1: $('#gridId').jqGrid({...});
1: <%=Html.LabelFor(m => m.xxx) %>
1: <Reference Include="System.Core">
2: <Private>True</Private>
3: </Reference>