Click here to Skip to main content
15,888,211 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: I am creating graph chart line chart bar chart in asp.net web form. Pin
Richard MacCutchan12-Aug-18 21:01
mveRichard MacCutchan12-Aug-18 21:01 
QuestionThe remote name could not be resolved Pin
Member 102909889-Aug-18 1:10
Member 102909889-Aug-18 1:10 
AnswerRe: The remote name could not be resolved Pin
Richard Deeming9-Aug-18 1:42
mveRichard Deeming9-Aug-18 1:42 
AnswerRe: The remote name could not be resolved Pin
Nathan Minier9-Aug-18 2:23
professionalNathan Minier9-Aug-18 2:23 
QuestionSetting onblur, onkeyup and onkeydown for @Html.Kendo().TextBoxFor using HtmlAttributes Pin
indian1438-Aug-18 14:34
indian1438-Aug-18 14:34 
AnswerRe: Setting onblur, onkeyup and onkeydown for @Html.Kendo().TextBoxFor using HtmlAttributes Pin
jkirkerx13-Aug-18 8:10
professionaljkirkerx13-Aug-18 8:10 
GeneralRe: Setting onblur, onkeyup and onkeydown for @Html.Kendo().TextBoxFor using HtmlAttributes Pin
jkirkerx18-Aug-18 8:28
professionaljkirkerx18-Aug-18 8:28 
QuestionGetting HiddenField value in GetValidators method of CustomModelValidatorProvider Pin
indian1437-Aug-18 11:28
indian1437-Aug-18 11:28 
Hi all,

I have overridden GetValidators method of CustomModelValidatorProvider in class CustomModelValidatorProvider, when a Post is happening, this Validator is getting all the values that I have input on the screen but I have Hidden field that I want to pass into this method is not coming in.
    public class CustomModelValidatorProvider : System.Web.Mvc.DataAnnotationsModelValidatorProvider
    {
        protected override IEnumerable<System.Web.Mvc.ModelValidator> GetValidators(System.Web.Mvc.ModelMetadata metadata, ControllerContext context, IEnumerable<Attribute> attributes)
        {
            var z = metadata.PropertyName;
            if ((metadata.PropertyName == "Code") 
                && (metadata.ContainerType.FullName == "DHCS.BH.Provider.Models.LookupTable"))
            {
                LookupTable model = metadata.Container as LookupTable;

                var newAttributes = new List<Attribute>(attributes);
                var stringLength = newAttributes.OfType<StringLengthAttribute>().FirstOrDefault();
                if (stringLength != null)
                {
                    newAttributes.Remove(stringLength);

                    if (model.CodeLength != 0)
                    {
                        newAttributes.Add(new StringLengthAttribute(model.CodeLength)
                        {
                            MinimumLength = model.CodeLength,
                            ErrorMessage = @"The field {{0}} length must be at least {model.CodeLength}."
                        });
                    }

                    attributes = newAttributes;
                }
            }
            return base.GetValidators(metadata, context, attributes);
        }

        public string GetPropertyName<T>(Expression<Func<T>> propertyLambda)
        {
            var me = propertyLambda.Body as MemberExpression;

            if (me == null)
            {
                throw new ArgumentException("You must pass a lambda of the form: '() => Class.Property' or '() => object.Property'");
            }

            return me.Member.Name;
        }
    }
My cshtml file is as below, it is a Popup that's being generated for Create and Edit buttons of Kendo Grid.
@model DHCS.BH.Provider.Models.LookupTable

@{
    ViewBag.Title = "EditLookup";
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

<pre>
<div class="k-edit-form-container">
    @*<div class="editor-field">
        @Html.Kendo().TextBoxFor(model => model.LookupTableId).HtmlAttributes(new { autocomplete = "off", id = "idXYZ" })
    </div>*@
    @Html.HiddenFor(model => model.LookupTableId, new { id = "txtLookupTableId" })
    <div class="editor-label">
        @Html.LabelFor(model => model.Code)
    </div>
    <div class="editor-field">
        @Html.Kendo().TextBoxFor(model => model.Code).HtmlAttributes(new { autocomplete = "off", id = "idTxtForCodeLookupCode" })<br />
        &nbsp;<br />
        <label id="lblCodeValidationMessage" style="color:gray;font-style:italic;font-size:smaller;font-weight:normal;">Testing</label>
    </div>
    <div class="editor-label">
        @Html.LabelFor(model => model.Description)
    </div>
    <div class="editor-field">
        @Html.Kendo().TextBoxFor(model => model.Description).HtmlAttributes(new { autocomplete = "off", id = "idTxtForDescLookupCode" })
        &nbsp;&nbsp;&nbsp;
        <label id="lblDescriptionValidationMessage" style="color:gray;font-style:italic;font-size:x-small;font-weight:normal;"></label><br />
    </div>

    <div class="editor-label" >
        <label id="lblIsValid">Is Active: </label>
    </div>
    <div class="editor-field" style="padding-top: 10px;">
        @Html.Kendo().CheckBoxFor(model => model.IsValid)
    </div>
</div>

}

SetLookupTableValue();



And method SetLookupTableValue sets the value of the HiddenField txtLookupTableId, when I click on the save all other Textbox and Checkbox values coming in the model of the above GetValidators method but the LookupTableId value is coming as null, any help for this would very great help, thanks in advance.

Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."
AnswerRe: Getting HiddenField value in GetValidators method of CustomModelValidatorProvider Pin
Eric W Scott8-Aug-18 3:59
professionalEric W Scott8-Aug-18 3:59 
GeneralRe: Getting HiddenField value in GetValidators method of CustomModelValidatorProvider Pin
indian1438-Aug-18 6:30
indian1438-Aug-18 6:30 
GeneralRe: Getting HiddenField value in GetValidators method of CustomModelValidatorProvider Pin
Eric W Scott9-Aug-18 4:16
professionalEric W Scott9-Aug-18 4:16 
QuestionHow to solve HTTP Error 403.14 - Forbidden error in web service project Pin
sudipta saha6-Aug-18 1:24
sudipta saha6-Aug-18 1:24 
AnswerRe: How to solve HTTP Error 403.14 - Forbidden error in web service project Pin
Richard Deeming6-Aug-18 2:21
mveRichard Deeming6-Aug-18 2:21 
GeneralRe: How to solve HTTP Error 403.14 - Forbidden error in web service project Pin
sudipta saha6-Aug-18 22:31
sudipta saha6-Aug-18 22:31 
AnswerRe: How to solve HTTP Error 403.14 - Forbidden error in web service project Pin
dan!sh 6-Aug-18 2:41
professional dan!sh 6-Aug-18 2:41 
GeneralRe: How to solve HTTP Error 403.14 - Forbidden error in web service project Pin
sudipta saha6-Aug-18 22:24
sudipta saha6-Aug-18 22:24 
GeneralRe: How to solve HTTP Error 403.14 - Forbidden error in web service project Pin
dan!sh 6-Aug-18 22:28
professional dan!sh 6-Aug-18 22:28 
GeneralRe: How to solve HTTP Error 403.14 - Forbidden error in web service project Pin
sudipta saha6-Aug-18 22:59
sudipta saha6-Aug-18 22:59 
Questionjquery ajax Pin
Member 139369243-Aug-18 2:57
Member 139369243-Aug-18 2:57 
AnswerRe: jquery ajax Pin
dan!sh 3-Aug-18 3:31
professional dan!sh 3-Aug-18 3:31 
GeneralRe: jquery ajax Pin
Member 139369243-Aug-18 4:33
Member 139369243-Aug-18 4:33 
GeneralRe: jquery ajax Pin
Richard Deeming3-Aug-18 4:39
mveRichard Deeming3-Aug-18 4:39 
QuestionWant to prevent button posting the Data for add or Update Pin
indian1432-Aug-18 14:11
indian1432-Aug-18 14:11 
AnswerRe: Want to prevent button posting the Data for add or Update Pin
Vincent Maverick Durano2-Aug-18 19:01
professionalVincent Maverick Durano2-Aug-18 19:01 
GeneralRe: Want to prevent button posting the Data for add or Update Pin
indian1433-Aug-18 6:06
indian1433-Aug-18 6:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.