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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:15:34+00:00 2026-06-13T02:15:34+00:00

I am trying to allow users to select an image and add some additional

  • 0

I am trying to allow users to select an image and add some additional information to it.

I have an object that holds the additional info – lets just keep it simple and say its two strings – and an image

[Table("ImageInfo")]
public class ImageInfo
{
    [Key]
    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
    public int ImageInfoId { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }

    public Image Image { get; set; }
}

[Table("Image")]
public class Image
{
    [Key]
    [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
    public int IamgeId { get; set; }
    public byte[] ImageBytes { get; set; }
}

For the Create view I want to show the users two text fields and a ‘gallary’ type layout of all existing iamges from the database.

I would like the iamge gallary part to be a partial view so I can reuse it elsewhere too.

I cannot figure out how to display the images and be able to see which one a use has selected in the controller to link them up. I imaging it will require some view specific models but beyond that I am drawing a blank.

Can someone point me in the right direction please.

ps. reason for storing ImageInfo and Image in seperate tables is that there will be many ImageInfo for each Image.

  • 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-13T02:15:36+00:00Added an answer on June 13, 2026 at 2:15 am

    Yes. you need some view specific models. We will call it ViewModels. They are simple POCO classes to be used in the View. so let’s create 2 of them for our scenario.

    public class AddUserImageViewModel
    {
      public int UserId { set;get;}
      public List<ImageViewModel> AvailableImages { set;get;}
      public string Name { set;get;}
      public string Description { set;get;}  
      public int SelectedImageID { set;get;}
    }    
    public class ImageViewModel
    {
      public int ID { set;get;}
      public string Name { set;get;}
      public string Description { set;get;}
      public string URL { set;get;}  
    }
    

    Now in the GET action, set the property values on an object of our viewmodel

    public ActionResult AddImage()
    {
      var vm=new AddUserImageViewModel();
      vm.AvailableImages =repositary.GetAvailableImages();
      return View(vm);
    }
    

    Now our View will be strongly typed to our viewmodel

    @model AddUserImageViewModel
    <h2>Add image to profile</h2>
    @using(Html.Beginform())
    {   
      @Html.HiddenFor(m=>m.SelectedImageID)
      <input type="submit" />
    }
    @{ Html.RenderPartial("AvailableImages",Model.AvailableImages);  }
    

    AvailableImages will be a partial view which is strongly typed to a collection of ImageViewModel

    @model List<ImageViewModel>
    @foreach(var item in Model)
    {
      <img src=@item.URL" id=@item.ID" alt="@item.Name" class="imgItem" />
    }
    

    Add some jquery code, so that when user selects an image, get the image id and set it to the Hidden variable(SelectedImageID) in our form so that it will be available when the form is posted.

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

Sidebar

Related Questions

I'm trying to create a simple WYSIWYG editor that will allow users to select
I'm trying to add a public API to my app to allow users to
I have been trying to integrate Facebook with my app to allow users to
I'm trying to develop a system that will allow users to update local, offline
I'm trying to create a dialog which will allow users to upload an image.
I am trying to find out how to allow users to only select certain
I am trying allow users to copy and paste my text content that sits
I am trying to allow a user to select an image, either from the
I'm trying to use a JQuery UI slider to allow users to select a
We are trying to build a SQL query builder that would allow users to

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.