CodePaste Logo
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 Form
C#
// this code requires a reference to JSON.NET in your project
#if true
 
using System;
using System.Net.Http.Formatting;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Json;
using Newtonsoft.Json;
using System.IO;
by Rick Strahl   February 21, 2012 @ 6:23pm
671 Views
no comments
 
XML
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="PublishWeb" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
  <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
      <ClassLibraryOutputDirectory>bin$(Configuration)</ClassLibraryOutputDirectory>
      <WebProjectFile>$(ProjectFolder)\$(ProjectFile)</WebProjectFile>
  </PropertyGroup>
by Prithvi Ramana A   February 07, 2012 @ 10:18am
72 Views
no comments
 
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (HttpContext.Current.Request.IsAuthenticated)
    {
        ResetFormsAuthenticationTicket();
    }
    else
    {
        Response.Redirect("~/logout.aspx");
    }
by Kent   January 22, 2012 @ 7:26pm
43 Views
no comments
 
C#
static void Main(string[] args)
{
    Console.WriteLine(PhoneNumber("12345678901234"));
    Console.WriteLine(PhoneNumber("1234567890123"));
    Console.WriteLine(PhoneNumber("123456789012"));
    Console.WriteLine(PhoneNumber("12345678901"));
    Console.WriteLine(PhoneNumber("1234567890"));
    Console.WriteLine(PhoneNumber("123456789"));
    Console.WriteLine(PhoneNumber("12345678"));
    Console.WriteLine(PhoneNumber("1234567"));
by Jerry Nixon   December 06, 2011 @ 8:10am
Tags: C#, Format
105 Views
no comments
 
C#
string strFormatedGuid = Guid.NewGuid().ToString("N"); //Where N is the format, can be any of the ones described below
 
/*
Format: N
Output 32 digits:
00000000000000000000000000000000
 
Format: D
Output 32 digits separated by hyphens:
00000000-0000-0000-0000-000000000000
by Egli   August 02, 2011 @ 8:14pm
97 Views
no comments
 
C#
// create date time 2008-03-09 16:05:07.123
DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123);
 
String.Format("{0:y yy yyy yyyy}", dt);  // "8 08 008 2008"   year
String.Format("{0:M MM MMM MMMM}", dt);  // "3 03 Mar March"  month
String.Format("{0:d dd ddd dddd}", dt);  // "9 09 Sun Sunday" day
String.Format("{0:h hh H HH}",     dt);  // "4 04 16 16"      hour 12/24
String.Format("{0:m mm}",          dt);  // "5 05"            minute
String.Format("{0:s ss}",          dt);  // "7 07"            second
String.Format("{0:f ff fff ffff}", dt);  // "1 12 123 1230"   sec.fraction
by Egli   July 24, 2011 @ 10:54pm
96 Views
no comments
 
C#
// Just two decimal places
String.Format("{0:0.00}", 123.4567);      // "123.46"
String.Format("{0:0.00}", 123.4);         // "123.40"
String.Format("{0:0.00}", 123.0);         // "123.00"
 
// Max. two decimal places
String.Format("{0:0.##}", 123.4567);      // "123.46"
String.Format("{0:0.##}", 123.4);         // "123.4"
String.Format("{0:0.##}", 123.0);         // "123"
by Egli   July 24, 2011 @ 10:51pm
93 Views
no comments
 
XML
<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
by Aria Radmand   July 12, 2011 @ 5:12am
127 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using FizzWare.NBuilder;
using Microsoft.VisualStudio.TestTools.UnitTesting;
 
namespace Tests.Reporting
{
    [TestClass]
    public class DynamicXmlFormatting
158 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using FizzWare.NBuilder;
using Microsoft.VisualStudio.TestTools.UnitTesting;
 
namespace Tests.Reporting
{
    [TestClass]
    public class DynamicTextFormatting
    {
171 Views
no comments
 
SQL
select * from INFORMATION_SCHEMA.COLUMNS where table_name not like 'v%' order by TABLE_NAME, ORDINAL_POSITION
 
select * from INFORMATION_SCHEMA.ROUTINES
 
select * from INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
select * from INFORMATION_SCHEMA.KEY_COLUMN_USAGE
 
SELECT s.name [SPECIFIC_SCHEMA], o.name [SPECIFIC_NAME], s.name [ROUTINE_SCHEMA], o.name [ROUTINE_NAME], 
case when o.[type] in ('P', 'PC') then 'PROCEDURE' 
when o.type in ('V') then 'VIEW' 
by Thom Lamb   June 13, 2011 @ 8:10am
97 Views
no comments
 
// action code
$em = $this->get('doctrine')->getEntityManager();
        $categories = $em->getRepository('CMSBackBundle:Category')->findAll();
        
        $choices = array();
        
        foreach ( $categories as $k => $v ) {
            $choices[$v['id']] = $v['title'];
        }
        
by Darius   May 26, 2011 @ 5:38am
Tags: symfony2, form
316 Views
no comments
 
C#
const string PC_CATEGORY = "_Tmp";
const string PC_NAME = "_Tmp";
 
if (!PerformanceCounterCategory.Exists(PC_CATEGORY))
{
    CounterCreationDataCollection data = new CounterCreationDataCollection();
    CounterCreationData counter = new CounterCreationData(PC_NAME, "", PerformanceCounterType.NumberOfItems32);
    var pcCategory = PerformanceCounterCategory.Create(PC_CATEGORY, "", PerformanceCounterCategoryType.MultiInstance, data);
 
    data.Add(counter);
by bnaya   February 09, 2011 @ 12:45am
177 Views
no comments
 
XML
<Rectangle Width="100" Height="100" Fill="RoyalBlue" Margin="20">
    <Rectangle.RenderTransform>
        <TransformGroup>
            <ScaleTransform CenterX="50" CenterY="50" ScaleX="1.5" ScaleY="1.5" />
            <RotateTransform CenterX="50" CenterY="50" Angle="5" />
        </TransformGroup>
    </Rectangle.RenderTransform>
</Rectangle>
by Jerry Nixon   February 01, 2011 @ 4:35pm
292 Views
no comments
 
C#
namespace WindowsFormsApplication1
{
    public partial class Form1 : System.Windows.Forms.Form
    {
        public Form1()
        {
            InitializeComponent();
 
            // create list of data
            var _List = new System.Collections.Generic.List<Data> 
by Jerry Nixon   January 24, 2011 @ 2:17pm
1709 Views
1 comments
 
Produto    
    
Disco rigido  Samsung SATA 2 1TB 5400RPM                        R$ 183,00
Disco rigido  Samsung SATA 2 320GB P/NOTE 5400RPM               R$ 146,00
DVD-RW LG GH22NS50 SATA                                         R$ 50,00
DVD-RW LG SECURDISC IDE - Preto                                 R$ 70,00
Fone de Ouvido Philips - SHP2700/00                             R$ 83,00
Fonte Coletek ATX LC-8220BS2 200W 20+4 SATA                     R$ 38,00
Fonte Kmex ATX PX-300RMF 200W 20+4 SATA                         R$ 37,00
Fonte Kmex ATX PX-350RNF 230W 20+4 SATA                         R$ 39,00
by Thiago Pedro   September 07, 2010 @ 2:55pm
320 Views
no comments
 
C#
/// <summary>
/// Returns the content of the POST buffer as string
/// </summary>
/// <returns></returns>
public static string FormBufferToString()
{
    HttpRequest Request = HttpContext.Current.Request;            
 
    if (Request.TotalBytes > 0)            
        return Encoding.Default.GetString(Request.BinaryRead(Request.TotalBytes));
by Rick Strahl   August 19, 2010 @ 2:39pm
292 Views
no comments
 
XML
<ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    >
 
    <DataTemplate x:Key="SmallLogoTemplate">
        <Image ... />
    </DataTemplate>
 
    <DataTemplate x:Key="LargeLogoTemplate">
        <Image ... />
by George Ionita   June 22, 2010 @ 8:01am
156 Views
no comments
 
C#
public class YourPlugin : IPlugin
{
 
private static ResourceDictionary _Resources;
 
 
public static DataTemplate SmallIconTemplate
{
   get
   {
by George Ionita   June 22, 2010 @ 7:57am
179 Views
no comments
 
C#
int intValue = 1512;
string stringValue = intValue.ToString("#,#", CultureInfo.GetCultureInfo(Thread.CurrentThread.CurrentCulture.Name));
/* Result in US English (en-US) will be 1,512
   Result in Swedish (sv-SE) will be 1 512 */
by Robert Andersson   April 29, 2010 @ 4:53am
330 Views
no 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