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

  • SEARCH
  • Home
  • 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 8132145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:16:32+00:00 2026-06-06T09:16:32+00:00

I have two pages, one that edits user information, and one that edits information

  • 0

I have two pages, one that edits user information, and one that edits information in a pictures table. I recently stopped using strongly typed viewmodels due to the varying types of data required on each page.

The page that edits the user information works fine, but the page that edits picture information does not post back any of the edits that are made in the input fields; except for the ID, which is correct, all the other values come back as null. They both seem to be structured exactly the same way — I can’t figure out what’s the difference. As far as I can tell the code for both pages are the same, but I’m not getting data back on the second one.

User Controller and View which works

Controller

public ActionResult Preferences()
{
    int userid = getUserID(User.Identity.Name);  

    // Info for user preferences
    var accountInfo = db.users.Single(l => l.ID == userid);  

    ViewData["accountInfo"] = accountInfo;

    AccountController usr = new AccountController(); // Info for user menu
    ViewData["userInfo"] = usr.getUserInfo(User.Identity.Name);

     return View();
}

[HttpPost]
public ActionResult Preferences(user accountInfo, string oldPW)
{
    // Do stuff to save user info
    return RedirectToAction(actionname, routeValues);
}

View

@using (Html.BeginForm("Preferences", null, FormMethod.Post, 
                                            new { id = "prefsform" }))
{
AutoShowApp_MVC.user item = new AutoShowApp_MVC.user();
item = ViewBag.accountInfo;

<input id="lastname" name="lastname" type="text" value="@item.lastname"/>
<input id="address1" name="address1" type="text" value="@item.address1"/>
<input id="city" name="city" type="text" value="@item.city"/>
<input id="state" name="state" type="text" value="@item.state"/>
<input type="submit" value="Submit Changes"  />

}

Picture Controller and View which DON’T work

Controller:

public ActionResult Edit(long id)
{
    var picInfo = db.lmit_pics.Single(l => l.ID == id);
    ViewData["picInfo"] = picInfo; // get Picture Info

    // Get User Info for menu
    AccountController usr = new AccountController(); 
    ViewData["userInfo"] = usr.getUserInfo(User.Identity.Name);

    return View();
}

[HttpPost]
public ActionResult Edit(lmit_pics picInfo)
{
    // Do stuff to save picInfo
    return RedirectToAction("Index");
}

View:

@using (Html.BeginForm("Edit", null, FormMethod.Post, new { id = "editform" }))
{
    AutoShowApp_MVC.lmit_pics item = new AutoShowApp_MVC.lmit_pics();
    item = ViewBag.picInfo;
    <input type="text" id="model" value="@item.model" />
    <input type="text" id="description" value="@item.description" />
    <input type="submit" value="Save" /> 
}
  • 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-06T09:16:34+00:00Added an answer on June 6, 2026 at 9:16 am

    You do not have the name attribute specified on the inputs on your picture editing form.

    <input type="text" id="model" value="@item.model" />
    

    Should Be

    <input type="text" id="model" name="model" value="@item.model" />
    

    The form collection works from the name attribute, not the Id attribute which is why you are not getting any data back (you are, it is just not properly attributed).

    However, I agree with Wahid above, using strongly typed view models, editorFor helpers, etc not only help to prevent issues such as the above, but really go a long way in making a more secure, easier to maintain site.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two pages that inherit from one master page, First.aspx or second.aspx. Navigation
I have two ASP.NET sites that are used for managing patient information. One application
I have a page that displays two objects and then the user picks one
I have two pages. First one we open with $_POST variables in its url,
I'm trying to build a portal in which i have two pages , one
I have a page that, when accessed displays a table of information related to
I have a database that has two tables, one of which contains a foreign
I have two user controls that need to add a class atribute to the
I have two div in my website page one beside the other(one left and
I have two carousels on one page but unfortunately they copy each other. http://jsfiddle.net/seanjacob/tB6y5/

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.