.NET, ASP, Windows



ASP.NET Excel Function

This function written in c# builds a MS excel out of a dataSet.

    private DataSet dataSet = new DataSet();
    private DataView dView = new DataView();
 
    private void LoadPeople()
    {
        SqlConnection conn = new SqlConnection("Data Source=asdf;User ID=asdf;Password=asdf;Database=Directory");
        SqlDataAdapter dAdapter = new SqlDataAdapter("SELECT * FROM People", conn);
        dAdapter.Fill(dataSet, "peeps");
        dView.Table = dataSet.Tables["peeps"];
        personel_cnt = dView.Count;
        dView.Table.Columns.Add("is_a_member");
        conn.Close();
    }
 
    private void buildExcelReport()
    {
        DataSet dsExport = dataSet;
        System.IO.StringWriter tw = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter hw =
           new System.Web.UI.HtmlTextWriter(tw);
        DataGrid dgGrid = new DataGrid();
        dgGrid.DataSource = dsExport;
 
        //Report Header
        hw.WriteLine("My Super Duper Excel Report");
        hw.WriteLine("<br>∓nbsp;");
        // Get the HTML for the control.
        dgGrid.HeaderStyle.Font.Bold = true;
        dgGrid.DataBind();
        dgGrid.RenderControl(hw);
 
        // Write the HTML back to the browser.
        Response.ContentType = "application/vnd.ms-excel";
        this.EnableViewState = false;
        Response.Write(tw.ToString());
        Response.End();
    }

Post Comment Now


IIS 6.0: How To Eliminate the Delay in Serving Updated ASP

Due to some new enhancements in IIS 6.0, users may encounter a significant delay before receiving the content on the page. This can be a great annoyance for the users and prevent them from visiting your site. To eliminate this delay, follow these instructions:

  1. Copy the following:
    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ASP\Parameters]
    "DisableLazyContentPropagation"=dword:00000001
    
  2. Open Notepad and paste the text.
  3. Save the text file and rename it to for example “IIS6_Delay_Fix.reg”.
  4. Merge the file into the registry by double-clicking it.
  5. Reboot.

Post Comment Now


Visual Studio Syntax Highlighting and Intellisense for Classic ASP

With the new release of Visual Studio (VS) 2005, you would think that it would have full support for classic ASP when working in a directory. This is not the case. There are some hacks out there, however none are fully functional and some require that you set the page directive on every page you want highlighting and intellisense. Of course this will break some of your pages.

For those who want the power of VS (mainly Intellisense), you still need to use vs 2003 until MS makes a fully functional .asp template for VS 2005.

This tutorial will walk you through the process of creating a Solution that allows you to edit your classic ASP in VS 2003. The site must be accessible though windows explorer (C:\ or mapped drives).

  1. Start VS 2003
  2. File > New > Blank Solution
  3. Name it “Classic ASP” or whatever. The location is where the link will be stored for opening the solution and all it’s projects.
  4. Add your sites…
  5. Right Click the Solution “Classic ASP”
  6. Add > New Project > Visual Basic Projects > New Project In Existing Folder
  7. Name it “My ASP Site 1″
  8. Click Ok
  9. Browse to the location of the root folder for that web site.
  10. Single click the project. From the VS menu bar, click Project > Show all Files (or click the second button in the solution Explorer)
  11. Repeat for all your sites/directories.



Now when you start the solution, all the sites and files will be listed from within VS 2003. You now have html, javascript, and vbscript intellisense. You also get param lists when you call functions/subs that are on the same working page. Sweet!

Notes:

  • VS will create a couple of files in the project directories (bin folder, .vbproj, .vbproj.user) . They are harmless and a small price to pay for the power of VS.
  • You may get a warning about a project not being fully trusted by the .NET runtime. That’s ok, we are not using .NET here anyway.

Post Comment Now


Blog | Contact | Gallery | Links | Sandbox | Social Networking | Weather | Web Design


Copyright © 1997-2009 KCSH. All rights reserved.