I'm trying to show reports with MVC3 and using razor. I found links on internet where you only download the reports without showing a preview: For example, but I would like to show a preview using the ReportViewer. Searching again i found this other example where a guy made a version for Mvc2 and VS2008 and it worked fine, but when i changed to Mvc3 i got a infinite loading bar showing the ReportViewer. Here is the ReportViewer for Mvc3.
Here are some files:
Report.aspx
<%# Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Home Page
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
Print this...
</asp:Content>
Index.aspx
<%# Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Home Page
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
Print this...
</asp:Content>
Any help with Mvc3 ReportViewer.
Ps: Dont want use Telerik and others paying libraries.
Thanks in advanced.
ReportViewer is a server control and can't be added into a razor view. You can added a ReportViewer into any ASPX view page or view user control.
See my answer to this question for more details.
Related
I have an asp.net site, .net 4 framework. I'm trying to get the ckeditor up and running. Sorry, I'm a bit new to the ckeditor. There is a quick start guide here that shows you how to implement:
http://docs.ckeditor.com/#!/guide/dev_installation
I originally thought the editor wasn't showing the toolbar. However, after further debug, I believe the ckeditor isn't showing at all, and in fact, the textarea is still all that is showing.
I'm using the same code as on the example in the website. I've reposted that here:
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace('editor1');
</script>
I've included the script ckeditor.js script this way:
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="DefectEntry3.aspx.cs" Inherits="DefectWriter.DefectEntry3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script src="App_Data/ckeditor/ckeditor.js"></script>
I'm sure I'm making a simple mistake. Any help is appreciated.
Thanks!
Bob
I had the wrong path in the script source. Once I got the right path all is well.
I've got an ASPX page like this:
<%# Page Language="F#" %>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<%-- Try to output "This is a Test" 10 times --%>
<% for i = 1 To 10 do %>
<p>This is a test</p>
</body>
</html>
and a web.config that looks like this:
<?xml version="1.0"?>
<configuration>
<system.codedom>
<compilers>
<compiler language="F#;f#;fs;fsharp"
extension=".fs"
warningLevel="4"
type="Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider,
FSharp.Compiler.CodeDom, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=a19089b1c74d0809">
<providerOption name="CompilerVersion" value="v4.0" />
<providerOption name="WarnAsError" value="false" />
</compiler>
</compilers>
</system.codedom>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
</configuration>
When I run my VS2010 WebApp, I get an error like this:
"The CodeDom provider type "Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider,
FSharp.Compiler.CodeDom, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=a19089b1c74d0809" could not be located."
I've tried the settings mentioned by manojlds here, but they don't seem to be working for me either. I think it is because my copy of VS2010 Pro has a newer version of the F# compiler, but I don't know how to tell for sure.
Can someone help me understand the correct version settings that I should use in a VS2010 web.config for the "compiler" and "providerOption" elements?
I have not tried this, but your configuration file looks correct to me - can you check what eversion of the FSharp.Compiler.CodeDom assembly is installed in your GAC (by looking at C:\windows\assembly)?
However, at the moment, I would not really recommend using F# for writing of the ASPX part of a web page. It works, but you won't get as smooth experience when mixing C# with ASPX or using the Razor templating engine (for ASP.NET MVC).
I think the best way to create server-side ASP.NET web applications in F# is to use F# for the code behind (in traditional WebForms) or for the model and controller parts (in MVC). There is also a number of templates and tutorials that describe how to do this:
Tutorial: Creating a Web Project in F# Using an Online Template
and templates for ASP.NET MVC 4 and older ASP.NET MVC 3
You might also want to check out the Web Stacks page on fsharp.org
I have tried implementing this, but the extension methods are not working when I rewrite them in VB. I am trying to use a corporate master page in my MVC3 application. Right now I have my .Master and my .ascx page. I am confused on how to get it to show in my razor view.
my .ascx page:
<%# control Language="VB" Inherits="System.Web.Mvc.ViewUserControl" %>
<asp:Content ID="Content" ContentPlaceHolderID="ContentArea" runat="server">
<div>
Hello World
</div>
</asp:Content>
When I run it, it gives me this error: Content controls have to be top-level controls in a content page or a nested master page that references a master page.
I use my _ViewStart.vbhtmlto call on the .ascx page.
Trying to hack webforms objects to work with MVC3 is only going to cause you trouble down the road. Redo the file as an MVC3 layout using razor.
Edit: added
Layout File Tutorials:
Making layout pages
Understanding Layout Files
Layouts and Sections
I'm attempting to do what Scott Hanselman describes below:
http://www.hanselman.com/blog/MixingRazorViewsAndWebFormsMasterPagesWithASPNETMVC3.aspx
I have a Web Form user control with code behind that is called from the Web Form and Razor Master Pages that is not working in the Razor layout:
<div id="navtop">
#{ Html.RenderPartial("~/Controls/MasterPageMenu.ascx"); }
</div>
The user control contains the following:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="MasterPageMenu.ascx.cs" Inherits="Controls.MasterPageMenu" %>
I get the error:
The view at '~/Controls/MasterPageMenu.ascx' must derive from ViewPage, ViewPage, ViewUserControl, or ViewUserControl.
What have I missed in getting this to work in the Razor view world?
This should work, just make sure that your partial derives from ViewUserControl:
<%# Control
Language="C#"
Inherits="System.Web.Mvc.ViewUserControl"
%>
Remember that using server side controls in ASP.NET MVC is not something that's recommended even with the WebForms view engine and not something that you should even be attempting to do. In ASP.NET MVC you have layouts (master pages if you use WebForms view engine), views and partials. That's all. User controls belong to classic WebForms, not to ASP.NET MVC.
I had the idea a while back to put all of my taglib declarations (uri's, etc) in a common header file so I don't have to manually write them into all of my JSPs. Initially, things seemed fine, although I don't use the actual taglibs as much as just the simple EL syntax. However, I'm having trouble in all jsp files except for the one that explicitly has the taglibs declared. All of the other jsp's (that include the header file) treat the <c:something.../> tag as if it's HTML and don't evaluate it. I did some googling and found this post on O'Reilly suggesting that what I'm trying to do can be done, but I'm clearly doing something wrong. What's more is that the other stuff in the header file (common page headers, page titles, etc.) all show up fine. The header file and a sample of the inclusion are below.
Header file:
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%# page session="false" %>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%# taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%# taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
Inclusion statement:
<jsp:include page="/WEB-INF/jsp/include/header.jsp">
<jsp:param name="title" value="Home" />
</jsp:include>
This is expected behaviour.
When you use <jsp:include>, it executed the target in a separate request, and then includes the output in the including JSP. It doesn't include the source of the included target, it includes the output. The means by which that target output is generated is lost.
To do what you're trying to do, you need to use <% include %> directives:
<%# include file="/WEB-INF/jsp/include/header.jsp" %>
This will incline the literal text of header.jsp into your page. Of course, by doing that, you can no longer pass parameters to it, so you'd need to set that as a page context attribute (e.g. using <c:set>... but of course you can't use <c:set> until you've done your include...).
Essentially, it's not really worth the hassle. Taglib declarations are annoying boilerplate, but hard to get rid of.