Download pages as PDF In MVC3 Razor - asp.net-mvc

I have a MVC3, Razor engine application having 8 different views(.cshtml).I have these pages for users to enter personal details and other things.I have a requirement to download the content of all these 8 pages(.cshtml) as shown in browser in a button click as a single PDF file and save it.The pages(.cshtml) contains controls like dropdownbox,calender,radio button etc.Some of the contents in the views are loaded from models.

You can try using synchronised pechkin which is available as a nuget package.
This works on html so you can use a templating engine like RazorGenerator to convert Razor views to html.

Related

Generate a View/Page from a model in Blazor with Visual Studio

I am very new to Blazor and i am wondering if there is a way to generate a View from a Model and his Controller like with Razor to develop faster. In Visual Studio it is possible by right clicking on View Folder and choosing the Controller that we want.
Imagine having a User Model with data like Name, Adress etc. In Razor it is possible to generate a View (HTML, JS) containing those attributes related to User by choosing the model that we want (Edit, Create, Delete, etc).Then a complete form will show up with a generated HTML and JS in Pages Folder.
After a whole night of searching I found that this option given by Visual Studio is related with Scafolding and it is only avalaible for Blazor Server Side and Blazor Hosted applications. More information in the Syncfusion documentation

Using Crystal Report in MVC(ASP.net) application...(Not using *.aspx file)

Any good idea to use crystal report with MVC(ASP.net) application as a normal view like *.cshtml ,instead of *.aspx page.
Ok...Thanks Raphael...So final solution is,
In MVC3 directly cannot use ReportViewer Control from *.chtml page.Can use report in two ways
Create an pdf file on fly from your control class Or
Create a aspx page from where you can show your report using report viewer.
Sample application with crystal report and MVC3 ,can check this.
http://code.msdn.microsoft.com/Using-Crystal-Report-in-bb0e6229
It isn't possible to directly use reportviewer inside razor pages. Here you have a link that gives you 2 workaround
Using Reportviewer Control, within a Razor view, in the MVC3 Framework

integrating static html/css pages to an asp.net mvc project?

I am working for a personal project (Creating a website). I finished the design, then i converted all the pages to static html/css pages, after that i added some javascript. now I am with the final stage making the site dynamic i mean integrating the html/css pages to be an Asp.net MVC project with c# code that generates the content. even if i can tinker, but i prefer to be more methodical. so i am asking you for any guidelines how to do it ? and what the things i need to keep in mind to make this conversion ?
I am going to document my experience doing this here. It's going to be a incomplete and / or incorrect answer until I'm done with the process in a few days. I'm assuming Visual Studio 2012.
Create a new MVC 4 Internet Application project.
Add a method to the home controller for each static page.
Right click on each method and select Add View.
Open the images folder in VS and delete every item (from inside VS)
Drag all static site images into images project folder and add to project.
Replace contents of Site.css with static site css.
Paste the html from each page into the corresponding view. Leave the ViewBag.Title code block alone.
(still incomplete)

ReportViewer in MVC 4 partial

I am still unsure the best way to go about it.
I've read alsorts of resources, yet still no closer to a working solution.
I created a partial ASCX file. Added Report viewer to it, then rendered said partial in my CSHTML file. This was the closest I have come. In that I can see the report viewer, buttons etc. But for some reason the data never shows.
I have tried ASPX page inside an IFrame But this is not the way I want to go, about making this solution work.
Loading an ASPX page outright. But I lose my _Layout.cshtml main page style.
Some people suggest changing all sorts of things in config / Global.asax where as some say its not even necessary.
Ideally I want to have it as a partial in a page. But can deal with it being the only thing on the page, if I keep my main layout.
My experience with the older syntax / pages / non-MVC is limited to this project - trying to get this to work.
My data is linked through the components setup. The connection works fine in aspx page, as single page or iframe. But not in ascx.
The ReportView control requires ViewState to be enabled. In ASP.NET MVC such notion no longer exists. This means that you cannot use this control inside a native ASP.NET MVC view or partial. You can use it only in a classic WebForm (not in an ASP.NET MVC View) and the embed this WebForm inside an iframe within your current ASP.NET MVC view or partial. You have the possibility to render the report as an image for example and directly stream it to the response without using this control. Here's a blog post which illustrates the technique. So you could have a controller action which generates the report as a JPEG image and then link to this controller action from your view using the <img> tag. Unfortunately this makes only a static copy of the report and the user cannot interact with it.
You might also checkout this blog post which illustrates how you could run ASP.NET MVC and classic WebForms side by side.

MVC - Opening an asp.net page from the controller

I don't know if this is possible.
Can I have a mvc controller open a popup asp.net page? The asp.net page is within the mvc application, it's basically to run a crystal report viewer.
What happens just now is the mvc view loads and lists reports, then when a report is clicked it launches and exports to pdf. We now want this embedded in a web page instead of exporting to pdf(for various reasons one being no local download of the pdf report).
So sfter reading up i came across the solution to use a folder within the mvc app and use a webform in there. Now I'm trying to find how to open the .aspx pop-up from the controller where the report viewing is initiated.
Does that make any sense.
Any links/help is appreciated
Controllers in ASP.NET MVC are not supposed to open popups. You could do this using javascript inside the view. The window.open javascript function could be helpful:
window.open('/report.aspx', 'report');

Resources