New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of .NET
C#
http://codepaste.net/recent
by http://codepaste.net/mysnippets   Yesterday @ 3:15am
5 Views
no comments
 
' I watched Karl's video about validation with custom rules, and wondered
' why Silverlight, ASP.NET and ASP.NET MVC had DataAnnotations, and
' WPF only had IDataErrorInfo. So I thought of using EF4 as the model,
' and generating a metadata class like in RIA, MVC, etc for WPF and a
' inheritable generic class to convert the validations between IDataErrorInfo
' and the DataAnnotation attributes. 
'
' This way validation can happen the same way for each type of client!
'
' Let me know what you think please?
by rickrat   July 02, 2010 @ 3:54am
52 Views
no comments
 
Dim fc As New System.Drawing.Text.InstalledFontCollection
Fonts = (From x In Enumerable.Range(0, fc.Families.Count) _
         Select New With {.Id = x + 1, _
                          .Name = fc.Families(x).Name, _
                          .SortOrder = (x + 1) * 100}).ToList
fc = Nothing
by Thom Lamb   June 30, 2010 @ 10:54am
Tags: .Net, VB, Fonts, Linq
22 Views
no comments
 
 
Imports System.Net
Imports System.Net.NetworkInformation
Imports System.Threading
Imports System.Text
 
Public Class Form1
 
    Private Sub SimpleButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton1.Click
        MemoEdit1.Text = ""
by Thom Lamb   June 25, 2010 @ 10:13am
Tags: .Net, VB. Ping
23 Views
no comments
 
' Import ...
 
Public Module EnvironmentEvents
 
' Autogenerated code ...
 
    Private Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildDone
        If (DTE.ToolWindows.ErrorList.ErrorItems.Count = 0) Then
            SelectRootNode()
            DTE.ExecuteCommand("TestDriven.NET.RunTests")
by Dennis Traub   June 17, 2010 @ 9:40pm
48 Views
no comments
 
'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated from a template.
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
 
Option Compare Binary
by rickrat   June 13, 2010 @ 4:51pm
46 Views
no comments
 
Try
 
    Habanero.Base.GlobalRegistry.ApplicationName = "IGD"
    Habanero.Base.GlobalRegistry.ApplicationVersion = "v1.0"
    HabaneroApplication = New Habanero.UI.Win.HabaneroAppWin(Habanero.Base.GlobalRegistry.ApplicationName, Habanero.Base.GlobalRegistry.ApplicationVersion)
    HabaneroApplication.ClassDefsXml = IGD.BO.BOBroker.GetClassDefsXml()
 
    If Not HabaneroApplication.Startup() Then
        Throw New Exception("Unable to start Habanero Application")
    End If
by Mitchell William Cooper   May 30, 2010 @ 2:57pm
Tags: Habanero, ASP.NET,
31 Views
no comments
 
C#
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    Response.Write(DropDownList1.SelectedValue);
}
 
protected void ButtonSave_Click(object sender, EventArgs e)
{
    int n = SqlDataSource1.Insert();
    if (n == 1)
    Response.Redirect("ViewGuestBook.aspx");
May 14, 2010 @ 12:16am
Tags: ASP.net
27 Views
no comments
 
C#
public interface ICriteriaQuery<TEntity>
{
    DetachedCriteria Criteria { get; }
}
 
public interface ILinqQuery<TEntity>
{
    Expression<Func<TEntity, bool>> Expression { get; }
}
by Liam   May 13, 2010 @ 10:40pm
58 Views
no comments
 
C#
public static IEnumerable<TSource> Distinct<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> selector)
{
    return source.Distinct(new SelectorEqualityComparer<TSource, TKey>(selector));
}
by Paulo Morgado   April 10, 2010 @ 5:22am
65 Views
no comments
 
C#
public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> source, Func<TSource, TSource, bool> predicate)
{
    return source.Distinct(new PredicateEqualityComparer<TSource>(predicate));
}
by Paulo Morgado   April 10, 2010 @ 5:21am
71 Views
no comments
 
C#
[Serializable]
public class SelectorEqualityComparer<TSource, Tkey> : EqualityComparer<TSource>
{
    private Func<TSource, Tkey> selector;
 
    public SelectorEqualityComparer(Func<TSource, Tkey> selector)
        : base()
    {
        this.selector = selector;
    }
by Paulo Morgado   April 10, 2010 @ 5:18am
Tags: C#, .NET, .NET35, .NET40
76 Views
no comments
 
C#
[Serializable]
public class PredicateEqualityComparer<T> : EqualityComparer<T>
{
    private Func<T, T, bool> predicate;
 
    public PredicateEqualityComparer(Func<T, T, bool> predicate)
        : base()
    {
        this.predicate = predicate;
    }
by Paulo Morgado   April 10, 2010 @ 5:12am
Tags: C#, .NET, .NET35, .NET40
53 Views
no comments
 
C#
using System;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;
 
namespace MvcSamples.Html
{
    public static class UrlExtensions
by Bobby Diaz   April 08, 2010 @ 10:10pm
Tags: ASP.NET, MVC 2
205 Views
1 comments
 
C#
 
/*

Author: Mohammad Azam 
http://www.highoncoding.com 

This is a much better version than I demonstrated in the screencast! 

*/
by Mohammad Azam   March 29, 2010 @ 11:51am
169 Views
no comments
 
{
   "Fields":[
      {
         "FieldName":"Name",
         "ReplaceValidationMessageContents":true,
         "ValidationMessageId":"Name_validationMessage",
         "ValidationRules":[
            {
               "ErrorMessage":"Meno musí mať 5 až 40 znakov.",
               "ValidationParameters":{
by Jozef Izso   March 09, 2010 @ 7:37am
Tags: asp.net, mvc
118 Views
no comments
 
C#
//Classe I want to resolve from ILogger but want to register
public class AdvancedLogger : ILogger, IRequired
    {
    }
 
public class OtherClass : IOtherInterface, IRequired
    {
    }
 
by Thomas Jaskula   March 04, 2010 @ 2:00pm
47 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration;
 
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Data;
by Matt Slay   March 03, 2010 @ 12:56pm
61 Views
no comments
 
C#
public class URLRewriterModule : IHttpModule
    {
        /// <summary>
        /// You will need to configure this module in the web.config file of your
        /// web and register it with IIS before being able to use it. For more information
        /// see the following link: http://go.microsoft.com/?linkid=8101007
        /// </summary>
        #region IHttpModule Members
 
        public void Dispose()
by ZeroDotNet   February 22, 2010 @ 11:04pm
69 Views
no comments
 
XML
  <Target Name="AfterMerge">
  <ItemGroup>
    <JsFiles Include="$(TempBuildDir)\Scripts\infinitecarousel.js;$(TempBuildDir)\Scripts\jquery.autocomplete.js;$(TempBuildDir)\Scripts\core.js"/>
    <CssFiles Include="$(TempBuildDir)\Content\reset.css;$(TempBuildDir)\Content\infinitecarousel.css;$(TempBuildDir)\Content\Site.css" />
  </ItemGroup>
    
  <ReadLinesFromFile File="%(JsFiles.Identity)">
    <Output TaskParameter="Lines" 
            ItemName="jsLines"/>
  </ReadLinesFromFile>
by ArranM   February 16, 2010 @ 2:25pm
458 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text.RegularExpressions;
using System.Reflection;
using Activity_Search.Code;
 
namespace Activity_Search.Controllers
February 09, 2010 @ 5:31am
80 Views
no comments
 
    /// <summary>
    /// Extension methods on HtmlHelper and UrlHelper that provide strongly-typed access to URLs and ActionLinks for AccountController actions
    /// </summary>
    public static class HelperExtensionsForAccountController
    {
        /// <summary>
        /// Html Helpers for Controller = Account
        /// </summary>
        public static AccountControllerActionLinks Account(this HtmlHelper htmlHelper)
        {
by Ian   February 07, 2010 @ 7:29pm
339 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Security;
using System.Security.Permissions;
using System.IO;
using System.Security.Policy;
by bnaya   February 05, 2010 @ 11:40am
37 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security;
using System.Security.Permissions;
 
[assembly: AllowPartiallyTrustedCallers]
[assembly: SecurityRules(SecurityRuleSet.Level2)]
namespace TransparentSecurity
by bnaya   February 05, 2010 @ 3:35am
93 Views
no comments
 
C#
using System;
using System.Collections.Specialized;
using System.Web;
using System.IO;
 
namespace ConfigFileExample.Services
{
    public interface IConfigurationManager
    {
        NameValueCollection AppSettings { get; }
by Bob Cravens   February 03, 2010 @ 2:46pm
160 Views
2 comments
 
brought to you by:
West Wind Techologies


If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate