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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:24:45+00:00 2026-05-12T08:24:45+00:00

I have a UserController and an Edit.aspx. There is one field that is my

  • 0

I have a UserController and an Edit.aspx. There is one field that is my primary key so i dont want to allow users to edit this field.

The issue is that if i remove the

      <%= Html.TextBox("Email", Model.Email) %>

then when the asp.net-mvc magic calls my Controller code:

 [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Edit(int id, tblMailingList user_)
    {
        try
        {
            repo.UpdateUser(user_);
            return RedirectToAction("Index");
        }
        catch
        {
            return View();

the email field of the tblMailingList is null. The issue is that i need this as the lookup in the table to retrieve the current record and obviously if its null i get an exception.

When i put the textbox back for this field, it works fine. It seems crazy that i would have to have a textbox and allow editing to pass this field over to the controller. i tried putting it in a label and it still shows up as null in the controller.

any suggestions?

  • 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-05-12T08:24:45+00:00Added an answer on May 12, 2026 at 8:24 am

    My first question would be why are you doing the lookup on the Email field and not the Id field?

    You can pass parameters in your Form declaration to be passed through to your Controller.

    <% using (Html.BeginForm(
        "MethodName", "Controller", FormMethod.Post, 
        new { id = Model.Id, email = Model.Email)) { %>
    

    I’m not sure if I got the method declaration correct so please check.

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Edit(int id, string email, tblMailingList user_)
    {
        try
        {
            repo.UpdateUser(user_);
            return RedirectToAction("Index");
        }
        catch
        {
            return View();
    

    I would recommend updating slightly differently as your tblMailingList user will not be valid to be updated in your Repository.

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Edit(int id, FormCollection form)
    {
        tblMailingList user = repo.GetUser(id); // get the user using the id
                                                // so we can update in the same
                                                // context
        UpdateModel(user); // this will automatically update
                           // your user model with values
                           // from the form
    
        try
        {
            repo.UpdateUser(user);
            return RedirectToAction("Index");
        }
        catch
        {
            return View();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file that looks like this: function UserController(){}; UserController.prototype = { theData:
I am using the Zend Framework. I have a controller named 'UserController' that has
I have this simple code in my user_controller.rb file #listing all users def index
Per the Agile Development book, I have an Admin MVC that controls how users
I have a Users model that can have many Groups through Memberships. If a
I have a User entity that has a Current Location field (city and country).
I have a Ruby on Rails page to edit a users profile. The form
Here is my dilemma. I have a collection of entities that I want to
Story I have a select control that represents user access level. I'm looking for
EDIT: Got too confusing with so many different edits, so this is where I'm

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.