Archive for the ‘ASP.NET/C#’ Category

ASP.NET: Hide Menu Items by Role with Security Trimming

Thursday, February 4th, 2010

ASP.NET makes authorizations and security fairly simple with its roleManager, Authentication, and SiteMap providers.  This quick hint only covers how to hide a particular menu item from the standard Menu and TreeList navigation components when using a SiteMap provider. (more…)

Popularity: 2%

C# – SQL Server Foreign Key, Unique constraints

Wednesday, May 27th, 2009

unique_key_constraintI got tripped up today with a particularly nasty Join statement that worked perfectly form 90% of the queries, but was blowing up at times.  The error message was: 

(more…)

Popularity: 11%

C# – Convert String Array to a List (.Net 2.0)

Tuesday, May 19th, 2009

ASP.netSo you’ve got a C# string and you want to convert it to a List<string>.  Lists are one of the most efficient ways of storing…well…lists of things in .Net.  If you’re in .Net 3.0, it’s quite easy to go from a string array to a list by using the .ToList() function.

(more…)

Popularity: 16%

ASP.NET – Get User Name Under Windows Authentication

Tuesday, March 3rd, 2009

ASP.netGetting the authenticated user’s name when using Windows Authentication with ASP.NET is very simple.  I just keep having to go back to Google or dig out an old project to remember it, so here it is:

(more…)

Popularity: 37%

Excel Spreadsheet of US States

Thursday, February 12th, 2009

Here’s a simple Excel spreadsheet of US States and their abbreviations.  I don’t know how many times I’ve recreated this blooming thing.  I just found myself, once again trying to find a decent table of states to put into my Supple Forms states drop down list, and after ten minutes and finally getting it into an nice Excel table, I figured it was time to memorialize it forever here.  So, no more hunting around.  Here you go:

(more…)

Popularity: 40%

Get ASP.NET DropDownList Selected Value with jQuery

Friday, October 31st, 2008

With Microsoft’s recent announcement that they will begin shipping jQuery with Visual Studio, the little Javascript framework is about to hit the big time (it was already sort of big time, but this is BIG TIME).  And rightfully so.

(more…)

Popularity: 71%

C# – Get a Random Number Between x and y

Friday, October 31st, 2008

Here’s a quick function for getting random numbers in C#:

    Random rnd = new Random();
    protected int GetRandomInt(int min, int max)
    {
        return rnd.Next(min,max);
    }

    int myInt = GetRandomInt(5, 1000); //gives in random integer between 5 & 1000

Notice that you have to declare your instance of the Random class outside of the GetRandomInt function if you are going to be running this in a loop.

(more…)

Popularity: 28%

ASP.NET – C# – Emulating the VB Control Array – Pt. 1

Wednesday, October 29th, 2008

For you veterans of VB6, the control array probably became an old friend, or at least an annoying neighbor if you didn’t like them.  You couldn’t help run across the concept in VB6 because every time you copy and pasted a control for the first time, you got asked if you wanted to create a control array.

(more…)

Popularity: 31%