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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:25:43+00:00 2026-06-17T23:25:43+00:00

I have the following view part: <div class=editor-label> @Html.LabelFor(model => model.Type) </div> <div class=editor-field>

  • 0

I have the following view part:

<div class="editor-label">
    @Html.LabelFor(model => model.Type)
</div>
<div class="editor-field">
    @Html.DropDownListFor(model => model.Type, ElangWeb.Helpers.ModelHelpers.GetExerciseTypes())
</div>

I want to have a link which will generate some partialview based on my model’s Type property which is an Enum (I return different partial views based on the type),
I’ve added the following link:

@Ajax.ActionLink("AddExerciseItem", 
                        "AddExerciseItem",
                        "Exercise",
                        new { type=@Model.Type},
                        new AjaxOptions() { HttpMethod="GET", InsertionMode = InsertionMode.InsertBefore, UpdateTargetId="ExerciseItems"})

My controller action is defined as follows:

public ActionResult AddExerciseItem(ExerciseType type)
{

  return PartialView("ExerciseItemOption", new ExerciseItemOption());
}

I however does not work because I have the exeption “Object reference not set to an instance of an object” for my Model. How to resolve this issue?

  • 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-17T23:25:44+00:00Added an answer on June 17, 2026 at 11:25 pm

    You could use a normal link:

    @Html.ActionLink(
        "AddExerciseItem", 
        "AddExerciseItem", 
        "Exercise", 
        null, 
        new { id = "add" }
    )
    

    that you could unobtrusively AJAXify:

    // When the DOM is ready
    $(function() {
        // Subscribe to the click event of the anchor
        $('#add').click(function() {
            // When the anchor is clicked get the currently
            // selected type from the dropdown list.
            var type = $('#Type').val();
    
            // and send an AJAX request to the controller action that 
            // this link is pointing to:
            $.ajax({
                url: this.href,
                type: 'GET',
                // and include the type as query string parameter
                data: { type: type },
                // and make sure that you disable the cache because some
                // browsers might cache GET requests
                cache: false,
                success: function(result) {
                    // When the AJAX request succeeds prepend the resulting
                    // markup to the DOM the same way you were doing in your
                    // AJAX.ActionLink
                    $('#ExerciseItems').prepend(result);
                }
            });
            return false;
        });
    });
    

    Now your AddExerciseItem controller action could take the type parameter:

    public ActionResult AddExerciseItem(string type)
    {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have the following scenario: I have a class part of a view
I have following view <asp:Content ID=Content2 ContentPlaceHolderID=MainContent runat=server> <h2>Tables <%=ViewData[RetriverName] %></h2> <%using (Html.BeginForm(ResfreshSelectedTables, Home))
I have the following view: @model MyModel1 @{ ViewBag.Title = Index; Layout = ~/Views/Shared/_Layout.cshtml;
I have the following link: <?php echo $this->Html->link($post['Portfolio']['title'], array('controller' => 'portfolio', 'action' => 'view',
I have the following markup as a part of a Razor view: <table> <caption>Presidents</caption>
I have the following code in my view: <%= Html.ActionLink( View item, Index, Items,
i have following captcha code: <?php class CaptchaView extends View { private $fontsDir =
I am working on a project in cakephp.For the view part,I have the following
I have an employee class in model for ASP.NET MVC3. There is a field
I have the following view and table in my project, vw_get_arabia_upod_full_details arabia_upod_item_avalability_master I want

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.