October 2009
M T W T F S S
« Sep   Nov »
 1234
567891011
12131415161718
19202122232425
262728293031  

ASP.NET - Working with Gridview TemplateFields

1. code behide
string ComputeSeniorityLevel(TimeSpan ts)
{
int numberOfDaysOnTheJob = ts.Days;
if (numberOfDaysOnTheJob >= 0 && numberOfDaysOnTheJob <= 1000)
return “Newbie”;
else if (numberOfDaysOnTheJob > 1000 && numberOfDaysOnTheJob <= 4000)
return “Associate”;
else if (numberOfDaysOnTheJob >= 4000 && numberOfDaysOnTheJob <= 8000)
return “One of the Regulars”;
else
return “An Ol’ Fogey”;
}

2. html

<asp:GridView ID=”GridView1″ Runat=”server”
DataSourceID=”employeeDataSource” AutoGenerateColumns=”False”
[...]

Centering: Auto-width Margins

body {
margin:50px 0px; padding:0px;
text-align:center;
}

#Content {
width:500px;
margin:0px auto;
text-align:left;
padding:15px;
border:1px dashed #333;
background-color:#eee;
}

Call webservice from javascript

1.  VS 2005  – create new website with ASP.NET Ajax-Enabled Website , then create   WebService.asmx

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]  // <== [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {

public WebService () {
//Uncomment the following line if using designed components
//InitializeComponent();
}[WebMethod]

public string HelloWorld() [...]

How to use HtmlEncode with TemplateFields, Data Binding, and a GridView

Label ID=”LabelDescription”
           runat=”server”
           Text=’<%# System.Web.HttpUtility.HtmlEncode((string)Eval(”Description”)) %>’

Asp.net Permalinks Using URL Rewriting

A Permalink is a permanent link which points to a particular blog entry or forum entry. For example the permalink for this blog article is http://csharp-codesamples.com/2009/03/aspnet-permalinks-using-url-rewriting.

This does not mean that a physical page is created for each blog entry. Instead a single page shows the data for multiple blogs articles dynamically based on some query [...]

JavaScript dateTime function

<!– Paste this code into an external JavaScript file named: dateFormat.js –>

/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Oded Arbel :: http://geek.co.il/wp/ */

/**
* Extension of the JavaScript internal Date object to allow various formatting of
* date/time values.
* This implementation was designed to be compliant with the [...]

FileUpload in UpdatePanel, ASP.NET, like Gmail

http://geekswithblogs.net/ranganh/archive/2009/10/01/fileupload-in-updatepanel-asp.net-like-gmail.aspx

asp.net + jquery

Introduction to jQuery in ASP.Net and 10 Advantages to Choose jQuery

http://www.codedigest.com/Articles/ASPNETAJAX/183_Using_JQuery_in_ASPNet_AJAX_Applications_%e2%80%93_Part_1.aspx

More Fun With LINQ – Perform Common Tasks in ASP.NET

http://www.dotnetcurry.com/
http://www.dotnetcurry.com/ShowArticle.aspx?ID=320