Null Reference Exception in MVC

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Null Reference Exception in MVC

    Hi, I try to load a partial MVC view when I press a button.
    the Button Code is here

     <ext:Button ID="b1" runat="server" Icon="Accept" Text="Button1" IconAlign="Left"
                                                        Cls="btnLeft">
                                                        <DirectEvents>
                                                            <Click Url="/Shared/ContractForm" >
                                                                <ExtraParams>
                                                                     <ext:Parameter Name="containerId" Value="App.Panel2" Mode="Value" />
                                                                </ExtraParams>
                                                            </Click>
                                                        </DirectEvents>
                                                    </ext:Button>
    the Controller Code is here
     public ActionResult ContractForm(string containerId)
            {
                Ext.Net.MVC.PartialViewResult r = new Ext.Net.MVC.PartialViewResult(containerId);
    
                r.ContainerId = containerId;
                r.RenderMode = RenderMode.AddTo;
                r.SingleControl = true;
                return r;
    
               
            }
    and the error code is here:

    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [NullReferenceException: Object reference not set to an instance of an object.]
    Ext.Net.MVC.PartialViewResult.ExecuteResult(Contro llerContext context) in C:\Users\Geoffrey McGill\Documents\Visual Studio 2010\Projects\Ext.NET\v2\Ext.Net\MVC\PartialViewRe sult.cs:190
    System.Web.Mvc.ControllerActionInvoker.InvokeActio nResult(ControllerContext controllerContext, ActionResult actionResult) +13
    System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionRe sultWithFilters>b__19() +23
    System.Web.Mvc.ControllerActionInvoker.InvokeActio nResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
    System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionRe sultWithFilters>b__1b() +19
    System.Web.Mvc.ControllerActionInvoker.InvokeActio nResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
    System.Web.Mvc.ControllerActionInvoker.InvokeActio n(ControllerContext controllerContext, String actionName) +343
    System.Web.Mvc.Controller.ExecuteCore() +116
    System.Web.Mvc.ControllerBase.Execute(RequestConte xt requestContext) +97
    System.Web.Mvc.ControllerBase.System.Web.Mvc.ICont roller.Execute(RequestContext requestContext) +10
    System.Web.Mvc.<>c__DisplayClassb.<BeginProcessReq uest>b__5() +37
    System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidD elegate>b__0() +21
    System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSy nchronous>b__7(IAsyncResult _) +12
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
    System.Web.Mvc.<>c__DisplayClasse.<EndProcessReque st>b__d() +50
    System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThun k>b__0(Action f) +7
    System.Web.Mvc.SecurityUtil.ProcessInApplicationTr ust(Action action) +22
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsync Result asyncResult) +60
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHan dler.EndProcessRequest(IAsyncResult result) +9
    System.Web.CallHandlerExecutionStep.System.Web.Htt pApplication.IExecutionStep.Execute() +8970061
    System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously) +184
    I have no idea where to look for the problem.

    any hints?

    thanks
  2. #2
    this problem was my own fault.

    I did not had a view file witch corresponds with the action name. Creating it solved the problem

    Gerald


    Quote Originally Posted by geraldf View Post
    Hi, I try to load a partial MVC view when I press a button.
    the Button Code is here

     <ext:Button ID="b1" runat="server" Icon="Accept" Text="Button1" IconAlign="Left"
                                                        Cls="btnLeft">
                                                        <DirectEvents>
                                                            <Click Url="/Shared/ContractForm" >
                                                                <ExtraParams>
                                                                     <ext:Parameter Name="containerId" Value="App.Panel2" Mode="Value" />
                                                                </ExtraParams>
                                                            </Click>
                                                        </DirectEvents>
                                                    </ext:Button>
    the Controller Code is here
     public ActionResult ContractForm(string containerId)
            {
                Ext.Net.MVC.PartialViewResult r = new Ext.Net.MVC.PartialViewResult(containerId);
    
                r.ContainerId = containerId;
                r.RenderMode = RenderMode.AddTo;
                r.SingleControl = true;
                return r;
    
               
            }
    and the error code is here:



    I have no idea where to look for the problem.

    any hints?

    thanks

Similar Threads

  1. ComboBox SelectedItem gets null reference error
    By zfreeman in forum 2.x Help
    Replies: 1
    Last Post: Jul 31, 2012, 7:40 PM
  2. Combobox null value exception
    By softlabsgroup.support in forum 1.x Help
    Replies: 1
    Last Post: Jun 18, 2012, 10:21 PM
  3. [CLOSED] Null Reference Object Ajax
    By Oliver in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Jun 01, 2012, 1:18 PM
  4. Replies: 1
    Last Post: Sep 09, 2011, 3:00 PM
  5. Replies: 1
    Last Post: Jun 08, 2010, 11:38 AM

Posting Permissions