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

Telerik Reporting - Html.TelerikReporting() not found

6 Answers 866 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 28 Aug 2015, 03:58 AM
HI

I'm trying to write a simple Telerik Reporting project but met some diffcults :

New > Project > ... > Telerik C# ASP.NET MVC Application
New > New Item > ... > Telerik MVC Report Viewer Page Q2 2015 (Sample report definition)

Build the project there have no any failed :

========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

But the Error List show lots of errors after open ReportViewerView1.cshtml :

Error CS0103 The name 'ViewBag' does not exist in the current context CSharp.MvcDemo C:\Program Files\Telerik\Reporting Q2 2015\Examples\CSharp\MvcDemo\Views\Home\Index.cshtml 6
...
...
Error CS1061 'HtmlHelper' does not contain a definition for 'TelerikReporting' and no extension method 'TelerikReporting' accepting a first argument of type 'HtmlHelper' could be found (are you missing a using directive or an assembly reference?) CSharp.MvcDemo C:\Program Files\Telerik\Reporting Q2 2015\Examples\CSharp\MvcDemo\Views\Home\Index.cshtml 202

And the errors disappears after close ReportViewerView1.cshtml.

Why ? The bug of Visual Studio 2015 ??

Then move the \ReportViewerView1.cshtml into Views/Home, rename to Index.cshtml, the runtime error occurred after Start Debugging :

... CS1061: 'System.Web.Mvc.HtmlHelper<dynamic>' not contains 'TelerikReporting' ...,... 'TelerikReporting' 來接受類型 'System.Web.Mvc.HtmlHelper<dynamic>' ...

...:
 

Line 27: }
Line 28: 
Line 29: @(Html.TelerikReporting().ReportViewer()
Line 30:         // Each report viewer must have an id - it will be used by the initialization script
Line 31:         // to find the element and initialize the report viewer.
 

*The Telerik Reporting Q2 2015 Examples have the same problem but it can run report normally :
 C:\Program Files\Telerik\Reporting Q2 2015\Examples\CSharp\MvcDemo\Views\Home\Index.cshtml


Visual Studio 2015
ASP.NET MVC 5
.NET Framework 4.6

Best regards

Chris

6 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 31 Aug 2015, 03:15 AM
HI

I have found that 'Telerik Reporting Sample - MVC' are using 'Microsoft.AspNet.Mvc.4.0.30506.0' and works fine,
but Telerik Reporting MVC library are not works while using 'Microsoft.AspNet.Mvc.5.2.3'.

Is Telerik Reporting Q2 2015 not support MVC 5 yet ?? or is there have newest sample that works with MVC 5 ?

Best regards

Chris

0
Accepted
Chris
Top achievements
Rank 1
answered on 31 Aug 2015, 06:59 AM
HI

The solutions for Telerik Reporting (MVC 5) development problems was found :



。CS1061: 'System.Web.Mvc.HtmlHelper<dynamic>' not contains 'TelerikReporting' ...,... 'TelerikReporting' ... 'System.Web.Mvc.HtmlHelper<dynamic>' ...
。Design/Runtime error

Reason : Telerik project template have no add the required using
Solution : fix/add the required using - Telerik.Reporting/Telerik.ReportViewer.Mvc

Telerik MVC Report Viewer Page Q2 2015

\Views\Home\Index.cshtml

@using Telerik.Reporting <------------- add this line
@using Telerik.ReportViewer.Mvc <------------- add this line
@{
  ViewBag.Title = "Telerik MVC HTML5 Report Viewer";
}
 


。System.Web.HttpException: The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "styles; scripts".
。Runtime error

Reason : Telerik project template not match to each other.
Solution : fix/add the @RenderSection 'styles' and 'scripts' in _layout.cshtml for report viewer page (ReportViewerView1.cshtml, etc)

Telerik C# ASP.NET MVC Application

\views\shared\_layout.cshtml

<html>
<head>
  <script src="@Url.Content("..."></script>
  @RenderSection("styles", false) <------------- LACK
</head>
<body>
  @RenderSection("scripts", false); <------------- LACK
  ...
  @RenderBody()
  ...
</body>
</html>

Telerik MVC Report Viewer Page Q2 2015 (Sample report definition)

@section styles
{
  ...
}

@section scripts
{
  ...
}


Caution : 
Maybe someone will copy the ReportLibrary and test it, 
you should check the .js file/path first (.cshtml code)
or you will get error at runtime - JavaScript runtime error: Object doesn't support property or method 'telerik_ReportViewer' :

Telerik Reporting Q2 2015 C# Examples Solution
C:\Program Files\Telerik\Reporting Q2 2015\Examples\CSharp\MvcDemo\Views\Home\Index.cshtml

  @section scripts
  {
    ...
    <script src="@Url.Content("~/ReportViewer/js/telerikReportViewer-9.1.15.731.js")"></script>  <----- .js not .min.js

Telerik MVC Report Viewer Page Q2 2015
\ReportViewer\js\telerikReportViewer-9.1.15.731.min.js  <------------- .min.js


http://www.telerik.com/forums/mvc-5-setup

=========================================
Visual Studio 2015
ASP.NET 4.6/MVC 5
Telerik UI for ASP.NET MVC Q2 2015 SP1


Best regards

Chris
0
Chris
Top achievements
Rank 1
answered on 31 Aug 2015, 07:21 AM
TelerikMvcApp31.7z - Telerik reporting sample (VS2015/MVC5) - Telerik C# ASP.NET MVC Application + Telerik MVC Report Viewer Page Q2 2015



0
Chris
Top achievements
Rank 1
answered on 31 Aug 2015, 07:23 AM
TelerikMvcApp31.7z - Telerik reporting sample (VS2015/MVC5) - Telerik C# ASP.NET MVC Application + Telerik MVC Report Viewer Page Q2 2015



0
Chris
Top achievements
Rank 1
answered on 31 Aug 2015, 07:34 AM

TelerikMvcApp31.7z -> png makes corrupt 

upload .zip .7z not allowed (wried)

 

If anyone need Telerik reporting sample for MVC5 maybe you can leave a message(e-mail, etc)

0
Nasko
Telerik team
answered on 01 Sep 2015, 01:59 PM
Chris,

The MVC Report Viewer item template is not fully automatic and you will need to make some manual adjustments so it fits your MVC project structure.
Your third reply sums up the steps to configure the viewer correctly, so I will mark it as the answer to your question. We have plans to improve the item template's behavior in the future.

Regards,
Nasko
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Nasko
Telerik team
Share this question
or