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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:25:29+00:00 2026-06-14T04:25:29+00:00

I am using a create form with asp.net mvc 3, where a user enters

  • 0

I am using a create form with asp.net mvc 3, where a user enters information and submits, to save their typed information to a database. I would like to display to the user the Id generated with the database row they have just created (via a view for form submitted successfully your id number is…). Does anyone know of a method to accomplish this?

  • 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-14T04:25:30+00:00Added an answer on June 14, 2026 at 4:25 am

    Your question needs a bit more detail however there are a few things one should consider when coming up with a data persistence strategy. If you’re using the Asp.Net Membership provider, you need to specify that as well. There are methods for returning user info as Bildr pointed out, but I don’t recommend using that provider unless you need to as it is being replaced with a ‘Simple Membership Provider’ in MVC4.

    If your using a repository pattern, you could have classes inherit from a common interface. When you add an entity of type T it returns that entity back to the user, when you perform a save it doesn’t. This approach comes in handy when you’re crossing boundaries, such as with WCF Services and you are passing in a complex object graph with multiple child objects. You can of course, be a little more nimble and have your save method simply return the ID of the created object.

     public interface IRepository<T>
    {
        /// <summary>
        /// Saves the specified object and returns it back to the user.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns>The created class</returns>
        T Add(T model);
        /// <summary>
        /// Persist the specified object.
        /// </summary>
        /// <param name="model">The model.</param>
        void Save(T model);
    }
    

    Of course, if you’re building a simpler application, and you are as over repositories as Jimmy Bogard is, and using an ORM, such as EntityFramework then you would pass in your object (again, it’s by reference) to your context object:

      var foo = new Foo{ Name="goo"}
      _modelContext.MyDBSetFoos.Add(foo);
      ((ModelContext)_modelContext).SaveChanges();
      return foo.Id;
    

    If you clarify your question, I’d be happy to provide a more specifics. Good luck!

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

Sidebar

Related Questions

I am trying to create a custom authentication scheme in ASP.NET MVC using form
Im using asp.net mvc. I have a create and edit form which are very
Say you create a form using ASP.NET MVC that has a dynamic number of
I'm using ASP.NET Web Pages to create a form in which I can select
I am new In ASP.NET, I want to create to Login Form using Membership
I am using ASP.Net MVC. I have a partial view which has a form
I'm am using ASP.NET MVC to create a page that posts to the Paypal
I'm trying to create a page using ASP.NET MVC 2 which shows two things:
I am using jQuery Mobile to create a mobile ASP.NET MVC site I am
I'm trying to create a create model object page. I'm using asp.net mvc with

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.