Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8427583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:49:09+00:00 2026-06-10T04:49:09+00:00

I have no idea what am i doing wrong. Well i have this form,

  • 0

I have no idea what am i doing wrong.
Well i have this form, it’s part of complex view.

    @{
    var filtersAjaxOptions = new AjaxOptions
        {
            HttpMethod = "POST",
            InsertionMode = InsertionMode.Replace,
            UpdateTargetId = "clientList-body",
            OnBegin = "clientList.filterRequestStart()",
            OnComplete = "clientList.filterRequestComplete()",
            OnSuccess = "clientList.filterRequestSuccess()"
        };
    }
    <span class="clientFilters-filterValue inlineBlock">
        @using (Ajax.BeginForm(
            "Index",
            "ClientList",
            new {
                ProductId = Model.ClientListViewModel.Filters.ProductId,
                ClientFilter = Model.ClientListViewModel.Filters.ClientFilter,
                BillFilter = Model.ClientListViewModel.Filters.BillFilter,
                DateSortType = Model.ClientListViewModel.Filters.DateSortType,
                SortDirection = Model.ClientListViewModel.Filters.SortDirection
            },
            filtersAjaxOptions,
            new
            {
                id = "clientListDateFilter-form"
            }
        ))
        {
            @Html.TextBoxFor(
                m => m.ClientListViewModel.Filters.BeginDateRange,
                new
                {
                    @class = "dp-input textInput inlineBlock",
                    id = "dp-billDateFilterStart",
                }
            )
            @Html.TextBoxFor(
                m => m.ClientListViewModel.Filters.EndDateRange,
                new
                {
                    @class = "dp-input textInput inlineBlock",
                    id = "dp-billDateFilterEnd",
                }
            )
        }
    </span>

Here’s the filters model

    public class FilterModel
    {
        public FilterModel()
        {
            ClientFilter = ClientsEnum.All;
            BillFilter = ClientBillsEnum.All;
        }

        public string ProductId { get; set; }
        public ClientsEnum ClientFilter { get; set; }
        public ClientBillsEnum BillFilter { get; set; }
        public DateTime? BeginDateRange { get; set; }
        public DateTime? EndDateRange { get; set; }
        public DateSortType? DateSortType { get; set; }
        public SortDirection? SortDirection { get; set; }
    }

This part is ClientListController method Index:

    public ActionResult Index(FilterModel filters)
    {
        var clientListViewModel = GetClientListViewModel(filters, 1, 1, PageSize);
        if (ControllerContext.HttpContext.Request.IsAjaxRequest())
            return PartialView("Partial/ClientListBody", clientListViewModel);
        return View(clientListViewModel);
    }

Whenever i submit the form above, it turns to me that fields “BeginDateRange” and “EndDateRange” are null and other fields are set properly. Although, when i insert Request.Form in Watch, i can see the whole data.

UPDATE 1
So i set the <globalisation> in Web.config as this:

    <globalisation responseHeaderEncoding="utf-8" culture="en-US">

and yet it doesn’t work. Very same result as before.

UPDATE 2
Also when i tried to put all the routevalues data into @Html.HiddenFor, controller saw only nulls. And again, Request.Form is filled prprly.

So the question is: how can i bind form data to incoming model?
TY

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:49:11+00:00Added an answer on June 10, 2026 at 4:49 am

    The default model binder uses the current culture datetime format when binding datetimes. This means that you have to enter the date into the proper format in your textboxes. On the other hand if you need a fixed format you could use a fixed culture in your web.config (<globalization> element) or write a custom model binder: https://stackoverflow.com/a/7836093/29407


    UPDATE:

    You need to specify the correct binding prefix because your input fields are named like ClientListViewModel.Filters.BeginDateRange but your controller action takes a FilterModel as parameter instead of the root view model:

    public ActionResult Index([Bind(Prefix = "ClientListViewModel.Filters")] FilterModel filters)
    {
        ...
    }
    

    But now this will break the other values, so you need to adjust your view as well:

    @using (Ajax.BeginForm(
        "Index",
        "ClientList",
        null,
        filtersAjaxOptions,
        new
        {
            id = "clientListDateFilter-form"
        }
     ))
    {
        @Html.HiddenFor(x => x.ClientListViewModel.Filters.ProductId)
        @Html.HiddenFor(x => x.ClientListViewModel.Filters.ClientFilter)
        @Html.HiddenFor(x => x.ClientListViewModel.Filters.BillFilter)
        @Html.HiddenFor(x => x.ClientListViewModel.Filters.DateSortType)
        @Html.HiddenFor(x => x.ClientListViewModel.Filters.SortDirection)
    
        @Html.TextBoxFor(
            m => m.ClientListViewModel.Filters.BeginDateRange,
            new
            {
                @class = "dp-input textInput inlineBlock",
                id = "dp-billDateFilterStart",
            }
        )
        @Html.TextBoxFor(
            m => m.ClientListViewModel.Filters.EndDateRange,
            new
            {
                @class = "dp-input textInput inlineBlock",
                id = "dp-billDateFilterEnd",
            }
        )
    }
    

    or if you want to send them as part of the form url instead if using hidden fields:

    @using (Ajax.BeginForm(
        "Index",
        "ClientList",
        new RouteValueDictionary 
        { 
            { "ClientListViewModel.Filters.ProductId", Model.ClientListViewModel.Filters.ProductId },
            { "ClientListViewModel.Filters.ClientFilter", Model.ClientListViewModel.Filters.ClientFilter },
            { "ClientListViewModel.Filters.BillFilter", Model.ClientListViewModel.Filters.BillFilter },
            { "ClientListViewModel.Filters.DateSortType", Model.ClientListViewModel.Filters.DateSortType },
            { "ClientListViewModel.Filters.SortDirection", Model.ClientListViewModel.Filters.SortDirection },
        },
        filtersAjaxOptions,
        new RouteValueDictionary
        {
            { "id", "clientListDateFilter-form" }
        }
     ))
    {
        @Html.TextBoxFor(
            m => m.ClientListViewModel.Filters.BeginDateRange,
            new
            {
                @class = "dp-input textInput inlineBlock",
                id = "dp-billDateFilterStart",
            }
        )
        @Html.TextBoxFor(
            m => m.ClientListViewModel.Filters.EndDateRange,
            new
            {
                @class = "dp-input textInput inlineBlock",
                id = "dp-billDateFilterEnd",
            }
        )
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have no idea what I am doing wrong here. If i omit thew
Alright so I have no idea how to even begin doing this But basically
I have no idea why this doesn't work, but doing some validation functions and
I really have no idea what I'm doing wrong here. I can't get Datejs
I have no idea, what am i doing wrong I want to turn off
I'm building a management system for an idea I have. I'm well versed in
I have no idea why this is happening; some Google searches have led me
ok well i have this error with a counter i made witch is suppost
Alright I am stuck on this and I have no idea what I am
Anyone have idea about how to bind Boolean in sqlite with objective - c.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.