Fondamentalmente voglio sapere come incorporare un report in MVC.Net 2.Come usare ReportViewer 2010 a MVC.NET 2
risposta
ho fatto la domanda, perché non c'è abbastanza informazioni sul web, o delle informazioni non è così completo da poter iniziare a lavorare.
La prima cosa che devi sapere è che il visualizzatore di report è un webcontrol quindi non puoi usarlo su MVC, quindi la prima cosa che devi fare è creare un modulo web in modo da poter aggiungere il visualizzatore di report. Nell'esempio che ho fatto sto usando Visual Studio 2010.
il modulo web assomiglia a questo:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Report Viewer</title>
</head>
<body>
<div style="width: auto;">
<form id="form1" runat="server" style="width: 100%; height: 100%;">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="rptViewer" runat="server" Width="100%" Height="100%" AsyncRendering="False"
SizeToReportContent="True">
</rsweb:ReportViewer>
</form>
</div>
</body>
</html>
Il codice dietro del modulo web:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
var reportServer = ConfigurationManager.AppSettings["ReportServer"].ToString();
var reportPath = ConfigurationManager.AppSettings["ReportPath"].ToString();
rptViewer.ServerReport.ReportServerUrl = new Uri(reportServer);
rptViewer.ShowToolBar = false;
rptViewer.ServerReport.ReportPath = reportPath + Request.QueryString["ReportName"];
List<ReportParameter> parameters = new List<ReportParameter>();
string[] keys = Request.QueryString.AllKeys;
for (int i = 1; i < Request.QueryString.Count; i++)
{
parameters.Add(new ReportParameter(keys[i], Request.QueryString[i]));
}
this.ReportViewer1.ServerReport.SetParameters(parameters);
this.ReportViewer1.ProcessingMode = ProcessingMode.Remote;
this.ReportViewer1.ShowParameterPrompts = false;
this.ReportViewer1.ShowPromptAreaButton = false;
this.ReportViewer1.ServerReport.Refresh();
rptViewer.ProcessingMode = ProcessingMode.Remote;
rptViewer.ServerReport.Refresh();
}
}
Ora abbiamo bisogno usare il MVC. Abbiamo due opzioni, apriamo una nuova finestra con un javascript pop up o usiamo un iframe.
farò entrambe in modo da poter avere una migliore idea sul Vista:
<iframe id="Frame1" src="<%= Session["Url"] %>" width="230" height="230" frameborder="0"></iframe> **1
function OpenReports(name) {
var width = (screen.availWidth - 700).toString();
var height = (screen.availHeight - 100).toString();
window.open('/Reporting/Reports.aspx?ReportName=' + name,
'mywindow', 'width=' + width + ',height=' + height + ',toolbar=no,location=no,directories=yes,status=no,' +
'menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes' + ',screenX=0,screenY=0,left=0,top=0');
} **2
** 1 SessionURL è una variabile di sessione con il percorso e il rapporto che vogliamo mostrare. Anche questo è il primo modo per incorporare il report utilizzando un iframe
** 2/Report /Reports.aspx è il percorso del webform che abbiamo appena realizzato. Questo è il secondo modo, l'apertura di una nuova finestra.
Nel Controller:
public ActionResult ViewName()
{
Session["Url"] = "/Reporting/Reports.aspx?ReportName=Report44";
return View();
}**1
** 1 /Reporting/Reports.aspx è il percorso del modulo web abbiamo appena fatto eaelier.
Anche Se usate Report Viewer 10 ricordatevi questa funzionalità nel web.config:
<system.web>
<httpHandlers>
<add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpHandlers>
</system.web>
Spero tutto questo tutorial aiuta qualcuno :)
- 1. ReportViewer 2010, IO.Exception \
- 2. ASP MVC.NET - come associare KeyValuePair?
- 3. Come usare Mercurial da Visual Studio 2010?
- 4. Come passare ObjectId da MongoDB in MVC.net
- 5. Stampa un ReportViewer senza anteprima
- 6. Angular 2, come usare setTimeout?
- 7. File robots.txt in MVC.NET 4
- 8. Come aggiungere il file rdlc a ReportViewer nei progetti WPF
- 9. ReportViewer orientamento della pagina
- 10. ReportViewer - Nascondi esportazione PDF
- 11. Pulsante di stampa non visibile in ReportViewer
- 12. Come forzare Play framework 2 a usare sempre SSL?
- 13. Come usare orderby con 2 campi in linq?
- 14. reportviewer, Barra errato
- 15. ReportViewer in MVC 4 parziale
- 16. Come devo usare @types con dattiloscritto 2
- 17. come usare addPreferencesFromResource per Android 2.X?
- 18. Microsoft ReportViewer Web Control richiedono uno ScriptManager
- 19. Errore parser Microsoft ASP.NET ReportViewer
- 20. Esportare il controllo del reportviewer C# a livello di programmazione
- 21. Come si cerca manualmente una rotta in RouteTable MVC.Net?
- 22. Accesso ai valori del percorso in vista Mvc.net
- 23. VS ReportViewer RDLC - come impedire a una tabella di spingere verso il basso altri elementi?
- 24. Java a Excel 2010
- 25. Utilizzo di SSRS con ASP.Net ReportViewer
- 26. ReportViewer che mostra immagini danneggiate in Chrome
- 27. Utilizzo di MS ReportViewer in WPF
- 28. Origine dati Reportviewer in asp.net-mvc
- 29. Indicatore di caricamento del controllo di ReportViewer?
- 30. Voglio usare NumPy/SciPy. Dovrei usare Python 2 o 3?
Lo ha fatto aiutare qualcuno - mi. Grazie mille. – Peanut
Riguardo a "La prima cosa che devi sapere è che il visualizzatore di report è un controllo web quindi non puoi usarlo su MVC", questo non è corretto come una dichiarazione generale. [Puoi far funzionare i controlli web in MVC.] (Http://blogs.teamb.com/craigstuntz/2009/05/12/38297/) Non l'ho ancora provato con il visualizzatore di report. –
mi ha aiutato molto. Grazie, Sergio. – AEMLoviji