This is a migrated thread and some comments may be shown as answers.
Object Reference not set...
7 Answers 116 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mel
Top achievements
Rank 2
Mel asked on 22 Apr 2010, 12:23 PM
On my first stab at trying the controls, I followed the instructions then added the following menu to the site.master, however the page does not work, and I get an 'object reference not set...' for the menu control. Any help please:

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title
    <%= Html.Telerik().StyleSheetRegistrar() 
        .DefaultGroup(group => group.Add("telerik.common.css") 
                                    .Add("telerik.vista.css")) 
    %> 
    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" /> 
</head> 
 
<body> 
    <div class="page"
 
        <div id="header"
            <div id="title"
                <h1>.NET MVC 2 Application</h1> 
            </div> 
               
            <div id="logindisplay"
                <% Html.RenderPartial("LogOnUserControl"); %> 
            </div>  
             
            <div id="menucontainer"
                <
                   Html.Telerik().Menu() 
                       .Name("menu") 
                       .Items(menu => 
                                  { 
                                      menu.Add().Text("Home").Action("Home", "Index", "Home"); 
                                      menu.Add().Text("About").Action("About", "About", "Home"); 
                                  }) 
                       .Render(); 
                %>             
            </div> 
        </div> 
 
        <div id="main"
            <asp:ContentPlaceHolder ID="MainContent" runat="server" /> 
 
            <div id="footer"
            </div> 
        </div> 
    </div> 
    <!-- other content --> 
    <%= Html.Telerik().ScriptRegistrar() %> 
</body> 
</html> 
 


7 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 22 Apr 2010, 12:32 PM
Hello Mel,

Make sure you are using the MVC 2 build of the components. The version of the Telerik.Web.Mvc.dll assembly should end with 235 e.g. 2010.1.416.235.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mel
Top achievements
Rank 2
answered on 22 Apr 2010, 12:59 PM
I did have the wrong version. I replaced it with 2010.1.309.235 and I still get the same error:

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

Source Error:

Line 26:             <div id="menucontainer">
Line 27:                 <%
Line 28:                    Html.Telerik().Menu()
Line 29:                        .Name("menu")
Line 30:                        .Items(menu =>

0
Atanas Korchev
Telerik team
answered on 22 Apr 2010, 01:07 PM
Hello Mel,

I still think you are using the older version. Check the properties of the Telerik.Web.Mvc node in the references. You need to remove it and add it again to update an assembly reference.

All the best,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mel
Top achievements
Rank 2
answered on 22 Apr 2010, 01:21 PM
I double checked, published and checked again, and it does say 2010.1.309.235


0
Atanas Korchev
Telerik team
answered on 22 Apr 2010, 01:32 PM
Hello Mel,

The problem is that you have not correctly set the controller and action

This

menu.Add().Text("Home").Action("Home", "Index", "Home");

Should be

menu.Add().Text("Home").Action("Index", "Home");

Greetings,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mel
Top achievements
Rank 2
answered on 22 Apr 2010, 01:37 PM
AH! Thank you!! It works, many thanks for your help!!
0
viktor
Top achievements
Rank 1
answered on 21 Sep 2010, 03:04 PM
Hi

I have the same problem although I'm binding to a sitemap.
The sitemap is embedded on an .ascx page and is then rendered as part of a master page.

In Debug mode, I can see that the ViewData is populated but the sitemap just does not render.

What do you think I should do?

Regards.
Tags
Menu
Asked by
Mel
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Mel
Top achievements
Rank 2
viktor
Top achievements
Rank 1
Share this question
or