Get Report Page Width In Asp.net

Hi Guys,

I am trying to get rid of webreport controller's scroll bars. I got rid of height scroll bar but couldn't get rid of width scroll bar yet. Therefore I am trying to get the report's page width and assign it to webreport controller's width parameter.

My code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FastReport;


namespace fastReportTestProject
{
public partial class WebForm1 : System.Web.UI.Page
{


protected void WebReport1_StartReport(object sender, EventArgs e)
{
WebReport1.Report.SetParameterValue("SystemUserId","00000001-d83e-4ed3-8ff7-e2ca1a89f96c");
WebReport1.Report.SetParameterValue("LanguageId","6a57491a-6c20-4184-97ea-1ceb5ea5b008");
WebReport1.Report.SetParameterValue("CurrencyId","00000014-4060-4325-88af-5f16ec548c2e");
WebReport1.Report.SetParameterValue("ContractHeaderId","0bfc8b2c-4ad6-4fb6-9c6e-cfaa0352fc6e");
WebReport1.Report.SetParameterValue("CurrencyRate",1);
WebReport1.Report.SetParameterValue("Type", 0);
WebReport1.Report.SetParameterValue("CurrencyId", "00000014-4060-4325-88af-5f16ec548c2e");
}

protected void Button1_Click(object sender, EventArgs e)
{
WebReport1.ReportFile = DropDownList1.SelectedValue;
WebReport1.Refresh() ;
}

protected void WebReport1_Init(object sender, EventArgs e)
{
Report report = new Report();
float size;
report.Load(Server.MapPath(DropDownList1.SelectedValue));
size=report.Pages[0].Width;

}

}
}


As you see in the code, in Init event I load my .frx file and try to get its first page width but when I debug this program I see that "report.Pages[0].Width" returns 0.0 . It response like it is an empty report. Do you have any ideas? Thnxxx.

Comments

  • edited 10:33AM
    ysfph wrote: »
    Hi Guys,

    I am trying to get rid of webreport controller's scroll bars. I got rid of height scroll bar but couldn't get rid of width scroll bar yet. Therefore I am trying to get the report's page width and assign it to webreport controller's width parameter.

    My code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using FastReport;


    namespace fastReportTestProject
    {
    public partial class WebForm1 : System.Web.UI.Page
    {


    protected void WebReport1_StartReport(object sender, EventArgs e)
    {
    WebReport1.Report.SetParameterValue("SystemUserId","00000001-d83e-4ed3-8ff7-e2ca1a89f96c");
    WebReport1.Report.SetParameterValue("LanguageId","6a57491a-6c20-4184-97ea-1ceb5ea5b008");
    WebReport1.Report.SetParameterValue("CurrencyId","00000014-4060-4325-88af-5f16ec548c2e");
    WebReport1.Report.SetParameterValue("ContractHeaderId","0bfc8b2c-4ad6-4fb6-9c6e-cfaa0352fc6e");
    WebReport1.Report.SetParameterValue("CurrencyRate",1);
    WebReport1.Report.SetParameterValue("Type", 0);
    WebReport1.Report.SetParameterValue("CurrencyId", "00000014-4060-4325-88af-5f16ec548c2e");
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
    WebReport1.ReportFile = DropDownList1.SelectedValue;
    WebReport1.Refresh() ;
    }

    protected void WebReport1_Init(object sender, EventArgs e)
    {
    Report report = new Report();
    float size;
    report.Load(Server.MapPath(DropDownList1.SelectedValue));
    size=report.Pages[0].Width;

    }

    }
    }


    As you see in the code, in Init event I load my .frx file and try to get its first page width but when I debug this program I see that "report.Pages[0].Width" returns 0.0 . It response like it is an empty report. Do you have any ideas? Thnxxx.

    Guys,

    I found the solution:

    You should get the report's page width in the init event and assign it to webcontrol.

    protected void WebReport1_Init(object sender, EventArgs e)
    {
    string form;
    form=Request.QueryString["form"];
    Report report = new Report();
    float paperWidthSizeCm;
    report.Load(Server.MapPath(form));
    ReportPage page1 = report.Pages[0] as ReportPage;
    paperWidthSizeCm = page1.PaperWidth / 10;
    WebReport1.Width = Unit.Parse(Convert.ToString(Convert.ToInt32(paperWidthSizeCm * 37.8)) + "px"); // Converting cm to px
    WebReport1.ReportFile = form;
    }

    By this technique you can view your report with just browser scroll bars.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.