This is a migrated thread and some comments may be shown as answers.

[Solved] 'System.Web.Mvc.HtmlHelper<dynamic>' does not contain a definition for 'GetCurrentTheme'

9 Answers 771 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Douglas
Top achievements
Rank 1
Douglas asked on 04 Apr 2012, 05:14 PM
I just set up an existing MVC3 Razor app to use Telerik controls.

I think I have the grid control working ok, however there seems to be an issue getting the themes to work properly.

Following the local extensions example for the grid control, i ended up with this code:

@using Telerik.Web.Mvc.UI
 
<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
   @(Html.Telerik().StyleSheetRegistrar()
                      .DefaultGroup(group => group
                          .Add("telerik.examples.css")
                          .Add("telerik.common.css")
                          .Add("telerik." + Html.GetCurrentTheme() + ".css")
                                 .Add("telerik.vista.css")
                          .Add("telerik.rtl.css")
                          .Combined(true)
                          .Compress(true))
                     )
    @RenderSection("HeadContent", required:false)
    @*@Html.Partial("_Header")*@
     
</head>
 
<body>
    <div class="page">
        <div id="header">
            <div id="title">
                <h1>Marketing Website Tools</h1>
            </div>
            <div id="logindisplay">
                Welcome <strong>@User.Identity.Name</strong>!
            </div>
            <div id="menucontainer">
                <ul id="menu">
                    <li>@Html.ActionLink("Home", "Index", "Home")</li>
                    <li>@Html.ActionLink("About", "About", "Home")</li>
                    <li>@Html.ActionLink("Messages", "Index", "Callouts")</li>
                    <li>@Html.ActionLink("Flyers", "Index", "Flyers")</li>
                    @*<li>@Html.ActionLink("Callouts", "Index", "Callouts")</li>*@
                    <li>@Html.ActionLink("Banners", "Index", "Banners")</li>
                    <li>@Html.ActionLink("Buttons", "Index", "Buttons")</li>
                </ul>
            </div>
        </div>
        <div id="main">
            @RenderBody()
        </div>
        <div id="footer">
        </div>
    </div>
     
@*    @(Html.Telerik().StyleSheetRegistrar().DefaultGroup(group=>group.Add("telerik.common.css").Add("telerik.vista.css").Combined(true).Compress(true)))
    @Html.Telerik().ScriptRegistrar()*@
  @*   @(Html.Telerik().ScriptRegistrar()
                     .DefaultGroup(group => group
                         .Add("telerik.examples.js")
                         .Compress(true))
                     .OnDocumentReady(
                     @<text>
                         prettyPrint();
                     </text>)
    )
    *@
 
</body>
</html>

But this line:

.Add("telerik." + Html.GetCurrentTheme() + ".css")

is causing an error:

Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper<dynamic>' does not contain a definition for 'GetCurrentTheme' and no extension method 'GetCurrentTheme' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<dynamic>' could be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 11:                           .Add("telerik.examples.css")
Line 12:                           .Add("telerik.common.css")
Line 13:                           .Add("telerik." + Html.GetCurrentTheme() + ".css")
Line 14:                                  .Add("telerik.vista.css")
Line 15:                           .Add("telerik.rtl.css")

Source File: c:\development\MarketingWebsiteTools\MarketingWebsiteTools\Views\Shared\_Layout.cshtml    Line: 13 



C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\Users\ddexter\AppData\Local\Temp\Temporary ASP.NET Files\root\167c91fc\fef9fe89\assembly\dl3\fbd2278e\fc0408eb_860ecd01\AutoMapper.DLL" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Users\ddexter\AppData\Local\Temp\Temporary ASP.NET Files\root\167c91fc\fef9fe89\assembly\dl3\d5ffa19d\ac567eee_860ecd01\PagedList.Mvc.DLL" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Users\ddexter\AppData\Local\Temp\Temporary ASP.NET Files\root\167c91fc\fef9fe89\App_global.asax.mh78gcfq.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\Users\ddexter\AppData\Local\Temp\Temporary ASP.NET Files\root\167c91fc\fef9fe89\assembly\dl3\9f240e22\4b4af7cd_6d12cd01\MarketingWebsiteTools.DLL" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\Users\ddexter\AppData\Local\Temp\Temporary ASP.NET Files\root\167c91fc\fef9fe89\assembly\dl3\59a7a084\72d666ee_860ecd01\PagedList.DLL" /R:"C:\Users\ddexter\AppData\Local\Temp\Temporary ASP.NET Files\root\167c91fc\fef9fe89\assembly\dl3\7698d94c\4e2d92ee_860ecd01\Calabonga.Mvc.PagedListExt.DLL" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Deployment\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Deployment.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Helpers\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.Helpers.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Mvc\v4.0_3.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\Users\ddexter\AppData\Local\Temp\Temporary ASP.NET Files\root\167c91fc\fef9fe89\App_GlobalResources.rqmeg_ge.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Abstractions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Abstractions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Telerik.Web.Mvc\v4.0_2012.1.214.340__121fae78165ba3d4\Telerik.Web.Mvc.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Data.Linq.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Routing\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Routing.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\EntityFramework\v4.0_4.1.0.0__b77a5c561934e089\EntityFramework.dll" /out:"C:\Users\ddexter\AppData\Local\Temp\Temporary ASP.NET Files\root\167c91fc\fef9fe89\App_Web__layout.cshtml.639c3968.marcpoto.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699;1701 /warnaserror-  "C:\Users\ddexter\AppData\Local\Temp\Temporary ASP.NET Files\root\167c91fc\fef9fe89\App_Web__layout.cshtml.639c3968.marcpoto.0.cs" "C:\Users\ddexter\AppData\Local\Temp\Temporary ASP.NET Files\root\167c91fc\fef9fe89\App_Web__layout.cshtml.639c3968.marcpoto.1.cs"


Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.

c:\development\MarketingWebsiteTools\MarketingWebsiteTools\Views\Shared\_Layout.cshtml(13,50): error CS1061: 'System.Web.Mvc.HtmlHelper<dynamic>' does not contain a definition for 'GetCurrentTheme' and no extension method 'GetCurrentTheme' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<dynamic>' could be found (are you missing a using directive or an assembly reference?)




Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225
 

Thanks


9 Answers, 1 is accepted

Sort by
0
Dadv
Top achievements
Rank 1
answered on 05 Apr 2012, 02:11 PM
This is a internal extension for the demo version,  link to a dropdownlist, if you didn't get this extension and didn't ref it, this will never work in other empty telerik mvc project.
0
Kiang
Top achievements
Rank 1
answered on 18 Apr 2012, 08:37 AM
hello... I've got same problem with you.. how can i fix this thing??
0
Douglas
Top achievements
Rank 1
answered on 18 Apr 2012, 01:53 PM
Make sure that your default path is pointing to the proper directory:

@(Html.Telerik().StyleSheetRegistrar()
                     .DefaultGroup(group => group
                          
                   .DefaultPath("~/Content/2012.1.214/")
                         .Add("telerik.common.min.css")
                         .Add("telerik." + Html.GetCurrentTheme() + ".min.css")
                         .Add("telerik.rtl.css")
                         .Combined(true)
                         .Compress(true))
                    )

Also your actual themes may be minified...mine were..so check the names as well..

hope that helps

doug
0
Kiang
Top achievements
Rank 1
answered on 18 Apr 2012, 03:55 PM
file below is my code and pathway... can u help me to check it~? thanks 
0
Dadv
Top achievements
Rank 1
answered on 20 Apr 2012, 09:31 AM
For me the problem is Html.GetCurrentTheme() not the path...

Html.GetCurrentTheme() is en internal extension, you need to add it in your own project if you want it work :

 public static string GetCurrentTheme(this HtmlHelper html)
        {
            return html.ViewContext.HttpContext.Request.QueryString["theme"] ?? "vista";
        }


and in your View you need something to call the new theme  like this  <a href="YourUrl?theme=default" class="t-drop-down">default</a>

PS: this is ONLY in the DEMO site, it's not include in the Telerik core dll...
0
Satish
Top achievements
Rank 1
answered on 02 May 2012, 05:24 PM
Where to add GetCurrentTheme?  To HomeController?
0
Dadv
Top achievements
Rank 1
answered on 03 May 2012, 01:52 PM
GetCurrentTheme  should be a stand alone extension (static class)

public static class ThemeExtender
{
public static string GetCurrentTheme(this HtmlHelper html)
        {
            return html.ViewContext.HttpContext.Request.QueryString["theme"] ?? "vista";
        }
}

don't forget to add the namespace in the view
0
Jose
Top achievements
Rank 1
answered on 11 May 2012, 06:07 AM
My Suggestion: Don't include GetCurrentTheme in your examples. It's confusing and I almost reject the possibility of take this set of control seriously. The error was not clear and I though initialy that it was part of some classes that the template should install for you.
0
Dadv
Top achievements
Rank 1
answered on 11 May 2012, 04:05 PM
I suggest you to add a request to the Pit for that
Tags
Grid
Asked by
Douglas
Top achievements
Rank 1
Answers by
Dadv
Top achievements
Rank 1
Kiang
Top achievements
Rank 1
Douglas
Top achievements
Rank 1
Satish
Top achievements
Rank 1
Jose
Top achievements
Rank 1
Share this question
or