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 9193929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:16:54+00:00 2026-06-17T21:16:54+00:00

I have a simple form for modifying part of a complex model. I can

  • 0

I have a simple form for modifying part of a complex model. I can of course pare down the model, but I would like to solve the complex case, because we’ll eventually be dealing with the whole model anyways.

I want the rendered input to have a simple Id and Name, but the model name seems to be unmovable.

@Html.EditorFor(model => model.CallInfo.Phone1,
   new { @id = "Phone1", @name = "Phone1"})

Should output this

<input type="text" value="" name="Phone1" id="Phone1" class="text-box single-line">

Instead, it outputs this, with CallInfo prefixed everywhere.

<input type="text" value="" name="CallInfo.Phone1" id="CallInfo_Phone1" class="text-box single-line">

If this can’t be defeated, then is there a way to get the CallInfo.Phone1 parameter to auto-parse into a parameter for the action method? Because this is waaay invalid syntax in C#.

public ActionResult UpdatePhoneNumber(Int32 profileId, String CallInfo.Phone1)

Again, I realize I could manually retrieve it from the request, like so

HttpRequest.Current.Params["CallInfo.Phone1"]

But it really seems like the C# MVC4 conventions should play nice together here, making ONE of these auto-magic widgets do the right thing.

Update: Following Dmitri’s answer, I left the view markup the way it was, with the name="CallInfo.Phone1" attribute as generated and modified the action signature to this:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdatePhoneNumber(Int32 profileId,
    [Bind(Prefix = "CallInfo")] string phone1)
{
    // Save it
}

In the debugger, phone1 is null and does not get saved to the database. The post body, captured from firebug, has this to say:

Parameters          application/x-www-form-urlencoded
CallInfo.Phone1     8121234567

I’ve also tried capitalizing the p in the Phone1 parameter name to no effect.

  • 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-17T21:16:56+00:00Added an answer on June 17, 2026 at 9:16 pm

    If this can’t be defeated, then is there a way to get the
    CallInfo.Phone1 parameter to auto-parse into a parameter for the
    action method? Because this is waaay invalid syntax in C#.

    Sure, using the [Bind] attribute:

    public ActionResult UpdatePhoneNumber(
        int profileId, 
        [Bind(Prefix = "CallInfo")] string phone1
    )
    {
        ...
    }
    

    or even better, by defining a view model:

    public class MyViewModel
    {
        public int ProfileId { get; set; }
        public CallInfoViewModel CallInfo { get; set; }
    }
    
    public class CallInfoViewModel
    {
        public string Phone1 { get; set; }
    }
    

    and then having your controller action take this view model as argument:

    public ActionResult UpdatePhoneNumber(MyViewModel model)
    {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple form like this which accepts only two values string action and
Have a simple form (only extract fields here) but for some reason the JQserilization
I have a simple form that looks like this: <%= simple_form_for @study,:url => studies_path,
I have a simple form like this : <form method=post name=change_pass id=change_pass action=change_pass2.php> <input
I have a simple form that looks like so <% remote_form_for post, :url =>
i have simple form and posting it with ajax, but i am not able
I have simple login form I am using SQLite database which has fields like
I have a simple form that triggers an ajax call but as soon as
I have a simple form that behaves as expected when method=GET , but when
I have simple form with 2 textfield Name and Phone and can add new

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.