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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:43:08+00:00 2026-06-05T19:43:08+00:00

Thanks for reading this. I have no idea why this is throwing a NullReferenceException

  • 0

Thanks for reading this.

I have no idea why this is throwing a NullReferenceException in _GetDate.cshtml:

<legend>For This @Model.lob.ToUpper() Please Enter Date Range</legend>

SomeController pass model –> Index.cshtml –> @Html.Partial(“_GetDate”, Model)

Also, when I break one line above in the intermediate Window I could see the value for @Model.lob.

Here’s the stack trace:

System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=App_Web_l250s0ch
StackTrace:
    at ASP._Page_Views_Shared__GetDate_cshtml.Execute() in c:\Visual Studio 2010\Projects\Web\SomeProject\SomeProject\Views\Shared\_GetDate.cshtml:line 7
    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
    at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
    at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
    at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
    at System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection)
    at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData)
    at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model)
    at ASP._Page_Views_Balance_GetDate_cshtml.Execute() in c:\Visual Studio 2010\Projects\Web\SomeProject\SomeProject\Views\Balance\GetDate.cshtml:line 22
    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
    at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
    at System.Web.WebPages.StartPage.RunPage()
    at System.Web.WebPages.StartPage.ExecutePageHierarchy()
    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
    at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
    at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
    at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
InnerException: 

Here’s GetDate.cshtml (line 22 = @Html.Partial(“_GetDate”, Model)):

@model SomeProject.Models.DateParameter

@{
    ViewBag.Title = "GetDate";
}

@section script{
 @Content.Script("/UI/jquery.ui.core.js", Url)
 @Content.Script("/UI/jquery.ui.widget.js", Url)
 @Content.Script("/UI/jquery.ui.datepicker.js", Url)
 @Content.Script("MyCustomScript.js", Url)
}

@*<script src="@Url.Content("~/Scripts/UI/jquery-ui-1.8.18.custom.js")" type="text/javascript"></script>*@
@*<script src="@Url.Content("~/Scripts/UI/jquery.ui.core.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/UI/jquery.ui.widget.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/UI/jquery.ui.datepicker.js")" type="text/javascript"></script>*@
@*@Content.ScriptinUI("jquery.ui.datepicker.js", Url)*@

<div id="table_div">

    @Html.Partial("_GetDate", Model)

</div>

Here’s “_GetDate”:

@model SomeProject.Models.DateParameter
<h2>@Model.lob.ToUpper() </h2>
    <table id="MainTable">
    <tr class="DatePicker"> <td>
    @Model.lob.ToUpper() 
    </td></tr>
</table> 

Here’s code from the Controller:

    public ActionResult GetDate(string lob)
    {
        var model = new DateParameter();
        model.lob = lob;
        ViewBag.lob = lob;
        return View(model);
    }

    [HttpPost]
    public ActionResult GetDate(FormCollection values, DateParameter newDateParameter)
    {
        if (ModelState.IsValid)
        {
            TempData["MyDate"] = newDateParameter;                
            return RedirectToAction("Listing");
        }
        else
        {
            return View(newDateParameter);
        }
    }

Might as well include the class for DateParameter:

public class DateParameter : IValidatableObject
{
    [Required]
    [StringLength(3)]
    public virtual string lob { get; set; }

    [Required]
    [DataType(DataType.DateTime)]
    [DisplayName("Start Date")]
    public virtual DateTime DateStart { get; set; }

    [Required]
    [DataType(DataType.DateTime)]
    [DisplayName("End Date")]
    public virtual DateTime DateEnd { get; set; }

    //VALIDATE DATES

    public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
    {
        //SET ERROR NEXT TO THE FIELD
        var field = new[] { "DateEnd" };

        if (DateEnd > DateTime.Now.AddDays(1))
        {
            yield return new ValidationResult("The End Date Cannot Be Greater Than Today", field);
        }
    }
}

Any idea how to return the string in @Model.lob in the partial view page?

TIA!

  • 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-05T19:43:10+00:00Added an answer on June 5, 2026 at 7:43 pm

    For what it’s worth rebooting corrected the issue. Hope this helps.

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

Sidebar

Related Questions

I really have no idea how to approach this. I've been reading for like
Firs of all thanks for reading this. I'm having trouble updating the progress from
Thanks in Advance for reading and answer this question. I got button in asp
Thanks for reading. I have done a search, read multiple posts (lost count) and
first of all thanks for reading. I have a web application that heavily uses
I've done plenty of reading on Dependency Injection, but I have no idea, how
I have this question on a practise exam, and have no idea how to
Hey, firstly thanks for reading this. I am a bit of a noobie c++
First, thank you for reading this. I am just starting php and I am
First and foremost, thank you all for reading this and helping, I'm very grateful.

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.