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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:19:40+00:00 2026-06-03T07:19:40+00:00

I have a main view and the URL for this view has a Action/Controller/Area

  • 0

I have a main view and the URL for this view has a Action/Controller/Area and id value, something like:

http://localhost:56513/Incident/IncidentHome/Index/8c02a647-a883-4d69-91be-7ac5f7b28ab7

I have a partialview in this main view, one that calls methods in the controller via Ajax. This partial view needs to know the ID value of the url for the parent page. I found how to do this is through ‘ParentActionViewContent’. Something like:

        using (Ajax.BeginForm("UpdatePersonalStatusPanel", "Status", new { area = "Tools" , id = ViewContext.ParentActionViewContext.RouteData.Values["id"].ToString() }, new AjaxOptions { UpdateTargetId = "divPersStatus" }))
        {
            <p style="text-align: center;">
                <span class="editor-label">@Html.LabelFor(m => m.StatusText)</span> <span class="editor-field">@Html.EditorFor(m => m.StatusText)</span>
                <input type="submit" value="Change Current Status" />
            </p>
        }

Now, this works fantastic for calling the controller method. The ID is passed correctly so that the controller can then see it in the routedata. I use the id to perform a database call, and then return the partialview again. The problem is on the return. I get a ‘Object reference not set to an instance of an object’ on the ViewContext.ParentActionViewContext.RouteData.Values[“id”].ToString() bit in the ajax.beginform , and my targetid doesn’t refresh.

Clearly I must be doing something wrong. Does someone else have a better way to see the parent view’s routedata through Ajax?

  • 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-03T07:19:41+00:00Added an answer on June 3, 2026 at 7:19 am

    If I’m understanding you correctly, this partial view calls itself. So ParentActionViewContext works the first time because the first time your main view calls an action using this partial view. However, later an ajax call directly returns this partial view. When the partial view is invoked directly there is no Parent View action hence the null reference on ParentActionViewContext.

    Rather than deal with with route data I recommend including the id in the model of your partial view.

    new { area = "Tools" , id = Model.Id }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get a url structure like this. http://example.com/blog/1/title-name-goes-here My main urls
In the main view i have this function public function lang($file, $language){ require 'languages/'.$language.'/'.
I have below html code in one of the opensource project. <form action=/wiki/bin/view/Main/Search> <div
I have added navigation controller into my appication in didFinishLaunchingWithOptions like this LoginViewController *mainView
I have a user controller that checks to login a user. It has this
I have a storyboard set up with working login and main view controller, the
I'm developing an iOS 4 application. I have a main view that contains another
I have an application composed of a main view and a secondary view which
I have an Android app with a ListActivity in the main view. The list
I have 2 views (first view - custom user control, MainWindow view - main

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.