Welcome To Snipplr


Everyone's Recent C# Snippets



This class uses static methods to create html controls on the fly in .NET
2 1599 posted 16 years ago by mpcircuitry
This will delete all items in a SharePoint list. Better than looping through a SPListItemCollection and doing a .delete();
0 1668 posted 16 years ago by blackf0rk
In DB.GetData(select) is executed new SqlDataAdapter(Select, dbConnection).Fill(table)
0 1152 posted 16 years ago by tomaszsimon
Great way to show the user that something is happening without too much tedious work. As simple to use as putting the following code in Form_Load: AutoWaitCursor.Cursor = Cursors.WaitCursor; AutoWaitCursor.Delay = new TimeSpan(0, 0, 0, 0, 25);...
1 3121 posted 16 years ago by pckujawa
Call it in the button click event after in(de)crementing CurrentPage value
0 995 posted 16 years ago by tomaszsimon
For .net 2.0+ The one limitation to enumerations is revealed when you try to reverse lookup an enumeration value using Enum.Parse(). The parse function will return an inconsistent enum object if ever there are two or more enumerations with the same...
0 1819 posted 16 years ago by bryanlyman
In order for the code snippet(s) to work, you need to do the following: 1. Go download the EWS API SDK: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=c3342fb3-fbcc-4127-becf-872c746840e1 2. Install the SDK on your machin...
0 1432 posted 16 years ago by blackf0rk
Will disable the button and still allow the postback event
0 1259 posted 16 years ago by derekholmes
The code is run in [LINQPad](http://www.google.com/url?sa=t&source=web&ct=res&cd=1&ved=0CAsQFjAA&url=http%3A%2F%2Fwww.linqpad.net%2F&ei=exUgS-a-KZOotgOs39T9CQ&usg=AFQjCNFw-ZpPkP4je7u9udiur5Wg5us7tQ&sig2=gA-_2y2xnTKzK2A9CVxXfg), which is where the Dum...
1 1533 posted 16 years ago by pckujawa
References: [msdn blog](http://blogs.msdn.com/youssefm/archive/2010/01/21/how-to-change-net-configuration-files-at-runtime-including-for-wcf.aspx), [devX](http://www.devx.com/dotnet/Article/41639/0/page/1) The .NET framework provides XML configura...
2 11079 posted 16 years ago by pckujawa
I used this code to run MySQL commands in ASP.NET
1 1968 posted 16 years ago by mpcircuitry
There's no built-in "loop" property on the Silverlight mediaElement control. Add a listener to any mediaElement and this function will loop it.
0 1179 posted 16 years ago by johnlync
In order to accurately get the next ID from a SharePoint list you need to access the content database for one reason: If you delete all the items from a list, and execute this simple code: list.Items[list.ItemCount -1].ID) + 1 the ID will always retu...
0 1330 posted 16 years ago by blackf0rk
0 1067 posted 16 years ago by wearetherock
0 949 posted 16 years ago by wearetherock
This snippet builds on my last snippet regarding [User input validation in Visual Studio .NET using MaskedTextBoxes and an ErrorProvider](http://snipplr.com/view/22419/user-input-validation-in-visual-studio-net-using-maskedtextboxes-and-an-errorprovi...
0 2539 posted 16 years ago by pckujawa
I just discovered that the MaskedTextBox control allows you to set the type of data which should be entered in the control and helps you do the validation of that data when necessary. The trick is to set the ValidatingType of the MaskedTextBox contro...
0 8733 posted 16 years ago by pckujawa
In case you find yourself parsing a string with unrecognizable ASCII character codes, use the regex below to replace them. The pattern matches only the valid keyboard symbols.
1 1256 posted 16 years ago by arangil
To display "&" character within the string used as error descriptor in ErrorProvidor component in .NET use "&&&" so that it displays as a single "&". More detail at: http://www.codeproject.com/Messages/3225091/ErrorProvider-SetError-string-constra...
0 1854 posted 16 years ago by sysdeamon
[Credit - Sam Allen, Dot Net Perls](http://dotnetperls.com/remove-html-tags)
2 2017 posted 16 years ago by jasonseney
1 1384 posted 16 years ago by jasonseney
A style of code reuse. Breaking methods (in this case MVC controller) into very small reusable atomic chunks that either perform an operation then return an ActionResult OR return null, then using with the null-coalescing operator.
0 1300 posted 16 years ago by jmcd
Useful in cases where the object author has specified their own serialization that doesn't work for you.
1 1672 posted 16 years ago by rengber
Definitely falls into the category of "simple thing I shoulda memorized years ago", but whatever:
0 1342 posted 16 years ago by rengber