Report Toolbar Control

HOW TO
Use in DataView, Repeater, GridView and MS-SQL Reporting System
 
Page - Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Reportoolbar.aspx.cs" Inherits="Reportoolbar_Default" %>

<%@ Register Assembly="ncToolControls" Namespace="ncToolControls" TagPrefix="nc" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function CloseReport() {
            window.close();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">    
    <div>        
        <nc:ReportingToolBar ID="rptTB" PanelWidth=795 runat="server" align="center" />        
    </div>
    </form>
</body>
</html>
Code behind - Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Reportoolbar_Default : System.Web.UI.Page
{
    protected void Page_Init(object sender, EventArgs e)
    {
        this.rptTB.ArrayControlToPanel.Add("dropdownlist");
        this.rptTB.ArrayControlToPanel.Add("ddlStatus");
        this.rptTB.ArrayControlToPanel.Add("Status");
        this.rptTB.ArrayControlToPanel.Add("Active");
        this.rptTB.ArrayControlToPanel.Add("In-Active");
        this.rptTB.btnPDF.Enabled = false;
        this.rptTB.btnPDF.Visible = false;
     
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //this.ToolBar1.IncludeJsFile(this);
        this.rptTB.btnExecute.Click += new EventHandler(btnExecute_Click);
        this.rptTB.btnExcel.Command += btnExportToExcel_Click;
        this.rptTB.btnClose.Command += btnCloseToolBar_Click;
        if (!Page.IsPostBack)
        {
            this.rptTB.btnExcel.Enabled = false;            
            this.rptTB.btnPrint.Enabled = false;            
            
        }
        
    }
    protected void btnCloseToolBar_Click(object sender, EventArgs e)
    {
        Response.Write("<script language='javascript'>alert('" + Server.HtmlEncode("Close this page!") + "')</script>");
    }
    protected void btnExecute_Click(object sender, EventArgs e)
    {
        if (rptTB.ShowMonthYearPeriod != true)
        {
            if (this.rptTB.TxtDateStart.Text != string.Empty && this.rptTB.TxtDateEnd.Text != string.Empty)
            {
                this.rptTB.btnExcel.Enabled = true;                
                this.rptTB.btnPrint.Enabled = true;
                Response.Write("<script language='javascript'>alert('" + Server.HtmlEncode("Testing postback!") + "')</script>");
                Response.Write("<script language='javascript'>alert('" + Server.HtmlEncode("Selected Range Date " + this.rptTB.TxtDateStart.Text + " to " + this.rptTB.TxtDateEnd.Text) + " Status="+ this.rptTB.ddlDropDownFilter.Text +"')</script>");                
            }
            else
            {
                this.rptTB.btnExcel.Enabled = false;
                this.rptTB.btnPrint.Enabled = false; 
                Response.Write("<script language='javascript'>alert('" + Server.HtmlEncode("Must specify a valid date range") + "')</script>");
                this.rptTB.TxtDateStart.Focus();
                return;
            }
        }        
    }
    protected void btnExportToExcel_Click(object sender, EventArgs e)
    {
        Response.Write("<script language='javascript'>alert('" + Server.HtmlEncode("Exporting to Excel - Must specify a valid date range") + "')</script>");
    }    
}

Add Feedback