使用 ASP.NEТ MVC
在 ASPX (MVC 2) 中使用 WebReport 不會(huì)有任何問題,只需將控件從工具箱拖到頁(yè)面即可。WebReport 會(huì)自動(dòng)對(duì) web.config 進(jìn)行所有必要的更改。讓我們看看在 aspx 中使用 WebReport 的演示,可以在文件夾 \Demos\C#\MvcDemo 中找到。
要在 Razor (MVC 3,4) 中使用 WebReport,您需要在網(wǎng)絡(luò)應(yīng)用程序根目錄下的 web.config 文件中添加一行處理程序定義。
在<system.web>部分添加此行,以便與IIS6一起使用:
<add path="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport" />
并在 <system.webServer> 部分添加此行,以便與 IIS7 一起使用:
<add name="FastReportHandler" path="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport" />
然后修改包含 Views 文件夾中的 web.config 文件。在 <system.web.webPages.razor> 部分添加以下幾行:
	<add namespace="FastReport" />
<add namespace="FastReport.Web" /> 
在文件 _Layout.cshtml 的標(biāo)記 :
	@WebReportGlobals.Scripts()
 @WebReportGlobals.Styles() 
現(xiàn)在可以在視圖上繪制報(bào)告了。轉(zhuǎn)到控制器并創(chuàng)建一個(gè) WebReport:
WebReport webReport = new WebReport(); // create object
webReport.Width = 600;  // set width
webReport.Height = 800; // set height
webReport.Report.RegisterData(dataSet, "AppData"); // data binding
webReport.ReportFile = this.Server.MapPath("~/App_Data/report.frx");  // load the report from the file
ViewBag.WebReport = webReport; // send object to the View
	點(diǎn)擊復(fù)制
	
@ViewBag.WebReport.GetHtml()
您也可以直接在 View 中編寫類似的代碼來創(chuàng)建 WebReport。
讓我們看看 Razor 中 WebReport 的演示,它位于 \Demos\C#\MvcRazor 文件夾中。這里有各種加載到報(bào)告中的示例,包括預(yù)先準(zhǔn)備好的,還有一個(gè)使用事件 StartReport 的示例。
別忘了在 bin 目錄中添加丟失的 dll。
點(diǎn)擊復(fù)制
	
如需下載fastreport最新試用版,請(qǐng)點(diǎn)產(chǎn)品名跳轉(zhuǎn)產(chǎn)品下載頁(yè)>>

 QQ交談
QQ交談 在線咨詢
在線咨詢 
                 
                
 渝公網(wǎng)安備
            50010702500608號(hào)
渝公網(wǎng)安備
            50010702500608號(hào)
             
            
 客服熱線
客服熱線