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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:09:53+00:00 2026-06-19T01:09:53+00:00

I looked through various tutorials, but I feel very confused on how I want

  • 0

I looked through various tutorials, but I feel very confused on how I want to go about executing what I have in mind and want some help to clarify my thoughts.

I will have a razor view page called Profile; on that profile page I have four different sections:

  1. Password change
  2. Setup password
  3. User name
  4. Biography.

I was thinking of creating each of the four sections as a partial section and each section will have text boxes and a save button that will allow the user to add or alter information.

@model Projects.Models.PasswordModel
@{
    ViewBag.Title = "Profile Account";
}

<hgroup class="title">
    <h1>@ViewBag.Title.</h1>
</hgroup>

<p class="message-success">@ViewBag.StatusMessage</p>


<div id="wrap">
    <div id="right">
        @if (ViewBag.HasLocalPassword)
        {
            @Html.Partial("_ChangePasswordPartial")
        }
        else
        { 
            @Html.Partial("_SetPasswordPartial")
        }
    </div>

    <div id="left">
        @Html.Partial("_UserNamePartial")
        @Html.Partial("_BiographyPartial")
    </div>
</div>

How can I properly set up the main view page and have the four sections properly displayed and functional? I got them to be displayed, but when I try to save a change I made to the username I would get an error for a different model–say the biography model. I feel like they are being connected when they shouldn’t. I am really looking for a clear tutorial of how to go about this and hopefully I will be able to make one after I figure this out.

This is my username partial

@model Project.Models.UsernameModel

@using (Html.BeginForm("_UsernamePartial", "Account")) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary()

       <p>Username</p>
       @Html.TextBoxFor(m=>m.Username)

    <button class="btn btn-small" type="submit" value="Save Username">Save</button>
}

My controller

GET:

public ActionResult _UsernamePartial()
        {
            var usernameModel = new UsernameModel();
            using (var db = new DataContext())
            {
                usernameModel.Nickname = (from u in db.Users
                                              where u.ID == WebSecurity.CurrentUserId
                                              select u.Username).FirstOrDefault();
            }
            return View(usernameModel);
        }

POST:

[HttpPost]
        public ActionResult _UsernamePartial(UsernameModel usernameModel, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                using (var db = new DataContext())
                {
                     User user = db.Users.FirstOrDefault(m => m.ID == WebSecurity.CurrentUserId);
                     user.Username = usernameModel.Username;
                     db.SaveChanges();
                 }
                return RedirectToAction("_UsernamePartial");
            }
            return View(returnUrl);
        }

Your help is greatly appreciated.

  • 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-19T01:09:54+00:00Added an answer on June 19, 2026 at 1:09 am

    You need to make sure your views are typed to the right model. Your view currently is typed to the PasswordModel model, which appears to be one section of your page. If you create a model composed of models for each section, it will make this easier:

    class ProfileModel {
        PasswordModel Password { get; set; }
        BiographyModel Biography { get; set; }
        ...
    }
    

    You would then set your Profile view to be typed to ProfileModel. Then you can pass each model to the partials:

    @Html.Partial("_BiographyPartial",Model.Biography)
    

    And an example _BiographyPartial would look like:

    @model Projects.Models.BiographyModel
    ...
    <h1>@Model.SomeBiographyProperty</h2>
    

    You should be careful to check that your validation, assuming you have some, is working correctly with this set up.

    Alternatively, you could put all of your data into one flat model and pass the whole model to each partial view.

    EDIT: Partial views aren’t backed by controllers and actions, they’re simply views that are rendered using the data you pass to them from the calling view. What you’re trying to do right now is render the _UsernamePartial action. If you want to do that you can try using Action instead of Partial:

    <div id="left">
        @Html.Action("_UserNamePartial")
        ...
    </div>
    

    And render that action as a partial view:

    public ActionResult _UsernamePartial()
    {
        var usernameModel = new UsernameModel();
        using (var db = new DataContext())
        {
            usernameModel.Nickname = (from u in db.Users
                                      where u.ID == WebSecurity.CurrentUserId
                                      select u.Username).FirstOrDefault();
        }
        return PartialView(usernameModel);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked through various answers here, but am still unable to figure it
I looked through other StackOverFlow questions, but I'm a little confused. I'm trying to
I've looked through various other questions about this and they are all fixed by
I have looked through a lot of various articles and have yet to find
I've looked through various questions both here and other places, but I still cannot
I am a completely new developer and have worked through various tutorials... How can
I've looked through the various questions on unit testing but can't find one that
I have already looked through a few answers using the various sorting methods of
I have looked through all the answers about sorting multidimensional arrays in PHP on
I've looked through the various questions already asked on this topic, and I've spent

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.