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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:23:56+00:00 2026-05-14T01:23:56+00:00

I am new to MVC and have a grasp of the basic model, but

  • 0

I am new to MVC and have a grasp of the basic model, but still doing everything with postbacks etc.

One aspect of the UI I want to build is to have a drop-down-list of items with a button to add an item to the database and refresh the list. Achieving this with WebForms was straight forward as everything was wrapped in UpdatePanels, but what is the best approach to achieve this using MVC?

Part of the markup for the list and button look like this:

<table>
    <tr>
        <td><%=Html.DropDownList("JobTitleSelectList", Model.JobTitleSelectList, "(select job title)", new { @class = "data-entry-field" })%></td>
        <td>&nbsp;</td>
        <td><a id="AddJobTitleDialogLink" href="javascript: addJobTitleDialog();" title="Add Job Title"><img id="AddJobTitleButtonImage" src="/Content/Images/Icons/16x16/PlusGrey.png" border="0" /></a></td>
    </tr>
</table>

The Dialog is a standard jquery Ui dialog, looks like this:

<div id="SingleTextEntryDialog" style="display:none">
        <table>
            <tr>
                <td>Name:</td>
                <td><input id="SingleTextEntryDialogText" type="text" size="25" /></td>
            </tr>
        </table>
    </div>

I am guessing I need to put this into a UserControl / PartialView (are they the same thing?) Also with the strongly typed View how do I pass the Model or just the SelectList Property to the UserControl or is this not the case?

Nor sure if there should be form in the dialog div? or how that is going to postback via ajax.

Some examples show a lot of ajax code in the page something like: $.ajax({...});
I assume doing this using jquery is more code than asp.net webforms, but there is just more code to see doing a “View Source” on a page?

Your comments 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-05-14T01:23:56+00:00Added an answer on May 14, 2026 at 1:23 am

    You could either use AJAX or perform a full page reload after the button is clicked. In bother cases you could have two forms on your page: the first form will contain the dropdown list allowing the user to select an element and a second form which will contain an input field and add button. Both forms will post to different actions on your controller.

    If you decide not not use AJAX here’s how you could proceed. Add a form containing the job title selection:

    <div id="selectjobcontainer">
    <% using (Html.BeginForm("selectjob", "home")) { %>
        <%= Html.DropDownList("JobTitleSelectList", Model.JobTitleSelectList) %>
        <input type="submit" value="Select job title" />
    <% } %>
    </div>
    

    Add another form which will allow the user to add a job title to the list:

    <div id="addjobcontainer">
    <% using (Html.BeginForm("addjob", "home")) { %>
        <%= Html.TextBox("JobTitle") %>
        <input type="submit" value="add job title" />
    <% } %>
    </div>
    

    The AddJob action should add the job title to the model and render the same view which will update the jobs dropdown list.

    If you decide to refresh the dropdown list using AJAX, the AddJob action should return a partial view containing the first form, meaning that you need to put its code into a separate ascx control which you will include into the main view.

    All that is left is to ajaxify the second form using the jQuery form plugin:

    $(function() {
        $('#addjobcontainer form').ajaxForm({
            success: function(html) {
                $('#selectjobcontainer').html(html);
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to the MVC pattern but have been trying to grasp it, for
I am new to MVC and facing one issue. I have a xml file
I am quite new to MVC but have been making steady progress however I
I have a new MVC 4 Application with a fairly basic View/Controller. The associated
i am new in mvc but have good experience in webform. when we call
(I'm new to MVC). In my application I don't have a model in the
First off, I'm fairly new to MVC but have an existing project in MVC3
I have started a new mvc project and clicked on project\properties\web - use local
I am new to MVC and EF and I have a question. I have
Pretty new to MVC and the like. I have a class the looks like

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.