Archive

Archive for the ‘C# Code Snippets’ Category

1 Line Notes 2 Self

1. Cryptographic errors are usually a missing snk file – look in AssemblyInfo.cs to find out where it should be.

Categories: C# Code Snippets

Visual Studio Go Faster Techniques

The trick of the year supplied by Paul is to drag code from your active cs (or vb) page into the Toolbox sidebar. This is far better than using the snippets feature that VS supplies yet, as far as I can see, is not a widely known super feature.

The snippets seemed great when VS was released (just right click on a coding surface and select one) but having your superior custom code available in the Toolbox is the bees knees.

Another performance trick (if somewhat obvious) is to add debug and view windows as tabs at the bottom of the development page. For example:

    Immediates Window
    Call Stack
    Breakpoints
    Pending Checkins
    Watch1
    FindResults1

To achieve this in VS2005+, right click on each window to make them dockable then drag the window down to the bottom status bar. Use Auto Hide to keep tidy.

Here is a way to speed things up by using shortcut keys.

PopulateHTMLTable()

public void PopulateHTMLTable()

{

    int numrows = 5;

    int numcells = 7;

    for (int j = 0; j < numrows – 1; j++)

    {

        HtmlTableRow r = new HtmlTableRow();

        for (int i = 0; i < numcells – 1; i++)

        {

            HtmlTableCell c = new HtmlTableCell();

            c.InnerHtml = “Created from” + Environment.NewLine + “code behind”;

            //c.Controls.Add(new LiteralControl(”row ” + j.ToString() + “, cell ” + i.ToString()));

            r.Cells.Add(c);

        }

        this.Table1.Rows.Add(r);

    }

}

Categories: Populate HTMLTable
Follow

Get every new post delivered to your Inbox.