Format:
Recent snippets matching tags of .Net
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Security.Cryptography; namespace Westwind.Web.Services { /// <summary> /// Implements the Gravatar API for retrieving a Gravatar image to display
216 Views
2 comments
<script type="text/javascript"> function CustomValidatorOmbudsmanNotifiedDate(s, args) { var dt = args.Value if (!dt && $("*[id$='OmbudsmanNotifiedFlag'] input:checked").val() == '1') { args.IsValid = false; } else { args.IsValid = true;
44 Views
no comments
Dim funcs = (From x In [Enum].GetValues(GetType(SummaryFunc)) _ Order By x _ Select New With {.ID = CInt(x), .Name = [Enum].GetName(GetType(SummaryFunc), x)}).ToList
62 Views
no comments
Module Module1 Public Enum PivotAction Sum = 1 Min = 2 Max = 3 Count = 4 End Enum Public Function Pivot(ByVal SourceTable As DataTable, _ ByVal PrimaryKeyColumn As String, _ ByVal PivotNameColumn As String, _
83 Views
1 comments
public float Value { get { object o = ViewState["Value"]; if (o == null) return 0; return (float)o; } set
47 Views
no comments
//Stored Guid as a string string strGuid = "5152A989-279F-4A81-AC68-4696966CD1E2" //Creating a GUID obj based on that guid string new Guid(strGuid);
74 Views
no comments
//using System.Web.UI //.aspx page must have a reference to jquery (for the example described bellow) string someScript= " $(window).bind('load', CodeToExcecute());"; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "someScript", someScript, true);
99 Views
no comments
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
70 Views
no comments
//using System.Globalization; CultureInfo culture = new CultureInfo("en-AU"); DateTime week_start = Convert.ToDateTime("27/07/2011", culture);
95 Views
no comments
//using System.Web; //to return "http://www.samplepage.com/Egli/index.aspx" string url = HttpContext.Current.Request.Url.AbsoluteUri; //to return "/Egli/index.aspx" string path = HttpContext.Current.Request.Url.AbsolutePath; //to return "www.samplepage.com" string host = HttpContext.Current.Request.Url.Host;
124 Views
no comments
<!--Place this under the <system.web> node--> <httpRuntime executionTimeout="1200" maxRequestLength="30720" />
102 Views
no comments
/* Note to reader: There are two server variables of interest; REMOTE_ADDR and HTTP_X_FORWARDED_FOR. As many visitors access the internet via a third party (ie their ISP), REMOTE_ADDR does not always contain their IP address... it contains their ISP's address. If this is the case, most browsers then store the users IP address in the HTTP_X_FORWARDED_FOR variable. So, first, we check HTTP_X_FORWARDED_FOR, and then if that is empty, we try REMOTE_ADDR instead: */ string IP_Address = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if(String.IsNullOrEmpty(IP_Address)) {
82 Views
no comments
// 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
69 Views
no comments
// 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"
71 Views
no comments
//using System.Web.Security
FormsAuthentication.SignOut();
87 Views
no comments
<asp:ListView ID="ListView_Example" runat="server" > <LayoutTemplate> <ul> <asp:PlaceHolder ID="PlaceHolder_Example" runat="server" /> </ul> </LayoutTemplate> <ItemTemplate> <li> <a href="<%=Eval("ExampleLink")%>"><%=Eval("ExampleName")%></a><%=Eval("ExampleSeparator")%> </li>
68 Views
no comments
//using System.Web.Security if (Membership.ValidateUser(username, password)) { //Log in user. FormsAuthentication.SetAuthCookie(username, true); } else { //Handle user not exist code.
89 Views
no comments
DropDownList.SelectedIndex = DropDownList.Items.IndexOf(DropDownList.Items.FindByValue("Value"));
77 Views
no comments
<!-- place under the <system.web> node--> <webServices> <wsdlHelpGenerator href="denied.aspx" /> <protocols> <remove name="HttpGet" /> <remove name="HttpPost" /> </protocols> </webServices>
86 Views
no comments
void Main() { AutoMapper.Mapper.CreateMap<Contact, KeyValuePair<Guid, string>>() .ConstructUsing(x => new KeyValuePair<Guid, string>(x.Id, x.FullName)); //var contacts = ContactRepository.GetAll(); // Returns IList<Contact> var contacts = new List<Contact> { new Contact { Id = Guid.NewGuid(), FullName = "Joe Bob" }, new Contact { Id = Guid.NewGuid(), FullName = "Sally Jones" }, };
198 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
