<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7412293528094012160</id><updated>2012-02-16T09:58:17.926-08:00</updated><category term='Creating an RSS feed for your ASP.NET site'/><category term='Working with DataSet Objects and XML'/><category term='SQL ERROR 40'/><category term='E-Books'/><title type='text'>Projects in ASP,PHP,ASP.NET</title><subtitle type='html'>Knowledge Guide...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>57</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-8528981614540211781</id><published>2010-03-31T07:09:00.001-07:00</published><updated>2010-03-31T07:09:59.889-07:00</updated><title type='text'>Interview Quest</title><content type='html'>online advertising &lt;br /&gt; &lt;br /&gt;internet advertising &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;What is Microsoft SharePoint Portal Server? &lt;br /&gt;SharePoint Portal Server is a portal server that connects people, teams, and knowledge across business processes. SharePoint Portal Server integrates information from various systems into one secure solution through single sign-on and enterprise application integration capabilities. It provides flexible deployment and management tools, and facilitates end-to-end collaboration through data aggregation, organization, and searching. SharePoint Portal Server also enables users to quickly find relevant information through customization and personalization of portal content and layout as well as through audience targeting.&lt;br /&gt;What is Microsoft Windows SharePoint Services? &lt;br /&gt;Windows SharePoint Services is the solution that enables you to create Web sites for information sharing and document collaboration. Windows SharePoint Services " a key piece of the information worker infrastructure delivered in Microsoft Windows Server 2003 " provides additional functionality to the Microsoft Office system and other desktop applications, and it serves as a platform for application development.&lt;br /&gt;Office SharePoint Server 2007 builds on top of Windows SharePoint Services 3.0 to provide additional capabilities including collaboration, portal, search, enterprise content management, business process and forms, and business intelligence.&lt;br /&gt;What are the advantages of jQuery &lt;br /&gt;The advantages of using jQuery are:&lt;br /&gt;1. JavaScript enhancement without the overhead of learning new syntax&lt;br /&gt;2. Ability to keep the code simple, clear, readable and reusable&lt;br /&gt;3. Eradication of the requirement of writing repetitious and complex loops and DOM scripting library calls&lt;br /&gt;What is JQuery &lt;br /&gt;JQuery is a light weight JavaScript library which provides fast and easy way of HTML DOM traversing and manipulation, its event handling, its client side animations, etc. One of the greatest features of jQuery is that jQuery supports an efficient way to implement AJAX applications because of its light weight nature and make normalize and efficient web programs.&lt;br /&gt;The IHttpHandler and IHttpHandlerFactory interfaces ? &lt;br /&gt;The IHttpHandler interface is implemented by all the handlers. The interface consists of one property called IsReusable. The IsReusable property gets a value indicating whether another request can use the IHttpHandler instance. The method ProcessRequest() allows you to process the current request. This is the core place where all your code goes. This method receives a parameter of type HttpContext using which you can access the intrinsic objects such as Request and Response. The IHttpHandlerFactory interface consists of two methods - GetHandler and ReleaseHandler. The GetHandler() method instantiates the required HTTP handler based on some condition and returns it back to ASP.NET. The ReleaseHandler() method allows the factory to reuse an existing handler. &lt;br /&gt;Does .NET CLR and SQL SERVER run in different process? &lt;br /&gt;Dot Net CLR and all .net realtes application and Sql Server run in same process or we can say that that on the same address because there is no issue of speed because if these two process are run in different process then there may be a speed issue created one process goes fast and other slow may create the problem.&lt;br /&gt;What do you mean by three-tier architecture? &lt;br /&gt;The three-tier architecture was comes into existence to improve management of code and contents and to improve the performance of the web based applications. There are mainly three layers in three-tier architecture. the are define as follows &lt;br /&gt;(1)Presentation &lt;br /&gt;(2)Business Logic &lt;br /&gt;(3)Database &lt;br /&gt;&lt;br /&gt;(1)First layer Presentation contains mainly the interface code, and this is shown to user. This code could contain any technology that can be used on the client side like HTML, JavaScript or VBScript etc. &lt;br /&gt;&lt;br /&gt;(2)Second layer is Business Logic which contains all the code of the server-side .This layer have code to interact with database and to query, manipulate, pass data to user interface and handle any input from the UI as well. &lt;br /&gt;&lt;br /&gt;(3)Third layer Data represents the data store like MS Access, SQL Server, an XML file, an Excel file or even a text file containing data also some additional database are also added to that layers. &lt;br /&gt;When not to use Design Patterns &lt;br /&gt;Do not use design patterns in any of the following situations.&lt;br /&gt;&lt;br /&gt;• When the software being designed would not change with time.&lt;br /&gt;• When the requirements of the source code of the application are unique.&lt;br /&gt;&lt;br /&gt;If any of the above applies in the current software design, there is no need to apply design patterns in the current design and increase unnecessary complexity in the design.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-8528981614540211781?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/8528981614540211781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=8528981614540211781' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/8528981614540211781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/8528981614540211781'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2010/03/interview-quest.html' title='Interview Quest'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-8930466376177287324</id><published>2008-12-17T19:28:00.000-08:00</published><updated>2008-12-17T19:29:03.246-08:00</updated><title type='text'>xml creation</title><content type='html'>&lt;pre&gt;Imports System.Data&lt;br /&gt;Imports System.Data.SqlClient&lt;br /&gt;Imports System.Web.Configuration&lt;br /&gt;Imports System.IO&lt;br /&gt;Partial Class xmltest&lt;br /&gt;    Inherits System.Web.UI.Page&lt;br /&gt;    Dim i As Integer&lt;br /&gt;    Dim Filen As FileInfo&lt;br /&gt;    Dim conpubs As SqlConnection&lt;br /&gt;    Dim conn As String = WebConfigurationManager.ConnectionStrings("SQLConnection").ConnectionString&lt;br /&gt;    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;br /&gt;        DBtoXML()&lt;br /&gt;    End Sub&lt;br /&gt;    Private Sub ErrMail(ByVal msg As String)&lt;br /&gt;        Dim lbl As New Label&lt;br /&gt;        lbl.Text = "&lt;script language='javascript'&gt;window.alert(""" &amp; msg &amp; """)&lt;/script&gt;"&lt;br /&gt;        Page.Controls.Add(lbl)&lt;br /&gt;    End Sub&lt;br /&gt;    Public Function DBtoXML() As Boolean&lt;br /&gt;        Try&lt;br /&gt;            conpubs = New SqlConnection(conn)&lt;br /&gt;            conpubs.Open()&lt;br /&gt;            Dim ds As New DataSet()&lt;br /&gt;            Dim da As New SqlDataAdapter("SELECT * FROM registration WHERE DoctorName like 'r%'", conpubs)&lt;br /&gt;            Dim filename As String = "DBtoXML.xml"&lt;br /&gt;            Filen = New FileInfo(Server.MapPath("~/conversions/") &amp; filename)&lt;br /&gt;            If Filen.Exists Then&lt;br /&gt;                File.Delete(Server.MapPath("~/conversions/") &amp; filename)&lt;br /&gt;                'Me.i = 0&lt;br /&gt;                'Do While Me.i &lt; 100&lt;br /&gt;                '    i += 1&lt;br /&gt;                '    filename = "DBtoXML.xml"&lt;br /&gt;                '    File = New FileInfo(Server.MapPath("~/conversions/") &amp; filename)&lt;br /&gt;                '    If Not File.Exists Then Exit Do&lt;br /&gt;                '    If i = 100 Then ErrMail("DBtoXML File Name Failure /n Could not find a suitable filename for:  " &amp; Server.MapPath("~/conversions/") &amp; filename) : Return False&lt;br /&gt;                'Loop&lt;br /&gt;            End If&lt;br /&gt;            da.Fill(ds)     'Used for backups, incase of a failure or incase I need it later on.    ds.WriteXml(Server.MapPath("/conversions/") &amp; filename)     For Me.i = 0 To da.Tables("Stories").Rows.Count - 1    'I could also use, For Each dr As DataRow in da.Tables("Stories"), right? I'd prefer that.      'I need to name the file after a row... called... "SID"    Next  Catch ex As SqlException    ErrMail("Database Exception - DBtoXML Conversion", (ex).ToString())    Return False  End TryEnd FunctionPublic Function DBtoXML() As Boolean&lt;br /&gt;            ds.WriteXml(Server.MapPath("~/conversions/") &amp; filename)&lt;br /&gt;            'For Me.i = 0 To da.Tables("Stories").Rows.Count - 1&lt;br /&gt;            '    'I could also use, For Each dr As DataRow &lt;strong class="highlight"&gt;in&lt;/strong&gt; da.Tables("Stories"), right? I'd prefer that.&lt;br /&gt;            '    'I need to name the file after a row... called... "SID"&lt;br /&gt;            'Next&lt;br /&gt;        Catch ex As SqlException&lt;br /&gt;            ErrMail("Database Exception - DBtoXML Conversion" &amp; (ex).ToString())&lt;br /&gt;            Return False&lt;br /&gt;        Finally&lt;br /&gt;            conpubs.Close()&lt;br /&gt;        End Try&lt;br /&gt;    End Function&lt;br /&gt;&lt;br /&gt;End Class&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-8930466376177287324?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/8930466376177287324/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=8930466376177287324' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/8930466376177287324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/8930466376177287324'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/12/xml-creation.html' title='xml creation'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-975376359926182003</id><published>2008-12-17T19:27:00.000-08:00</published><updated>2008-12-17T19:28:19.256-08:00</updated><title type='text'></title><content type='html'>&lt;pre&gt;Imports System.Text&lt;br /&gt;Imports System.Xml&lt;br /&gt;Imports System.Data.SqlClient&lt;br /&gt;&lt;br /&gt;Partial Class rss&lt;br /&gt;    Inherits System.Web.UI.Page&lt;br /&gt;    Dim cn As SqlConnection = Nothing&lt;br /&gt;    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load&lt;br /&gt;        Response.Clear()&lt;br /&gt;        Response.ContentType = "text/xml"&lt;br /&gt;        cn = New SqlConnection(ConfigurationManager.ConnectionStrings("LocalSqlServer").ToString)&lt;br /&gt;        Dim xtw As XmlTextWriter = New XmlTextWriter(Response.OutputStream, Encoding.UTF8)&lt;br /&gt;        xtw.WriteStartDocument()&lt;br /&gt;        Dim processtext As String = "type='text/xsl' href='rss.xsl'"&lt;br /&gt;        xtw.WriteProcessingInstruction("xml-stylesheet", processtext)&lt;br /&gt;        xtw.WriteStartElement("rss")&lt;br /&gt;        xtw.WriteAttributeString("version", "2.0")&lt;br /&gt;        xtw.WriteStartElement("channel")&lt;br /&gt;        xtw.WriteElementString("title", "Latest Escort List")&lt;br /&gt;        xtw.WriteElementString("link", "http://www.selectescortsuk.com/")&lt;br /&gt;        xtw.WriteElementString("description", "Members Description")&lt;br /&gt;        Dim sql As String = "Select * from rssview"&lt;br /&gt;        Dim da As SqlDataAdapter = New SqlDataAdapter(sql, cn)&lt;br /&gt;        cn.Open()&lt;br /&gt;        Dim dt As Data.DataTable = New Data.DataTable()&lt;br /&gt;        da.Fill(dt)&lt;br /&gt;        If dt.Rows.Count &gt; 0 Then&lt;br /&gt;            Dim i As Integer&lt;br /&gt;            For i = 0 To dt.Rows.Count - 1 Step i + 1&lt;br /&gt;                xtw.WriteStartElement("item")&lt;br /&gt;                xtw.WriteElementString("title", dt.Rows(i)("UserName").ToString())&lt;br /&gt;                xtw.WriteElementString("description", dt.Rows(i)("Description").ToString())&lt;br /&gt;                xtw.WriteElementString("link", "http://www.selectescortsuk.com/")&lt;br /&gt;                xtw.WriteElementString("pubDate", XmlConvert.ToString(Convert.ToDateTime(dt.Rows(i)("CreateDate").ToString()), "dd-MMM-yyyy THH:mm:sszzzzzz"))&lt;br /&gt;                xtw.WriteEndElement()&lt;br /&gt;            Next&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;        xtw.WriteEndElement()&lt;br /&gt;        xtw.WriteEndElement()&lt;br /&gt;        xtw.WriteEndDocument()&lt;br /&gt;&lt;br /&gt;        xtw.Flush()&lt;br /&gt;        xtw.Close()&lt;br /&gt;        cn.Close()&lt;br /&gt;    End Sub&lt;br /&gt;End Class&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-975376359926182003?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/975376359926182003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=975376359926182003' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/975376359926182003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/975376359926182003'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/12/0-then-dim-i-as-integer-for-i-0-to-dt.html' title=''/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-6593218307591044164</id><published>2008-06-18T05:14:00.000-07:00</published><updated>2008-06-18T05:15:23.219-07:00</updated><title type='text'>Create an RSS feed using ASP.NET 2.0</title><content type='html'>Create an RSS feed using ASP.NET 2.0&lt;br /&gt;&lt;br /&gt;This tutorial will show you how to create a dynamic XML RSS 2.0 feed using ASP.NET 2.0 (C#). The headlines will be retrieved from a SQL database.&lt;br /&gt; On Wednesday, January 4th 2006 at 09:58 AMBy Andrei Pociu (View Profile)*****   (Rated 4.7 with 45 votes)&lt;br /&gt;Contextual Ads&lt;br /&gt;More ASP.NET Resources&lt;br /&gt;&lt;br /&gt;    * Tutorials ASP.NET Tutorials&lt;br /&gt;    * Code ASP.NET Code&lt;br /&gt;    * Jobs ASP.NET Jobs&lt;br /&gt;&lt;br /&gt;Advertisement&lt;br /&gt;I don't think there's a need for explaining what RSS is, or what RSS does. Most of the time, the headlines of an RSS feed are retrieved from a database, such as SQL server. An example of this is Feedpedia.com which creates feeds containing the latest headlines retrieved from the website's database. One of these feeds is located at http://www.feedpedia.com/RSS/TodaysHeadlines.aspx?Group=13.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In this tutorial we're going to create a similar RSS feed, using ASP.NET 2.0.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the ASP.NET 2.0 project, create a new file which will be the RSS feed. We used "TodaysHeadlines.aspx".&lt;br /&gt;&lt;br /&gt;Now open the markup of the file and replace everything inside it with the following two lines:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Don't forget to change the CodeFile and Inherits attributes of the Page tag in case you gave your RSS file a different name than TodaysHeadlines.aspx.&lt;br /&gt;&lt;br /&gt;If you're wondering what the second page does: it tells the ASP.NET server to keep the page in cache for 120 seconds (2 minutes) so that the SQL server doesn't have to be accessed every time someone opens your RSS feed. You can change the duration depending on how often your content updates.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="TodaysHeadlines.aspx.cs" Inherits="TodaysHeadlines" %&gt;&lt;br /&gt;&lt;%@ OutputCache Duration="120" %&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now since we are already discussing the OutputCache, I want to bring your attention towards something. If you're going to create a dynamic RSS feed file to which you're going to pass a parameter which changes the content of the feed (such as the one on Feedpedia: http://www.feedpedia.com/RSS/TodaysHeadlines.aspx?Group=13), the cache you will create you some problems: when you open the RSS feed with a different attribute (in Feedpedia's case, a different Group ID), the content will not change, but the cached one will be shown. In that case you will need to tell the cache that the content varies by that parameter, and it should build a different cache based on the parameter passed. Here's how you can do that:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;%@ OutputCache Duration="120" VaryByParam="Group" %&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now if you didn't understand any of my mumbling above, don't worry, as long as you don't plan to pass parameters to the RSS feed, everything will work fine for you without the VaryByParam attribute.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Believe it or not, we're done with the&lt;br /&gt;markup, so switch to code view. Add the following using statements at the top:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;&lt;br /&gt;using System.Text;&lt;br /&gt;&lt;br /&gt;using System.Xml;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now what's left to do for your RSS feed to work, is add this code in the Page_Load event:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// Clear any previous output from the buffer&lt;br /&gt;&lt;br /&gt;Response.Clear();&lt;br /&gt;&lt;br /&gt;Response.ContentType = "text/xml";&lt;br /&gt;&lt;br /&gt;XmlTextWriter xtwFeed = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);&lt;br /&gt;&lt;br /&gt;xtwFeed.WriteStartDocument();&lt;br /&gt;&lt;br /&gt;// The mandatory rss tag&lt;br /&gt;&lt;br /&gt;xtwFeed.WriteStartElement("rss");&lt;br /&gt;&lt;br /&gt;xtwFeed.WriteAttributeString("version", "2.0");&lt;br /&gt;&lt;br /&gt;// The channel tag contains RSS feed details&lt;br /&gt;&lt;br /&gt;xtwFeed.WriteStartElement("channel");&lt;br /&gt;&lt;br /&gt;xtwFeed.WriteElementString("title", "Feedpedia Today's World News");&lt;br /&gt;&lt;br /&gt;xtwFeed.WriteElementString("link", "http://www.feedpedia.com");&lt;br /&gt;&lt;br /&gt;xtwFeed.WriteElementString("description", "The latest news and journals from all over the world.");&lt;br /&gt;&lt;br /&gt;xtwFeed.WriteElementString("copyright", "Copyright 2005 - 2006 Feedpedia.com. All rights reserved.");&lt;br /&gt;&lt;br /&gt;// Objects needed for connecting to the SQL database&lt;br /&gt;&lt;br /&gt;SqlConnection SqlCon;&lt;br /&gt;&lt;br /&gt;SqlCommand SqlCom;&lt;br /&gt;&lt;br /&gt;SqlDataReader SqlDR;&lt;br /&gt;&lt;br /&gt;// Edit to match your connection string&lt;br /&gt;&lt;br /&gt;SqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());&lt;br /&gt;&lt;br /&gt;// Edit to match your stored procedure or SQL command&lt;br /&gt;&lt;br /&gt;SqlCom = new SqlCommand("GetTodaysHeadlines", SqlCon);&lt;br /&gt;&lt;br /&gt;SqlCom.CommandType = CommandType.StoredProcedure;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (SqlCon.State == ConnectionState.Closed)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   SqlCon.Open();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;SqlDR = SqlCom.ExecuteReader();&lt;br /&gt;&lt;br /&gt;// Loop through the content of the database and add them to the RSS feed&lt;br /&gt;&lt;br /&gt;while (SqlDR.Read())&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   xtwFeed.WriteStartElement("item");&lt;br /&gt;&lt;br /&gt;   xtwFeed.WriteElementString("title", SqlDR["Title"].ToString());&lt;br /&gt;&lt;br /&gt;   xtwFeed.WriteElementString("description", SqlDR["Description"].ToString());&lt;br /&gt;&lt;br /&gt;   xtwFeed.WriteElementString("link", "http://www.feedpedia.com/View.aspx?View=" + SqlDR["ID"]);&lt;br /&gt;&lt;br /&gt;   xtwFeed.WriteElementString("pubDate", SqlDR["Date"].ToString());&lt;br /&gt;&lt;br /&gt;   xtwFeed.WriteEndElement();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;SqlDR.Close();&lt;br /&gt;&lt;br /&gt;SqlCon.Close();&lt;br /&gt;&lt;br /&gt;// Close all tags&lt;br /&gt;&lt;br /&gt;xtwFeed.WriteEndElement();&lt;br /&gt;&lt;br /&gt;xtwFeed.WriteEndElement();&lt;br /&gt;&lt;br /&gt;xtwFeed.WriteEndDocument();&lt;br /&gt;&lt;br /&gt;xtwFeed.Flush();&lt;br /&gt;&lt;br /&gt;xtwFeed.Close();&lt;br /&gt;&lt;br /&gt;Response.End();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Of course, you'll need to do the necessary changes so that the code matches your SQL database table. If you have any questions or doubts about the code, don't hesitate to place a comment for this tutorial. I will answer ASAP.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you did everything right, your RSS feed will be valid and should have a structure similar to the one below:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;XML RSS Feed&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;There are several tags which you can add to the RSS feed, such as the author of the headline, the category or an unique ID. You can find more information about this at the RSS 2.0 specification page.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-6593218307591044164?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/6593218307591044164/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=6593218307591044164' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/6593218307591044164'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/6593218307591044164'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/06/create-rss-feed-using-aspnet-20.html' title='Create an RSS feed using ASP.NET 2.0'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-3754376307358077862</id><published>2008-05-02T04:08:00.000-07:00</published><updated>2008-05-02T04:16:37.826-07:00</updated><title type='text'>Accessing HTML Source code using ASP.NET </title><content type='html'>In this article, we will see how to view the HTML source of the posted page.&lt;br /&gt;To do so, follow these steps :&lt;br /&gt;Step 1: Create a new ASP.NET website and rename it to “ViewHtmlSource”. Drag and drop a button. Rename the button ID to “btnViewHtml” and set its Text property to “View Html”. Similarly drag and drop a textbox and rename the textbox to “txtHtmlSrc”. Set its ‘TextMode’ to Multiline.&lt;br /&gt;Step 2: In the Form Load() event, add the following code:&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;   btnViewHtml.Attributes.Add("onClick", "javascript:getHtml()");&lt;br /&gt;}&lt;br /&gt;Step 3: Switch to the source tab of the Default.aspx page and add the following code in the  section of the page. &lt;script type="text/javascript" language="javascript"&gt;&gt;    function getHtml(txtbox)&lt;br /&gt;    {&lt;br /&gt;        var src = document.documentElement.innerHTML;&lt;br /&gt;        document.forms[0]['txtHtmlSrc'].value = src;&lt;br /&gt;    }&lt;br /&gt;    &lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Step 4: In the &lt;%Page&gt; directive, add ValidateRequest=false.&lt;br /&gt;&lt;br /&gt;&lt;%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;&lt;br /&gt;&lt;br /&gt;That’s it.&lt;br /&gt;&lt;br /&gt;The entire source code will look like this&lt;br /&gt;&lt;br /&gt;Default.aspx&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;title&gt;View HTML&lt;/title&gt;&lt;%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;&lt;script type="text/javascript" language="javascript"&gt;br /&gt;    function getHtml(txtbox)&lt;br /&gt;    {&lt;br /&gt;        var src = document.documentElement.innerHTML;&lt;br /&gt;        document.forms[0]['txtHtmlSrc'].value = src;&lt;br /&gt;    }&lt;br /&gt;    &lt;/script&gt; &lt;form id="form1" runat="server"&gt;&lt;br /&gt;  &lt;br /&gt;&lt;/form&gt;Default.aspx.cs&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;&lt;br /&gt;public partial class _Default : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;   protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;   {&lt;br /&gt;       btnViewHtml.Attributes.Add("onClick", "javascript:getHtml()");&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-3754376307358077862?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/3754376307358077862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=3754376307358077862' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/3754376307358077862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/3754376307358077862'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/05/accessing-html-source-code-using-aspnet.html' title='Accessing HTML Source code using ASP.NET '/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-3005318803851680795</id><published>2008-05-02T04:06:00.000-07:00</published><updated>2008-05-02T04:07:13.962-07:00</updated><title type='text'>Sending Email In ASP.NET 2.0</title><content type='html'>In ASP.NET, sending emails has become simpler. The classes required to send an email are contained in the System.Net.Mail. The steps required to send an email from ASP.NET are as follows :&lt;br /&gt;Step 1: Declare the System.Net.Mail namespace &lt;br /&gt;C# - using System.Net.Mail;&lt;br /&gt;VB.NET - Imports System.Net.Mail&lt;br /&gt;Step 2: Create a MailMessage object. This class contains the actual message you want to send. There are four overloaded constructors provided in this class. We will be using &lt;br /&gt;C# - public MailMessage ( string from, string to, string subject, string body )&lt;br /&gt;VB.NET - public MailMessage (String From, String to, String subject, String body)&lt;br /&gt;The constructor of this MailMessage class is used to specify the sender email, receiver email, subject, body.&lt;br /&gt;C#&lt;br /&gt;MailMessage message = new MailMessage            ("abc@somedomain.com","administrator@anotherdomain.com","Testing","This is a test mail");&lt;br /&gt;VB.NET&lt;br /&gt;Dim message As MailMessage = New MailMessage ("abc@somedomain.com","administrator@anotherdomain.com","Testing","This is a test mail")&lt;br /&gt;                    &lt;br /&gt;Step 3: To add an attachment to the message, use the Attachment class.&lt;br /&gt; &lt;br /&gt;C#&lt;br /&gt;string fileAttach = Server.MapPath("myEmails") + "\\Mypic.jpg";&lt;br /&gt;Attachment attach = new Attachment(fileAttach);&lt;br /&gt;message.Attachments.Add(attach);&lt;br /&gt;VB.NET&lt;br /&gt;Dim fileAttach As String = Server.MapPath("myEmails") &amp; "\Mypic.jpg" &lt;br /&gt;Dim attach As Attachment = New Attachment(fileAttach) message.Attachments.Add(attach)&lt;br /&gt;Step 4:After creating a message, use the SmtpClient to send the email to the specified SMTP server. I will be using ‘localhost’ as the SMTP server.&lt;br /&gt; &lt;br /&gt;C#&lt;br /&gt;SmtpClient client = new SmtpClient("localhost");&lt;br /&gt;client.Send(message);&lt;br /&gt; &lt;br /&gt;Additionally, if required, you &lt;br /&gt; &lt;br /&gt;client.Timeout = 500; &lt;br /&gt;// Pass the credentials if the server requires the client to authenticate before it will send e-mail on the client's behalf.&lt;br /&gt;client.Credentials = CredentialCache.DefaultNetworkCredentials;&lt;br /&gt;VB.NET&lt;br /&gt;Dim client As SmtpClient = New SmtpClient("localhost") &lt;br /&gt;client.Send(message)&lt;br /&gt;Additionally, if required, you client.Timeout = 500&lt;br /&gt;' Pass the credentials if the server requires the client to authenticate before it will send e-mail on the client's behalf.&lt;br /&gt;client.Credentials = CredentialCache.DefaultNetworkCredentials &lt;br /&gt;That’s it. It’s that simple.&lt;br /&gt;To configure SMTP configuration data for ASP.NET, you would add the following tags to your web.config file.&lt;br /&gt; &lt;br /&gt; &lt;system.net&gt;&lt;br /&gt;    &lt;mailSettings&gt;&lt;br /&gt;      &lt;smtpfrom="abc@somedomain.com"&gt;&lt;br /&gt;        &lt;networkhost="somesmtpserver"port="25"userName="name" password="pass"defaultCredentials="true" /&gt;&lt;br /&gt;      &lt;/smtp&gt;&lt;br /&gt;    &lt;/mailSettings&gt;&lt;br /&gt; &lt;/system.net&gt;&lt;br /&gt; &lt;br /&gt;References :&lt;br /&gt;http://msdn2.microsoft.com/En-US/library/system.net.mail.mailmessage.aspx&lt;br /&gt; &lt;br /&gt;Conclusion:&lt;br /&gt; &lt;br /&gt;In this short article, we explored how easy it is to send Email’s with attachments using the classes in System.Net.Mail. This approach of sending mails will remain the same for web as well as windows application.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-3005318803851680795?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/3005318803851680795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=3005318803851680795' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/3005318803851680795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/3005318803851680795'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/05/sending-email-in-aspnet-20.html' title='Sending Email In ASP.NET 2.0'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-9186735324537485287</id><published>2008-05-02T04:05:00.001-07:00</published><updated>2008-05-02T04:05:37.291-07:00</updated><title type='text'>Uploading Multiple Files in ASP.NET 2.0</title><content type='html'>In ASP.NET 2.0, the FileUpload control enables users to upload file from your web pages. The FileUpload control consists of a text box and a browse button. Clicking on the button allow users to select a file on the client and upload it to the server. Let us first start off by exploring how to upload a single file in asp.net. To do so, follow these steps:&lt;br /&gt;Step 1: Drag and drop the FileUpload server control from the toolbox. The code behind looks as follows :&lt;br /&gt;&lt;asp:FileUpload id=”FileUpload1” runat=”server” /&gt;&lt;br /&gt;Step 2: Drop a Button control and rename it to “Upload”&lt;br /&gt;&lt;asp:Button ID=”btnUpload” runat=”server” Text=”Upload” /&gt;&lt;br /&gt;Step 3: Double click the Upload Button to add an event hander to the code behind.&lt;br /&gt;C#&lt;br /&gt;protected void btnUpload_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;VB.NET&lt;br /&gt;Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As EventArgs)&lt;br /&gt;End Sub&lt;br /&gt; &lt;br /&gt;Step 4: Add the following code to the event handler&lt;br /&gt;C#&lt;br /&gt; &lt;br /&gt;protected void btnUpload_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;        try&lt;br /&gt;        {&lt;br /&gt;            if (FileUpload1.HasFile)&lt;br /&gt;            {&lt;br /&gt;                FileUpload1.SaveAs(Server.MapPath("MyFiles") +&lt;br /&gt;                    "\\" + FileUpload1.FileName);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        catch (Exception ex)&lt;br /&gt;        {&lt;br /&gt;            // Handle your exception here&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;VB.NET&lt;br /&gt;Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As EventArgs) &lt;br /&gt;Try&lt;br /&gt;If FileUpload1.HasFile Then&lt;br /&gt;FileUpload1.SaveAs(Server.MapPath("MyFiles") &amp; "\" &amp; FileUpload1.FileName)&lt;br /&gt;End If&lt;br /&gt;Catch ex As Exception &lt;br /&gt;' Handle your exception here&lt;br /&gt;End Try&lt;br /&gt;End Sub&lt;br /&gt;The “HasFile” property of our FileUpload control helps us to determine if a file has actually been uploaded. We then use the "SaveAs" method to save the file to disk.&lt;br /&gt;That is all you require to implement the FileUpload functionality in your web pages. In order to retrieve the metadata information of the file being uploaded, you can drop a Label control on to the form designer and use the PostedFile.FileName and PostedFile.ContentLength on the FileUpload control. This would give you the uploaded file’s name and size respectively. Eg:&lt;br /&gt;Label1.Text = FileUpload1.PostedFile.FileName;&lt;br /&gt;Label1.Text += FileUpload1.PostedFile.ContentLength;&lt;br /&gt;Uploading Multiple Files&lt;br /&gt; &lt;br /&gt;So far so good. Let’s extend the above sample to upload multiple files at a time. Follow these steps mentioned below to do so: &lt;br /&gt;Step 1: Drag and drop multiple (in our case four) FileUpload controls on to the designer.&lt;br /&gt;Step 2: Drop a Button control and rename it to “Upload”&lt;br /&gt;&lt;asp:Button ID=”btnUpload” runat=”server” Text=”Upload” /&gt;&lt;br /&gt;Step 3: Double click the Upload Button to add an event hander to the code behind.&lt;br /&gt;C#&lt;br /&gt;protected void btnUpload_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;VB.NET&lt;br /&gt;Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As EventArgs)&lt;br /&gt;End Sub&lt;br /&gt;Step 4: Import the System.IO namespace.&lt;br /&gt;using System.IO; - C#&lt;br /&gt;&lt;br /&gt;Imports System.IO - VB.NET&lt;br /&gt;&lt;br /&gt;Step 5: Use the ‘HttpFileCollection’ class to retrieve all the files that are uploaded. Files are encoded and transmitted in the content body using multipart MIME format with an HTTP Content-Type header. ASP.NET extracts this information from the content body into individual members of an HttpFileCollection.&lt;br /&gt;The code would look as follows:&lt;br /&gt;C#&lt;br /&gt;protected void btnUpload_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;        try&lt;br /&gt;        {&lt;br /&gt;            // Get the HttpFileCollection&lt;br /&gt;            HttpFileCollection hfc = Request.Files;&lt;br /&gt;            for (int i = 0; i &lt; hfc.Count; i++)&lt;br /&gt;            {&lt;br /&gt;                HttpPostedFile hpf = hfc[i];               &lt;br /&gt;                if (hpf.ContentLength &gt; 0)&lt;br /&gt;                {&lt;br /&gt;                    hpf.SaveAs(Server.MapPath("MyFiles") + "\\" +&lt;br /&gt;                      Path.GetFileName(hpf.FileName));                       &lt;br /&gt;                }               &lt;br /&gt;            }    &lt;br /&gt;        }&lt;br /&gt;        catch (Exception ex)&lt;br /&gt;        {&lt;br /&gt;            // Handle your exception here&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;VB.NET&lt;br /&gt;Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As EventArgs) &lt;br /&gt;Try&lt;br /&gt;' Get the HttpFileCollection&lt;br /&gt;Dim hfc As HttpFileCollection = Request.Files &lt;br /&gt;For i As Integer = 0 To hfc.Count - 1 &lt;br /&gt;Dim hpf As HttpPostedFile = hfc(i) &lt;br /&gt;If hpf.ContentLength &gt; 0 Then&lt;br /&gt;hpf.SaveAs(Server.MapPath("MyFiles") &amp; "\" &amp; Path.GetFileName(hpf.FileName))&lt;br /&gt;End If&lt;br /&gt;Next i &lt;br /&gt;Catch ex As Exception &lt;br /&gt;' Handle your exception here&lt;br /&gt;End Try&lt;br /&gt;End Sub&lt;br /&gt;The ‘HttpPostedFile’ class provides methods and properties to access the contents and properties of each file. In our case, we use this class to check the length of the file. To retrieve the filename and length of the file uploaded, we can use hpf.FileName and hpf.ContentLength respectively.&lt;br /&gt;Well, that was simple to implement, wasn’t it! However there are a few points to be kept in mind.&lt;br /&gt;Some important points to consider while uploading&lt;br /&gt; &lt;br /&gt;1.    To save a file to the server, the account associated with ASP.NET must have sufficient permissions on the folder, where the files are being uploaded. This would usually be the ‘ASPNET’ account for Windows XP or a similar OS. In Windows Server 2003, the account used is ‘NETWORKSERVICE’. So you would be required to explicitly grant write permissions to these accounts on the folder.&lt;br /&gt; &lt;br /&gt;2.    While uploading the files to a remote server, the default ASPNET user account used by ASP.NET does not have network permissions by default. The solution is to either give the account such permissions or use impersonation to have it run under a different account that has the permissions.&lt;br /&gt; &lt;br /&gt;3.    By default, you can upload no more than 4096 KB (4 MB) of data. However there is a workaround for this limitation. You can change the maximum file size by changing the maxRequestLength attribute of the httpRuntime element in the web.config file. You can also increase the ‘executionTimeout’. By default it is 110 seconds. I would encourage you to experiment with the other attributes of the httpRuntime element.&lt;br /&gt;&lt;configuration&gt;&lt;br /&gt;      &lt;system.web&gt;&lt;br /&gt;            &lt;httpRuntime&lt;br /&gt;               executionTimeout="200"&lt;br /&gt;               maxRequestLength="8192"&lt;br /&gt;               requestLengthDiskThreshold="256"&lt;br /&gt;               useFullyQualifiedRedirectUrl="false"&lt;br /&gt;               minFreeThreads="8"&lt;br /&gt;               minLocalRequestFreeThreads="4"&lt;br /&gt;               appRequestQueueLimit="5000"&lt;br /&gt;               enableKernelOutputCache="true"&lt;br /&gt;               enableVersionHeader="true"&lt;br /&gt;               requireRootedSaveAsPath="true"&lt;br /&gt;               enable="true"&lt;br /&gt;               shutdownTimeout="90"&lt;br /&gt;               delayNotificationTimeout="5"&lt;br /&gt;               waitChangeNotification="0"&lt;br /&gt;               maxWaitChangeNotification="0"&lt;br /&gt;               enableHeaderChecking="true"&lt;br /&gt;               sendCacheControlHeader="true"&lt;br /&gt;               apartmentThreading="false"/&gt;&lt;br /&gt;      &lt;/system.web&gt;&lt;br /&gt;&lt;/configuration&gt;&lt;br /&gt;References&lt;br /&gt;There are a number of good resources I referred to, for this article. A few of them are:&lt;br /&gt;http://www.wrox.com/WileyCDA/Section/id-292160.html&lt;br /&gt;http://msdn2.microsoft.com/en-US/library/aa479405.aspx&lt;br /&gt;http://msdn2.microsoft.com/en-us/library/system.web.httpfilecollection.aspx&lt;br /&gt;Conclusion&lt;br /&gt;File uploading in ASP.NET has certainly improved from its earlier versions. However we as developers would like to perform way better than it does today. In this article, I made an attempt to use this control to upload multiple files to the server. I hope this article was useful and I thank you for viewing it.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-9186735324537485287?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/9186735324537485287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=9186735324537485287' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/9186735324537485287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/9186735324537485287'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/05/uploading-multiple-files-in-aspnet-20.html' title='Uploading Multiple Files in ASP.NET 2.0'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-3635089465390153898</id><published>2008-05-02T04:01:00.000-07:00</published><updated>2008-05-02T04:02:27.188-07:00</updated><title type='text'>Exploring the Global.asax file in ASP.NET</title><content type='html'>Have you ever felt the need of writing logic at the application level; precisely a location or a file where you could handle events or errors at the application level? Well if yes, then enter the Global.asax. Using this file, you can define event handlers with application-wide or session-wide scope. In this article, we will explore the application and session level events exposed in the Global.asax file and how we can utilize these events in our applications.&lt;br /&gt;The Global.asax, also known as the ASP.NET application file, is located in the root directory of an ASP.NET application. This file contains code that is executed in response to application-level and session-level events raised by ASP.NET or by HTTP modules. You can also define ‘objects’ with application-wide or session-wide scope in the Global.asax file. These events and objects declared in the Global.asax are applied to all resources in that web application.&lt;br /&gt;Note 1: The Global.asax is an optional file. Use it only when there is a need for it.&lt;br /&gt;Note 2: If a user requests the Global.asax file, the request is rejected. External users cannot view the file.&lt;br /&gt;The Global.asax file is parsed and dynamically compiled by ASP.NET. You can deploy this file as an assembly in the \bin directory of an ASP.NET application.&lt;br /&gt;How to create Global.asax&lt;br /&gt;Adding a Global.asax to your web project is quiet simple. &lt;br /&gt;Open Visual Studio 2005 or 2008 &gt; Create a new website &gt; Go to the Solution Explorer &gt; Add New Item &gt; Global Application Class &gt; Add.&lt;br /&gt;Examining the methods related to the events in Global.asax&lt;br /&gt;There are 2 ‘set’ of methods that fire corresponding to the events. The first set which gets invoked on each request and the second set which does not get invoked on each request. Let us explore these methods.&lt;br /&gt;Methods corresponding to events that fire on each request&lt;br /&gt;Application_BeginRequest() – fired when a request for the web application comes in.&lt;br /&gt;Application_AuthenticateRequest –fired just before the user credentials are authenticated. You can specify your own authentication logic over here.&lt;br /&gt;Application_AuthorizeRequest() – fired on successful authentication of user’s credentials. You can use this method to give authorization rights to user. &lt;br /&gt;Application_ResolveRequestCache() – fired on successful completion of an authorization request. &lt;br /&gt;Application_AcquireRequestState() – fired just before the session state is retrieved for the current request.&lt;br /&gt;Application_PreRequestHandlerExecute() - fired before the page framework begins before executing an event handler to handle the request.&lt;br /&gt;Application_PostRequestHandlerExecute() – fired after HTTP handler has executed the request.&lt;br /&gt;Application_ReleaseRequestState() – fired before current state data kept in the session collection is serialized.&lt;br /&gt;Application_UpdateRequestCache() – fired before information is added to output cache of the page.&lt;br /&gt;Application_EndRequest() – fired at the end of each request&lt;br /&gt;Methods corresponding to events that do not fire on each request&lt;br /&gt;Application_Start() – fired when the first resource is requested from the web server and the web application starts.&lt;br /&gt;Session_Start() – fired when session starts on each new user requesting a page.&lt;br /&gt;Application_Error() – fired when an error occurs.&lt;br /&gt;Session_End() – fired when the session of a user ends.&lt;br /&gt;Application_End() – fired when the web application ends.&lt;br /&gt;Application_Disposed() - fired when the web application is destroyed.&lt;br /&gt;Show me an example!!&lt;br /&gt;Let us see an example of how to use the Global.asax to catch unhandled errors that occur at the application level.&lt;br /&gt;To catch unhandled errors, do the following. Add a Global.asax file (Right click project &gt; Add New Item &gt; Global.asax). In the Application_Error() method, add the following code:&lt;br /&gt; &lt;br /&gt;C#&lt;br /&gt; void Application_Error(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        // Code that runs when an unhandled error occurs&lt;br /&gt;        Exception objErr = Server.GetLastError().GetBaseException();&lt;br /&gt;        string err = "Error in: " + Request.Url.ToString() +&lt;br /&gt;                          ". Error Message:" + objErr.Message.ToString();&lt;br /&gt;        &lt;br /&gt;    }&lt;br /&gt;VB.NET&lt;br /&gt;Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)&lt;br /&gt;        ' Code that runs when an unhandled error occurs        &lt;br /&gt;        Dim objErr As Exception = Server.GetLastError().GetBaseException()&lt;br /&gt;        Dim err As String = "Error in: " &amp; Request.Url.ToString() &amp; ". Error Message:" &amp; objErr.Message.ToString()&lt;br /&gt;        &lt;br /&gt;    End Sub&lt;br /&gt;Here we make use of the Application_Error() method to capture the error using the Server.GetLastError().&lt;br /&gt;Conclusion:&lt;br /&gt;In this article, we learnt that Global.asax is a file used to declare application-level events and objects. The file is responsible for handling higher-level application events such as Application_Start, Application_End, Session_Start, Session_End, and so on. I would encourage you to explore the methods corresponding to the events and analyze the best possible methods to use them in your application, if needed.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-3635089465390153898?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/3635089465390153898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=3635089465390153898' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/3635089465390153898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/3635089465390153898'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/05/exploring-globalasax-file-in-aspnet.html' title='Exploring the Global.asax file in ASP.NET'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-4928141364920352138</id><published>2008-05-02T03:57:00.000-07:00</published><updated>2008-05-02T04:01:14.304-07:00</updated><title type='text'>ASP.NET AJAX Calendar Extender – Tips and Tricks</title><content type='html'>&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;The CalendarExtender is an ASP.NET AJAX control that is associated with a TextBox control. When the user clicks on the TextBox, a client-side Calendar control pops up. The user can then set a date by clicking on a day, navigate months by clicking on the left and right arrow and perform other such actions without a postback. In this article, we will see some tips and tricks that can be applied to a CalendarExtender control. If you are new to the CalendarExtender control, you can check out some information about it over here.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;I assume you have some basic experience developing ASP.NET Ajax applications and have installed the ASP.NET Ajax Library and ASP.NET Control Toolkit. As of this writing, the toolkit version is Version 1.0.20229 (if you are targeting Framework 2.0, ASP.NET AJAX 1.0 and Visual Studio 2005) and Version 3.0.20229 (if targeting .NET Framework 3.5 and Visual Studio 2008).&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;All the tips shown below have been created using Version 3.0.20229 (targeting .NET Framework 3.5 and Visual Studio 2008).&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Tip 1: How to display and hide a Calendar on the click of a Button&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;If you want to popup a Calendar on the click of a button, you can use set the PopupButtonID of the CalendarExtender to the ID of the button. In this case, we will be using an ImageButton as shown below:&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;       &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ImageButton&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="Server"&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="ImageButton1"&lt;/span&gt; &lt;span style="color: red;"&gt;ImageUrl&lt;/span&gt;&lt;span style="color: blue;"&gt;="~/Images/Icon1.jpg"&lt;/span&gt; &lt;span style="color: red;"&gt;AlternateText&lt;/span&gt;&lt;span style="color: blue;"&gt;="Click here to display calendar"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&gt;&lt;/span&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;cc1&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;CalendarExtender&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="CalendarExtender1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: red;"&gt;TargetControlID&lt;/span&gt;&lt;span style="color: blue;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color: red;"&gt;PopupButtonID&lt;/span&gt;&lt;span style="color: blue;"&gt;="ImageButton1"/&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;If you are using an earlier version of the toolkit, you may observe that the ImageButton causes a postback when you click on it again, to close the Calendar. To avoid the postback, use a HTML Image Control instead of the Server side Image Control as shown below: &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;       &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;img&lt;/span&gt; &lt;span style="color: red;"&gt;alt&lt;/span&gt;&lt;span style="color: blue;"&gt;="Icon"&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="/Images/Icon1.jpg"&lt;/span&gt; &lt;span style="color: red;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;="Image1"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;       &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;cc1&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;CalendarExtender&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="CalendarExtender1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: red;"&gt;TargetControlID&lt;/span&gt;&lt;span style="color: blue;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color: red;"&gt;PopupButtonID&lt;/span&gt;&lt;span style="color: blue;"&gt;="Image1"/&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Note:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; In case you are clicking on the textbox to open the calendar, then in earlier versions of the toolkit, the calendar would not hide automatically when the user clicked anywhere outside the Calendar control. However this was fixed in the later versions. In fact, in the latest version, the Calendar hides automatically when a date is selected.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;If for some reason you are facing issues with the Calendar not hiding automatically, make sure that you have the latest version of the AJAX Control Toolkit. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Tip 2: How to Add a CalendarExtender to a GridView&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;If you want to add a CalendarExtender to a GridView, use a template field with a TextBox and CalendarExtender as shown below:&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;    &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;form&lt;/span&gt; &lt;span style="color: red;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;="form1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ScriptManager&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="ScriptManager1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;div&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;GridView&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="GridView1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: red;"&gt;AutoGenerateColumns&lt;/span&gt;&lt;span style="color: blue;"&gt;="False"&lt;/span&gt; &lt;span style="color: red;"&gt;DataKeyNames&lt;/span&gt;&lt;span style="color: blue;"&gt;="CategoryID"&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: red;"&gt;DataSourceID&lt;/span&gt;&lt;span style="color: blue;"&gt;="SqlDataSource1"&lt;/span&gt; &lt;span style="color: red;"&gt;ShowFooter&lt;/span&gt;&lt;span style="color: blue;"&gt;="true"&lt;/span&gt; &lt;span style="color: red;"&gt;AllowPaging&lt;/span&gt;&lt;span style="color: blue;"&gt;="True"&lt;/span&gt; &lt;span style="color: red;"&gt;AllowSorting&lt;/span&gt;&lt;span style="color: blue;"&gt;="True"&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Columns&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;            &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;               &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;BoundField&lt;/span&gt; &lt;span style="color: red;"&gt;DataField&lt;/span&gt;&lt;span style="color: blue;"&gt;="CategoryID"&lt;/span&gt; &lt;span style="color: red;"&gt;HeaderText&lt;/span&gt;&lt;span style="color: blue;"&gt;="CategoryID"&lt;/span&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                 &lt;span style="color: red;"&gt;SortExpression&lt;/span&gt;&lt;span style="color: blue;"&gt;="CategoryID"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;BoundField&lt;/span&gt; &lt;span style="color: red;"&gt;DataField&lt;/span&gt;&lt;span style="color: blue;"&gt;="CategoryName"&lt;/span&gt; &lt;span style="color: red;"&gt;HeaderText&lt;/span&gt;&lt;span style="color: blue;"&gt;="CategoryName"&lt;/span&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                 &lt;span style="color: red;"&gt;SortExpression&lt;/span&gt;&lt;span style="color: blue;"&gt;="CategoryName"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;              &lt;b&gt;&lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TemplateField&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                    &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                    &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;cc1&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;CalendarExtender&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="CalendarExtender1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: red;"&gt;TargetControlID&lt;/span&gt;&lt;span style="color: blue;"&gt;="TextBox1"/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                &lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TemplateField&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Columns&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;GridView&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;SqlDataSource&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="SqlDataSource1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: red;"&gt;ConnectionString&lt;/span&gt;&lt;span style="color: blue;"&gt;="Data Source=SUPROTIM;Initial Catalog=Northwind;Integrated Security=True"&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: red;"&gt;SelectCommand&lt;/span&gt;&lt;span style="color: blue;"&gt;="SELECT [CategoryID], [CategoryName] FROM [Categories]"&lt;/span&gt; &lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;SqlDataSource&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;div&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;    &lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;form&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Tip 3: Enable Year Navigation in CalendarExtender&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;When the calendar appears, click on the title of the calendar to change the view to Months in the current year. Clicking it again, switches the view to Years, showing 10 years at a time. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;If you plan to do this programmatically, here’s some code for you. Use the OnClientShown event and switch the mode using javascript. This tip was shared by one of the Microsoft® support person at the asp.net forums.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;:&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;cc1&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;CalendarExtender&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="CalendarExtender1"&lt;/span&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;runat&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;="server"&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: red;"&gt;TargetControlID&lt;/span&gt;&lt;span style="color: blue;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color: red;"&gt;OnClientShown&lt;/span&gt;&lt;span style="color: blue;"&gt;="ChangeCalendarView"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Then add this to the &lt;head&gt; section&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;head&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;title&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;CalendarExtender&lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;title&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;script&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;function&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; ChangeCalendarView(sender,args)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;{&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;   sender._switchMode(&lt;span style="color: rgb(163, 21, 21);"&gt;"years"&lt;/span&gt;, &lt;span style="color: blue;"&gt;true&lt;/span&gt;);            &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;}&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;script&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;head&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Tip 4: Display only the day and month in the CalendarExtender&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;To select only the day and month without the year, use the Format property of the CalendarExtender and set it to “dd/MM” as shown below:&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;cc1&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;:&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;CalendarExtender&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="CalendarExtender1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: red;"&gt;Format&lt;/span&gt;&lt;span style="color: blue;"&gt;="dd/MM"&lt;/span&gt; &lt;span style="color: red;"&gt;TargetControlID&lt;/span&gt;&lt;span style="color: blue;"&gt;="TextBox1"&lt;/span&gt; /&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt; &lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Tip 5: How to Set Culture to work with CalendarExtender&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Make sure that the ScriptManager has EnableScriptGlobalization="true" and EnableScriptLocalization="true".&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;:&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;ScriptManager&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="ScriptManager1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;         &lt;span style="color: red;"&gt;EnableScriptGlobalization&lt;/span&gt;&lt;span style="color: blue;"&gt;="true"&lt;/span&gt; &lt;span style="color: red;"&gt;EnableScriptLocalization&lt;/span&gt;&lt;span style="color: blue;"&gt;="true"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Tip 6: How to make sure user does not select a date earlier than today or greater than today&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;There could be instances where you do not want the user to select a day earlier than the current date. For example: when you are providing the user a form to book tickets, you would not like him to choose an earlier date. To achieve this requirement, use the following javascript code. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;u&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Prevent the User from selecting a Date Earlier than today&lt;/span&gt;&lt;/u&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;head&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;    &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;title&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;Calendar Extender&lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;title&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;    &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;    &lt;span style="color: blue;"&gt;function&lt;/span&gt; checkDate(sender,args)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;{&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (sender._selectedDate &lt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; Date()) &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            {&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                alert(&lt;span style="color: rgb(163, 21, 21);"&gt;"You cannot select a day earlier than today!"&lt;/span&gt;);&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                sender._selectedDate = &lt;span style="color: blue;"&gt;new&lt;/span&gt; Date(); &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                &lt;span style="color: green;"&gt;// set the date back to the current date&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;sender._textbox.set_Value(sender._selectedDate.format(sender._format))&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            }&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;}&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;    &lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;head&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Call the code:&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;   &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;form&lt;/span&gt; &lt;span style="color: red;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;="form1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ScriptManager&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="ScriptManager1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;div&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;           &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;cc1&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;CalendarExtender&lt;/span&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="CalendarExtender1"&lt;/span&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: red;"&gt;OnClientDateSelectionChanged&lt;/span&gt;&lt;span style="color: blue;"&gt;="checkDate"&lt;/span&gt; &lt;span style="color: red;"&gt;TargetControlID&lt;/span&gt;&lt;span style="color: blue;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color: blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;div&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;    &lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;form&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;u&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Select Date Greater than today&lt;/span&gt;&lt;/u&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;In the javascript, just change this line&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;sender._selectedDate &lt;b&gt;&gt;&lt;/b&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; Date()&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Note:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; You may argue that the user can still change the date by typing into the textbox or entering an invalid date. Well that can be easily handled using a ValidationControl and is covered in the next tip.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Tip 7: Add validation to the CalendarExtender Control&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;A simple way to add validation to the Calendar is to add a ValidationControl to the textbox associated with a CalendarExtender. You have two choices:&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: -0.25in;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;A.&lt;span style="font-size-adjust: none; font-stretch: normal;"&gt;&lt;/span&gt;&lt;span style="font-size: 7pt;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Add an ‘Extender’ to the ValidationControl. To do so, drag and drop a ValidationControl &gt; click on the smart tag of the ValidationControl &gt; choose ‘Add Extender’. From the Extender Wizard, choose ValidatorCalloutExtender. Using this approach makes it extremely easy to discover and attach control extenders to your controls. In VS 2005, you had to do this process manually, by wiring up control extenders.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: -0.25in;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;B.&lt;span style="font-size-adjust: none; font-stretch: normal;"&gt;&lt;/span&gt;&lt;span style="font-size: 7pt;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;You can choose not to add the Extender.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;We will go ahead with option A. We will be adding two ValidationControls to the textbox. The first, a CompareValidator to check if the user does not enter an invalid date (Eg: May 32) and second, a RangeValidator to keep the date range as desired.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;u&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Adding CompareValidator&lt;/span&gt;&lt;/u&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;:&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;CompareValidator&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="CompareValidator1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                &lt;span style="color: red;"&gt;ControlToValidate&lt;/span&gt;&lt;span style="color: blue;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color: red;"&gt;Display&lt;/span&gt;&lt;span style="color: blue;"&gt;="Dynamic"&lt;/span&gt; &lt;span style="color: red;"&gt;ErrorMessage&lt;/span&gt;&lt;span style="color: blue;"&gt;="Invalid Date"&lt;/span&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                &lt;span style="color: red;"&gt;Operator&lt;/span&gt;&lt;span style="color: blue;"&gt;="DataTypeCheck"&lt;/span&gt; &lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;="Date"&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;:&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;CompareValidator&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;cc1&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;:&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;ValidatorCalloutExtender&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="CompareValidator1_ValidatorCalloutExtender"&lt;/span&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: red;"&gt;Enabled&lt;/span&gt;&lt;span style="color: blue;"&gt;="True"&lt;/span&gt; &lt;span style="color: red;"&gt;TargetControlID&lt;/span&gt;&lt;span style="color: blue;"&gt;="CompareValidator1"&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;cc1&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;:&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;ValidatorCalloutExtender&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;u&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Adding RangeValidator&lt;/span&gt;&lt;/u&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; – We will restrict the user to select a date range starting from today to 15 days from now.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;:&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;RangeValidator&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="RangeValidator1"&lt;/span&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                &lt;span style="color: red;"&gt;ControlToValidate&lt;/span&gt;&lt;span style="color: blue;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color: red;"&gt;ErrorMessage&lt;/span&gt;&lt;span style="color: blue;"&gt;="RangeValidator"&lt;/span&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                &lt;span style="color: red;"&gt;Type&lt;/span&gt;&lt;span style="color: blue;"&gt;="Date"&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;:&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;RangeValidator&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;cc1&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;:&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;ValidatorCalloutExtender&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: red;"&gt;ID&lt;/span&gt;&lt;span style="color: blue;"&gt;="RangeValidator1_ValidatorCalloutExtender"&lt;/span&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&lt;/span&gt; &lt;span style="color: red;"&gt;Enabled&lt;/span&gt;&lt;span style="color: blue;"&gt;="True"&lt;/span&gt; &lt;span style="color: red;"&gt;TargetControlID&lt;/span&gt;&lt;span style="color: blue;"&gt;="RangeValidator1"&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;cc1&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;:&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;ValidatorCalloutExtender&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;In the code behind of your page, add this code&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;    &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;    {&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        RangeValidator1.MinimumValue = System.&lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;.Now.ToShortDateString();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        RangeValidator1.MaximumValue = System.&lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;.Now.AddDays(15).ToShortDateString();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;    }&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;VB.NET&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;      &lt;span style="color: blue;"&gt;Protected&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; Page_Load(&lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Object&lt;/span&gt;, &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; EventArgs)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            RangeValidator1.MinimumValue = System.DateTime.Now.ToShortDateString()&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            RangeValidator1.MaximumValue = System.DateTime.Now.AddDays(15).ToShortDateString()&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;      &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Well those were some tips associated with the CalendarExtender. As future versions of the toolkit are released, we should be hopeful that there will exist easier ways, of achieving the functionality discussed in this article. I hope this article was useful and I thank you for viewing it. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-4928141364920352138?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/4928141364920352138/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=4928141364920352138' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/4928141364920352138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/4928141364920352138'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/05/aspnet-ajax-calendar-extender-tips-and.html' title='ASP.NET AJAX Calendar Extender – Tips and Tricks'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-5450783281177760426</id><published>2008-05-02T03:53:00.000-07:00</published><updated>2008-05-02T03:55:33.449-07:00</updated><title type='text'>How to call Server Side function from Client Side Code using PageMethods in ASP.NET AJAX</title><content type='html'>  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;&lt;/span&gt;You cannot call server-side code ‘directly’ from client-side code. That is because by design, the server side code executes at server side and client side code at the client. However there are some workarounds. To call serverside code from javascript, you will need to use &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt;, and the easiest way out, is to use the ASP.NET AJAX Extensions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;One option while using Microsoft ASP.NET AJAX is to call ASP.NET Web services (.asmx files) from the browser by using client script. The script can call a webservice containing server-based methods (Web methods) and invoke these methods without a postback and without refreshing the whole page. However this approach could be overkill sometimes, to perform the simplest of tasks. Moreover the logic needs to be kept in a separate .asmx file. We need something that is more ‘integrated’ with our solution.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The option we are going to use in this article involves PageMethods. A PageMethod is basically a public static method that is exposed in the code-behind of an aspx page and is callable from the client script. PageMethods are annotated with the [WebMethod] attribute. The page methods are rendered as inline JavaScript.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Let us explore PageMethods with an example. The example we will be discussing here may not be the best example to explain PageMethods, but it will give you an idea of how to call server side code from client side. In this example, we will be connecting to the Customers table in the Northwind database. We will have some textboxes which will accept the CustomerID and in turn return the Contact Name of that Customer. The method returning ContactName will be called whenever the textbox loses focus. We will be using the onblur event where a javascript code will take in the value(CustomerID) from the textbox. This javascript function will then call a PageMethod (server side code) which returns the ContactName without any page refresh.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;I assume that you have downloaded and installed ASP.NET AJAX extensions for ASP.NET 2.0. If not, I would advise you to download the extensions from here and install it before moving ahead. At any point of time, if you find a difficulty in understanding the code, download the sample project attached with this article at the end.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Step 1: Create an ASP.NET AJAX enabled website. Go to File &gt; New &gt; Website &gt; ASP.NET AJAX-Enabled Web Site. Give the solution a name and location and click Ok.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Step 2: Drag and drop 2 labels and 4 textbox controls. We will be accepting the CustomerID from the user in the 2 textboxes and displaying the ‘ContactName’ in the other two textboxes. The textboxes that will display ‘ContactName’ has some properties set that will make it appear as a label without a border. Just set the BorderStyle=None, BorderColor=Transparent and ReadOnly=True. The markup will look similar to the following:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;form id="form1" runat="server"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;asp:scriptmanager id="ScriptManager1" runat="server"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/asp:scriptmanager&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;asp:label id="lblCustId1" runat="server" text="Customer ID 1"&gt;&lt;/asp:label&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;asp:textbox id="txtContact1" runat="server" bordercolor="Transparent" borderstyle="None"&gt;&lt;/asp:textbox&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;                &lt;/span&gt;ReadOnly="True"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;asp:label id="lblCustId2" runat="server" text="Customer ID 2"&gt;&lt;/asp:label&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;asp:textbox id="txtId2" runat="server"&gt;&lt;/asp:textbox&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;asp:textbox id="txtContact2" runat="server" bordercolor="Transparent" borderstyle="None"&gt;&lt;/asp:textbox&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;                &lt;/span&gt;ReadOnly="True"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/p&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/form&gt;  &lt;p class="MsoNormal"&gt;Before moving ahead, we will store our connection string information in the Web.config. Add the following tag below your  tag. Remember we have created an ‘ASP.NET AJAX enabled website’. The tag  along with some other tags automatically get added to the web.config.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;connectionstrings&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/connectionstrings&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;removename="all"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/removename="all"&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;addname="northwindconnectionstring"connectionstring="data source="(local);" catalog="Northwind;" security=" SSPI;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/addname="northwindconnectionstring"connectionstring="data&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Step 3: Currently we will add a method, ‘GetContactName()’ which will accept a CustomerID and return the Contact Name information from the Northwind database, Customer table. We will then transform this method as a PageMethod.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;C#&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;public static string GetContactName(string custid)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;if (custid == null || custid.Length == 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;return String.Empty;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;SqlConnection conn = null;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;string connection = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;conn = new SqlConnection(connection);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;string sql = "Select ContactName from Customers where CustomerId = @CustID";&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;SqlCommand cmd = new SqlCommand(sql, conn);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;cmd.Parameters.AddWithValue("CustID", custid);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;conn.Open();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;string contNm = Convert.ToString(cmd.ExecuteScalar());&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;return contNm;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;catch (SqlException ex)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;return "error";&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;finally&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;conn.Close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;VB.NET&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;Public Shared Function GetContactName(ByVal custid As String) As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;If custid Is Nothing OrElse custid.Length = 0 Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;Return String.Empty&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;End If&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;Dim conn As SqlConnection = Nothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;Try&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;Dim connection As String = ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;conn = New SqlConnection(connection)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;Dim sql As String = "Select ContactName from Customers where CustomerId = @CustID"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;Dim cmd As SqlCommand = New SqlCommand(sql, conn)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;cmd.Parameters.AddWithValue("CustID", custid)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;conn.Open()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;Dim contNm As String = Convert.ToString(cmd.ExecuteScalar())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;Return contNm&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;Catch ex As SqlException&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;Return "error"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;Finally&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;conn.Close()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;End Try&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;End Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Step 4: We will now transform this method as a PageMethod and then call this method GetContactName() from client side code; i.e. using JavaScript. To enable the method as a PageMethod, add the attribute [WebMethod] on top of the method:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;C#&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;[System.Web.Services.WebMethod]&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;public static string GetContactName(string custid)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;VB.NET&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;system.web.services.webmethod()&gt; _&lt;o:p&gt;&lt;/o:p&gt;&lt;/system.web.services.webmethod()&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;Public Shared Function GetContactName(ByVal custid As String) As String&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;   &lt;/span&gt;End Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;At the sametime, add the attribute EnablePageMethods="true" to the ScriptManager as shown below:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;asp:scriptmanager id="ScriptManager1" runat="server" enablepagemethods="true"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/asp:scriptmanager&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Step 5: Let us now create the JavaScript that will call this server side code. Add a javascript file called script.js to your solution (Right Click Project &gt; Add New Item &gt; Jscript File &gt; Rename file to script.js). Add the following code to the javascript file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;function CallMe(src,dest)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;{&lt;span style=""&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;     &lt;/span&gt;var ctrl = document.getElementById(src);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;     &lt;/span&gt;// call server side method&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;     &lt;/span&gt;PageMethods.GetContactName(ctrl.value, CallSuccess, CallFailed, dest);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;// set the destination textbox value with the ContactName&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;function CallSuccess(res, destCtrl)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;{&lt;span style=""&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;     &lt;/span&gt;var dest = document.getElementById(destCtrl);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;     &lt;/span&gt;dest.value = res;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;// alert message on some failure&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;function CallFailed(res, destCtrl)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;     &lt;/span&gt;alert(res.get_message());&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Step 6: We now need to reference this JavaScript file from our aspx page and invoke the ‘CallMe()’ method whenever the textbox loses focus. To do so:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Add a reference to the javascript file in the body tag as shown below:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;script type="text/javascript" language="javascript" src="script.js"&gt; &lt;/script&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/p&gt;&lt;form id="form1" runat="server"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;………&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Step 7: To invoke the methods whenever the textbox looses focus, add these lines of code in the Page_Load() event&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;C#&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;if (!Page.IsPostBack)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;txtId1.Attributes.Add("onblur", "javascript:CallMe('" + txtId1.ClientID + "', '" + txtContact1.ClientID + "')");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;txtId2.Attributes.Add("onblur", "javascript:CallMe('" + txtId2.ClientID + "', '" + txtContact2.ClientID + "')");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;VB.NET&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;If (Not Page.IsPostBack) Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;                  &lt;/span&gt;txtId1.Attributes.Add("onblur", "javascript:CallMe('" &amp;amp; txtId1.ClientID &amp;amp; "', '" &amp;amp; txtContact1.ClientID &amp;amp; "')")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;                  &lt;/span&gt;txtId2.Attributes.Add("onblur", "javascript:CallMe('" &amp;amp; txtId2.ClientID &amp;amp; "', '" &amp;amp; txtContact2.ClientID &amp;amp; "')")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End If&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;As shown above, we are using the Attributes.Add that lets us add an attribute to the server control’s System.Web.UI.AttributeCollection object. The function ‘CallMe’ kept in the ‘script.js’ file will be invoked. We are passing the source and destination textboxes as parameters. The source textbox will contain the CustomerID. The CustomerID will be looked up in the Customers table and the corresponding ‘ContactName’ will be retrieved in the destination textbox.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Well that is all that is needed to invoke server side code from client side. Run the code. Type ‘ALFKI’ in the first textbox and hit the tab key. You will see that the javascript function goes ahead and calls the PageMethod GetContactName() using PageMethods.GetContactName. It passes the value of the source textbox which contains the CustomerID. The ‘ContactName’ returned is displayed in the second textbox below the first one, in our case the value displayed is ‘Maria Anders’.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Troubleshooting: ‘PageMethods Is 'Undefined'’ error&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;1.&lt;span style=""&gt;    &lt;/span&gt;Try setting EnablePageMethods="true" in the script manager tag&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;asp:scriptmanager id="ScriptManager1" runat="server" enablepagemethods="true"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/asp:scriptmanager&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;2.&lt;span style=""&gt;    &lt;/span&gt;Don't add the javascript references or code in the  section. Add it to the  tag.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;script type="text/javascript" language="javascript" src="script.js"&gt; &lt;/script&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/p&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/p&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/form&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;3.&lt;span style=""&gt;    &lt;/span&gt;Page methods needs to be static in code behind.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-5450783281177760426?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/5450783281177760426/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=5450783281177760426' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/5450783281177760426'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/5450783281177760426'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/05/how-to-call-server-side-function-from.html' title='How to call Server Side function from Client Side Code using PageMethods in ASP.NET AJAX'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-4679318767177767896</id><published>2008-04-30T02:11:00.000-07:00</published><updated>2008-04-30T02:13:29.024-07:00</updated><title type='text'>How to view information in ViewState using ASP.NET 2.0 and 3.5</title><content type='html'>Http is a stateless protocol. Hence the state of controls is not saved between postbacks. Viewstate is the means of storing the state of server side controls between postbacks. Viewstate stores the state of controls in HTML hidden fields. In other words, it is a  snapshot of the contents of a page.&lt;br /&gt;When set to True, the ‘EnableViewState’ property enables storing the state of an object in a page between postbacks. Objects are saved in a Base64 encoded string. Because it is a Base64 encoded string, it is not readable by the human eye. However it is also not difficult to decode the viewstate and view the contents of the viewstate when it is passed over the wire. In this article we will see how to decode and view the contents of a viewstate.&lt;br /&gt;Step 1: Create an asp.net application with 2 textboxes, a label and a button as shown below. On the button click, we will concatenate the values of the 2 textbox and display this information in the label control.&lt;br /&gt;&lt;form id="form1" runat="server"&gt;&lt;div&gt;       &lt;br /&gt;&lt;/div&gt;Step 2: Add the button click event:&lt;br /&gt;&lt;/form&gt;C#&lt;br /&gt;protected void Button1_Click(object sender, EventArgs e)&lt;br /&gt;   {&lt;br /&gt;       Label1.Text = TextBox1.Text + " " + TextBox2.Text;     &lt;br /&gt;   }&lt;br /&gt;VB.NET&lt;br /&gt;Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)&lt;br /&gt;     Label1.Text = TextBox1.Text &amp;amp; " " &amp;amp; TextBox2.Text&lt;br /&gt;End Sub&lt;br /&gt;Step 3: Execute the page and enter some values in the textbox. We will enter the value ‘I Love’ and ‘Dotnetcurry.com’ respectively in the two textboxes. Now click the button. The label will contain the concatenated value and should display ‘I Love Dotnetcurry.com’. Now right click on the page &gt; View Source.&lt;br /&gt;Along with the other html text, you will see the following:&lt;br /&gt;&lt;input name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJODczNjQ5OTk0D2QWAgIDD2QWAgIFDw8WAh4EV GV4dAUWSSBMb3ZlIERvdG5ldEN1cnJ5LmNvbWRkZMHbBY9JqBTvB5 /6kXnY15AUSAwa" type="hidden"&gt;&lt;br /&gt;Step 4: Shown above in the blue colored text is the viewstate. This is the Base64 encoded string which we will be decoding. Do the following. Add another textbox and button control on to the page. Rename the textbox to ‘txtViewState’ and set its ‘TextMode’ property to ‘Multiline’. Set the text property of the button control to ‘View ViewState’ as shown below:&lt;br /&gt;&lt;br /&gt;View State&lt;br /&gt;&lt;asp:button id="Button2" runat="server" onclick="Button2_Click" text="View ViewState"&gt;&lt;br /&gt;On the button click add the following code.&lt;br /&gt;C#&lt;br /&gt;protected void Button2_Click(object sender, EventArgs e)&lt;br /&gt;   {&lt;br /&gt;       byte[] decode = Convert.FromBase64String(txtViewState.Text);&lt;br /&gt;       txtViewState.Text = System.Text.Encoding.ASCII.GetString(decode);&lt;br /&gt;   }&lt;br /&gt;VB.NET&lt;br /&gt;Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs)&lt;br /&gt;           Dim decode As Byte() = Convert.FromBase64String(txtViewState.Text)&lt;br /&gt;           txtViewState.Text = System.Text.Encoding.ASCII.GetString(decode)&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Step 5:&lt;br /&gt;&lt;br /&gt;Repeat Step 3. Copy the blue colored text and paste it in the ‘txtViewState’ textbox. Now click on the second button ‘View ViewState’. You will see that the decoded viewstate is displayed in the textbox as shown below:&lt;br /&gt;?       873649994d[1][1] d[1][1][1]  TextI Love DotnetCurry.comddd???I? ????y??? H&lt;br /&gt;Even though there are junk characters displayed in the textbox, however you can make out that the textbox contained the word ‘I Love DotnetCurry.com’&lt;br /&gt;Well that was simple, wasn’t it? In the coming articles we will see how to encrypt viewstate in order to prevent its contents to be decoded.&lt;br /&gt;&lt;/asp:button&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-4679318767177767896?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/4679318767177767896/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=4679318767177767896' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/4679318767177767896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/4679318767177767896'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/how-to-view-information-in-viewstate.html' title='How to view information in ViewState using ASP.NET 2.0 and 3.5'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-7877092625440902465</id><published>2008-04-30T02:08:00.000-07:00</published><updated>2008-04-30T02:09:22.271-07:00</updated><title type='text'>Pass Multiple Values from a GridView to Another Page  using ASP.NET</title><content type='html'> &lt;br /&gt;A common requirement in our projects is to select a GridView row and pass multiple values of the selected row to another page. I recently got a request from a few readers who wanted an article on this. In this article, we will explore how simple it is to achieve this requirement.&lt;br /&gt;I assume you have some basic understanding of the GridView and how to bind it to a Data Source control. The Hyperlink control added to the GridView makes it quiet easy to select a row and send single/multiple values to a different page through the URL. Let us see how:&lt;br /&gt;Step 1: Create a new ASP.NET website. Drag and drop a SqlDataSource Control to the page and use the wizard to connect to the Northwind database. Select the CustomerId, CompanyName, ContactName, Address and City from the Customers table. The wizard will also prompt you to save the connection string in the web.config file. Choose to do so. The design code will look similar to the following:&lt;br /&gt;      &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:NorthwindConnectionString %&gt;"&lt;br /&gt;            SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [Address], [City] FROM [Customers]"&gt;&lt;br /&gt;        &lt;/asp:SqlDataSource&gt;&lt;br /&gt;An entry will be added to the web.config file as shown below:&lt;br /&gt;      &lt;connectionStrings&gt;&lt;br /&gt;            &lt;add name="NorthwindConnectionString" connectionString="Data Source=(local);Initial Catalog=Northwind;Integrated Security=True"providerName="System.Data.SqlClient"/&gt;&lt;br /&gt;      &lt;/connectionStrings&gt;&lt;br /&gt;Step 2: Now add a GridView control to the page and using the smart tag, select the DataSource to be SqlDataSource1 in the GridView tasks panel. Using the same panel, click on the Enable Paging and Enable Sorting checkboxes. The source will look similar to the following. Observe that the DataKeyNames is set to ‘CustomerId’, that is the primary key of the Customers table.&lt;br /&gt;        &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CustomerID"&lt;br /&gt;            DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True"&gt;&lt;br /&gt;            &lt;Columns&gt;           &lt;br /&gt;                &lt;asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID" /&gt;&lt;br /&gt;                &lt;asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" /&gt;&lt;br /&gt;                &lt;asp:BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" /&gt;&lt;br /&gt;                &lt;asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" /&gt;&lt;br /&gt;                &lt;asp:BoundField DataField="City" HeaderText="City" SortExpression="City" /&gt;&lt;br /&gt;            &lt;/Columns&gt;&lt;br /&gt;        &lt;/asp:GridView&gt;&lt;br /&gt;Step 3: We will now add another page in our project. In the Solution Explorer, right click the project &gt; Add New Item &gt; Web Form &gt; Rename it to ‘CustomerDetails.aspx’.&lt;br /&gt;Step 4: Go back to Default.aspx and add two hyperlink fields. We will see how to pass a single value as well as multiple values using the two hyperlink fields.&lt;br /&gt;Single Value:&lt;br /&gt;Add the following hyperlink control after the &lt;Columns&gt; tag in the GridView as shown below:&lt;br /&gt;&lt;Columns&gt;&lt;br /&gt;&lt;asp:HyperLinkField DataNavigateUrlFields="CustomerID" DataNavigateUrlFormatString="CustomerDetails.aspx?CID={0}" Text="Pass Single Value" /&gt;&lt;br /&gt;Multiple Values:&lt;br /&gt;Just below the first hyperlink field, add another hyperlink field as shown below:&lt;br /&gt;&lt;asp:HyperLinkField DataNavigateUrlFields="CustomerID, CompanyName, ContactName, Address, City" DataNavigateUrlFormatString="CustomerDetails.aspx?CID={0}&amp;CName={1}&amp;ContactName={2}&amp;Addr={3}&amp;City={4}" Text="Pass Multiple Values" /&gt;&lt;br /&gt; &lt;br /&gt;In the source code shown above, we are using the hyperlink field and setting some properties that will make it extremely easy to pass values to a different page. The 'DataNavigateUrlFields' sets the names of the fields, that is to be used to construct the URL  in the HyperLinkField. In the first hyperlink, since we are passing only a single value, the DataNavigateUrlFields contains only CustomerID. However in the second hyperlink, since there are multiple values to be passed, DataNavigateUrlFields contains all the names of the fields that are to be passed as query string to CustomerDetails.aspx&lt;br /&gt;Similarly, the 'DataNavigateUrlFormatString' sets the string that specifies the format in which the URL is to be created. The 'Text' property represents the text that will be displayed to the user. The entire source code will look similar to the following:&lt;br /&gt;&lt;body&gt;&lt;br /&gt;    &lt;form id="form1" runat="server"&gt;&lt;br /&gt;    &lt;div&gt;&lt;br /&gt;        &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:NorthwindConnectionString %&gt;"&lt;br /&gt;            SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [Address], [City] FROM [Customers]"&gt;&lt;br /&gt;        &lt;/asp:SqlDataSource&gt;&lt;br /&gt;   &lt;br /&gt;    &lt;/div&gt;&lt;br /&gt;        &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CustomerID"&lt;br /&gt;            DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True"&gt;&lt;br /&gt;            &lt;Columns&gt;           &lt;br /&gt;                 &lt;asp:HyperLinkField DataNavigateUrlFields="CustomerID"&lt;br /&gt;                    DataNavigateUrlFormatString="CustomerDetails.aspx?CID={0}"&lt;br /&gt;                     Text="Pass Single Value" /&gt;&lt;br /&gt;                   &lt;asp:HyperLinkField DataNavigateUrlFields="CustomerID, CompanyName, ContactName, Address, City"&lt;br /&gt;                    DataNavigateUrlFormatString="CustomerDetails.aspx?CID={0}&amp;CName={1}&amp;ContactName={2}&amp;Addr={3}&amp;City={4}"&lt;br /&gt;                      Text="Pass Multiple Values" /&gt;&lt;br /&gt;                &lt;asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID" /&gt;&lt;br /&gt;                &lt;asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" /&gt;&lt;br /&gt;                &lt;asp:BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" /&gt;&lt;br /&gt;                &lt;asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" /&gt;&lt;br /&gt;                &lt;asp:BoundField DataField="City" HeaderText="City" SortExpression="City" /&gt;&lt;br /&gt;            &lt;/Columns&gt;&lt;br /&gt;        &lt;/asp:GridView&gt;&lt;br /&gt;    &lt;/form&gt;&lt;br /&gt;&lt;/body&gt;&lt;br /&gt;Step 5: The last step is to retrieve the query string variables from the URL in the CustomerDetails.aspx page. Add the following code for that:&lt;br /&gt;C#&lt;br /&gt;    protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        string cid = Request.QueryString["CID"];&lt;br /&gt;        string cname = Request.QueryString["CName"];&lt;br /&gt;        string contactName = Request.QueryString["ContactName"];&lt;br /&gt;        string address = Request.QueryString["Addr"];&lt;br /&gt;        string city = Request.QueryString["City"];&lt;br /&gt;    }&lt;br /&gt;VB.NET&lt;br /&gt;      Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)&lt;br /&gt;            Dim cid As String = Request.QueryString("CID")&lt;br /&gt;            Dim cname As String = Request.QueryString("CName")&lt;br /&gt;            Dim contactName As String = Request.QueryString("ContactName")&lt;br /&gt;            Dim address As String = Request.QueryString("Addr")&lt;br /&gt;            Dim city As String = Request.QueryString("City")&lt;br /&gt;      End Sub&lt;br /&gt;Set a breakpoint at the Page_Load method of the CustomerDetails.aspx. Run the application and click on either the ‘Pass Single Value’ or ‘Pass Multiple Values’ hyperlink to pass values to the CustomerDetails.aspx page. Using the breakpoint, observe the values of the selected row being passed to the CustomerDetails page.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-7877092625440902465?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/7877092625440902465/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=7877092625440902465' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/7877092625440902465'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/7877092625440902465'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/pass-multiple-values-from-gridview-to.html' title='Pass Multiple Values from a GridView to Another Page  using ASP.NET'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-3603025723207193511</id><published>2008-04-30T02:07:00.001-07:00</published><updated>2008-04-30T02:07:55.022-07:00</updated><title type='text'>Consuming RSS Feed using ASP.NET</title><content type='html'>&lt;br /&gt;RSS stands for Really Simple Syndication. It is a format used to publish regularly updated web content such as blogs, articles, news sites etc. In this article we will explore how to consume a RSS feed of a site.&lt;br /&gt;Now if you happen to visit a website regularly and have to often to go that website physically, to check if there is some new content available, then RSS feed is what you are looking out for. If that website provides RSS feed, all you need to do is subscribe to it. You can then use any RSS reader (like the one we will be building) which checks for updated content frequently and displays it to you. Handy, isn’t it!&lt;br /&gt;For eg: I assume some of you like visiting dotnetcurry.com to check for new articles. Instead what you can do is subscribe to my RSS feed over here:&lt;br /&gt;http://feeds.feedburner.com/netCurryRecentArticles&lt;br /&gt;Then by using a RSS reader, you can view the latest updated content of this site. Without further ado, let us see how to consume a RSS feed of any website in your application. For demonstration purposes, we will be consuming the RSS feed of dotnetcurry in our application.&lt;br /&gt;Note: Once you visit the url given above, right click on the page and View Source. You will find an XML file, since RSS is nothing but an XML file.&lt;br /&gt;Step 1: Create a new website (Open VS 2005 &gt; File &gt; New Website) called ‘RSSFeed’.&lt;br /&gt;Step 2: Drag and drop a XMLDataSource from the toolbox on to the Default.aspx. If the ‘Configure Data Source’ option is not visible on the XMLDataSource, click the smart tag (arrow just above the XMLDataSource) to make it visible and click on the link.&lt;br /&gt;Step 3: The ‘Configure Data Source’ dialog appears. Add the following entries:&lt;br /&gt;Data File - http://feeds.feedburner.com/netCurryRecentArticles&lt;br /&gt;Transform File – Specify an .XSL file if you have one. This is used to beautify or change the layout of the XML file.&lt;br /&gt;XPath Expression - rss/channel/item&lt;br /&gt;Once the entries has been added, click ok to close the dialog.&lt;br /&gt;Tip: If you wish to limit the number of RSS items to a limited item, use XPath as shown below.&lt;br /&gt;&lt;asp:xmldatasource id="XmlDataSource1" runat="server" datafile="http://feeds.feedburner.com/netCurryRecentArticles" xpath="rss/channel/item [position()&lt;=10]"&gt;&lt;/asp:xmldatasource&gt;&lt;br /&gt;&lt;br /&gt;Step 4: Now drag and drop a ‘DataList’ control from the toolbox on to Default.aspx. Click the smart tag to display the ‘Choose Data Source’. Choose ‘XMLDataSource1’ option from the dropdown.&lt;br /&gt;Step 5: Now go to the ‘Source’ view of Default.aspx. Create an &lt;itemtemplate&gt; within the &lt;asp:datalist&gt; element as shown below:&lt;br /&gt;&lt;br /&gt;&lt;itemtemplate&gt;&lt;br /&gt;               &lt;%#XPath("title")%&gt;&lt;br /&gt;&lt;br /&gt;               &lt;%#XPath("pubDate")%&gt;&lt;br /&gt;&lt;br /&gt;               &lt;%#XPath("author")%&gt;&lt;br /&gt;&lt;br /&gt;               &lt;%#XPath("description")%&gt;&lt;br /&gt;&lt;/itemtemplate&gt;&lt;br /&gt;After adding some UI look and feel to the DataList, the entire source code will look similar to the following:&lt;br /&gt;C#&lt;br /&gt;&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;title&gt;RSS Feed&lt;/title&gt;   &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   &lt;/asp:datalist&gt;&lt;/itemtemplate&gt;&lt;form id="form1" runat="server"&gt;&lt;br /&gt;   &lt;div&gt;&lt;br /&gt;       &lt;asp:xmldatasource id="XmlDataSource1" runat="server" datafile="http://feeds.feedburner.com/netCurryRecentArticles" xpath="rss/channel/item"&gt;&lt;/asp:xmldatasource&gt;&lt;br /&gt;  &lt;br /&gt;   &lt;/div&gt;&lt;br /&gt;       &lt;asp:datalist id="DataList1" runat="server" datasourceid="XmlDataSource1" backcolor="White" bordercolor="#404040" borderstyle="Solid" gridlines="Vertical"&gt;&lt;br /&gt;           &lt;itemtemplate&gt;&lt;br /&gt;               &lt;%#XPath("title")%&gt;&lt;br /&gt;&lt;br /&gt;               &lt;%#XPath("pubDate")%&gt;&lt;br /&gt;&lt;br /&gt;               &lt;%#XPath("author")%&gt;&lt;br /&gt;&lt;br /&gt;               &lt;%#XPath("description")%&gt;&lt;br /&gt;           &lt;/itemtemplate&gt;&lt;br /&gt;           &lt;alternatingitemstyle backcolor="CadetBlue"&gt;&lt;br /&gt;           &lt;itemstyle backcolor="AliceBlue" forecolor="Black"&gt;&lt;br /&gt;           &lt;headerstyle backcolor="#804040" forecolor="White" bold="true"&gt;&lt;br /&gt;       &lt;/headerstyle&gt;&lt;br /&gt;   &lt;/itemstyle&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;VB.NET&lt;br /&gt;&lt;%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;title&gt;RSS Feed&lt;/title&gt;   &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   &lt;/alternatingitemstyle&gt;&lt;/asp:datalist&gt;&lt;/form&gt;&lt;form id="form1" runat="server"&gt;&lt;br /&gt;   &lt;div&gt;&lt;br /&gt;       &lt;asp:xmldatasource id="XmlDataSource1" runat="server" datafile="http://feeds.feedburner.com/netCurryRecentArticles" xpath="rss/channel/item"&gt;&lt;/asp:xmldatasource&gt;&lt;br /&gt;  &lt;br /&gt;   &lt;/div&gt;&lt;br /&gt;       &lt;asp:datalist id="DataList1" runat="server" datasourceid="XmlDataSource1" backcolor="White" bordercolor="#404040" borderstyle="Solid" gridlines="Vertical"&gt;&lt;br /&gt;           &lt;itemtemplate&gt;&lt;br /&gt;               &lt;%#XPath("title")%&gt;&lt;br /&gt;&lt;br /&gt;               &lt;%#XPath("pubDate")%&gt;&lt;br /&gt;&lt;br /&gt;               &lt;%#XPath("author")%&gt;&lt;br /&gt;&lt;br /&gt;               &lt;%#XPath("description")%&gt;&lt;br /&gt;           &lt;/itemtemplate&gt;&lt;br /&gt;           &lt;alternatingitemstyle backcolor="CadetBlue"&gt;&lt;br /&gt;           &lt;itemstyle backcolor="AliceBlue" forecolor="Black"&gt;&lt;br /&gt;           &lt;headerstyle backcolor="#804040" forecolor="White" bold="true"&gt;&lt;br /&gt;       &lt;/headerstyle&gt;&lt;br /&gt;   &lt;/itemstyle&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/alternatingitemstyle&gt;&lt;/asp:datalist&gt;&lt;/form&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-3603025723207193511?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/3603025723207193511/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=3603025723207193511' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/3603025723207193511'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/3603025723207193511'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/consuming-rss-feed-using-aspnet.html' title='Consuming RSS Feed using ASP.NET'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-5416292130936757948</id><published>2008-04-30T02:04:00.000-07:00</published><updated>2008-04-30T02:07:09.310-07:00</updated><title type='text'>Read Data From an Excel File (.xlsx) in ASP.NET</title><content type='html'>  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 18pt; font-family: Cambria; color: rgb(54, 95, 145);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;In this article, we will see how to display data from an Excel spreadsheet using ASP.NET. We will connect to a Microsoft Excel workbook using the OLEDB.NET data provider, extract data and then display the data in a GridView. Let us get started.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Step 1:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; Open Visual Studio &gt; File &gt; New &gt;Website &gt; Under Templates, click ASP.NET WebSite and choose either Visual C# or Visual Basic as the language. Select a location and click Ok.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Step 2:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; We will create two excel sheets and add them to the project. One excel sheet will be created in Office 2003(.xls) and the other one using Office 2007(.xlsx). Add 4 columns called EID, EName, Age and City to the ‘Sheet1’. Also add some data into the columns. Once these excel files are created, add them to your project. To add them to the project, right click project &gt; Add Existing Item &gt; Add the two excel files.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Step 3:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; We will now create a web.config file to store the connection string information. Right click project &gt; Add New Item &gt; Web.config. Add the following entries to the file&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;      &lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;connectionStrings&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;            &lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;add &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;name&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;"&lt;span style="color: blue;"&gt;xls&lt;/span&gt;"&lt;span style="color: red;"&gt;connectionString&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Sample1.xls;Extended Properties=Excel 8.0&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;            &lt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;add &lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: red;"&gt;name&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;"&lt;span style="color: blue;"&gt;xlsx&lt;/span&gt;"&lt;span style="color: red;"&gt;connectionString&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Sample.xlsx;Extended Properties=Excel 12.0&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;      &lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(163, 21, 21);"&gt;connectionStrings&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue;"&gt;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;As you can observe, the connection string for xlsx (Excel 2007) contains Microsoft.ACE.OLEDB.12.0 as the provider. This is the new Access database engine OLE DB driver and is also capable of reading Excel 2003.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Step 4:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; Add a GridView to the Default.aspx page. We will extract  data from the excel file and bind it to the GridView.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;Step 5:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; Let us now create a connection to the excel file and extract data from it. Before that add a reference to&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt; System.Data.OleDb;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;    &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;    {&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;string&lt;/span&gt; connString = &lt;span style="color: rgb(43, 145, 175);"&gt;ConfigurationManager&lt;/span&gt;.ConnectionStrings[&lt;span style="color: rgb(163, 21, 21);"&gt;"xls"&lt;/span&gt;].ConnectionString;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: green;"&gt;// Create the connection object &lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: rgb(43, 145, 175);"&gt;OleDbConnection&lt;/span&gt; oledbConn = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;OleDbConnection&lt;/span&gt;(connString);&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;try&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        {&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: green;"&gt;// Open connection&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            oledbConn.Open();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: green;"&gt;// Create OleDbCommand object and select data from worksheet Sheet1&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: rgb(43, 145, 175);"&gt;OleDbCommand&lt;/span&gt; cmd = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;OleDbCommand&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"SELECT * FROM [Sheet1$]"&lt;/span&gt;, oledbConn);&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: green;"&gt;// Create new OleDbDataAdapter &lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: rgb(43, 145, 175);"&gt;OleDbDataAdapter&lt;/span&gt; oleda = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;OleDbDataAdapter&lt;/span&gt;();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            oleda.SelectCommand = cmd;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: green;"&gt;// Create a DataSet which will hold the data extracted from the worksheet.&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: rgb(43, 145, 175);"&gt;DataSet&lt;/span&gt; ds = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;DataSet&lt;/span&gt;();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: green;"&gt;// Fill the DataSet from the data extracted from the worksheet.&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            oleda.Fill(ds, &lt;span style="color: rgb(163, 21, 21);"&gt;"Employees"&lt;/span&gt;);&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: green;"&gt;// Bind the data to the GridView&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            GridView1.DataSource = ds.Tables[0].DefaultView;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            GridView1.DataBind();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        }&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        {&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        }&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        &lt;span style="color: blue;"&gt;finally&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        {&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: green;"&gt;// Close connection&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            oledbConn.Close();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;        }      &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;    }&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;VB.NET&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;      &lt;span style="color: blue;"&gt;Protected&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; Page_Load(&lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Object&lt;/span&gt;, &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; EventArgs)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; connString &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;String&lt;/span&gt; = ConfigurationManager.ConnectionStrings("xls").ConnectionString&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: green;"&gt;' Create the connection object &lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; oledbConn &lt;span style="color: blue;"&gt;As&lt;/span&gt; OleDbConnection = &lt;span style="color: blue;"&gt;New&lt;/span&gt; OleDbConnection(connString)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: blue;"&gt;Try&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  &lt;span style="color: green;"&gt;' Open connection&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  oledbConn.Open()&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  &lt;span style="color: green;"&gt;' Create OleDbCommand object and select data from worksheet Sheet1&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; cmd &lt;span style="color: blue;"&gt;As&lt;/span&gt; OleDbCommand = &lt;span style="color: blue;"&gt;New&lt;/span&gt; OleDbCommand("SELECT * FROM [Sheet1$]", oledbConn)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  &lt;span style="color: green;"&gt;' Create new OleDbDataAdapter &lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; oleda &lt;span style="color: blue;"&gt;As&lt;/span&gt; OleDbDataAdapter = &lt;span style="color: blue;"&gt;New&lt;/span&gt; OleDbDataAdapter()&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  oleda.SelectCommand = cmd&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  &lt;span style="color: green;"&gt;' Create a DataSet which will hold the data extracted from the worksheet.&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; ds &lt;span style="color: blue;"&gt;As&lt;/span&gt; DataSet = &lt;span style="color: blue;"&gt;New&lt;/span&gt; DataSet()&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  &lt;span style="color: green;"&gt;' Fill the DataSet from the data extracted from the worksheet.&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  oleda.Fill(ds, "Employees")&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  &lt;span style="color: green;"&gt;' Bind the data to the GridView&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  GridView1.DataSource = ds.Tables(0).DefaultView&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  GridView1.DataBind()&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: blue;"&gt;Catch&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: blue;"&gt;Finally&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  &lt;span style="color: green;"&gt;' Close connection&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;                  oledbConn.Close()&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;            &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Try&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;      &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;All set!! Run the application and see the data getting displayed in the GridView. If you want to target the Excel 2007 sheet, just change xls to xlsx in the ConfigurationManager.ConnectionString. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;I hope this article was useful and I thank you for viewing it.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-5416292130936757948?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/5416292130936757948/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=5416292130936757948' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/5416292130936757948'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/5416292130936757948'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/read-data-from-excel-file-xlsx-in.html' title='Read Data From an Excel File (.xlsx) in ASP.NET'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-1806044962693396429</id><published>2008-04-30T02:03:00.000-07:00</published><updated>2008-04-30T02:04:13.529-07:00</updated><title type='text'>Exploring the Global.asax file in ASP.NET</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Have you ever felt the need of writing logic at the application level; precisely a location or a file where you could handle events or errors at the application level? Well if yes, then enter the Global.asax. Using this file, you can &lt;span style="color:black;"&gt;define event handlers with application-wide or session-wide scope.&lt;/span&gt; In this article, we will explore the application and session level events exposed in the Global.asax file and how we can utilize these events in our applications.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;The Global.asax, also known as the ASP.NET application file, is located in the root directory of an ASP.NET application. This file contains code that is executed in response to application-level and session-level events raised by ASP.NET or by &lt;span class="klink"&gt;&lt;u&gt;&lt;span style="color:blue;"&gt;HTTP modules&lt;/span&gt;&lt;/u&gt;&lt;/span&gt;. You can also &lt;span style="color:black;"&gt;define ‘objects’ with application-wide or session-wide scope in the Global.asax file. These events and objects declared in the Global.asax are applied to all resources in that web application.&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Note 1:&lt;/span&gt;&lt;/b&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt; The Global.asax is an optional file. Use it only when there is a need for it.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Note 2:&lt;/span&gt;&lt;/b&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt; If a user requests the Global.asax file, the request is rejected. External users cannot view the file.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;The Global.asax file is parsed and dynamically compiled by ASP.NET. You can deploy this file as an assembly in the \bin directory of an ASP.NET application.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="color: rgb(79, 129, 189);font-family:Cambria;font-size:13;"  &gt;How to create Global.asax&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Adding a Global.asax to your web project is quiet simple. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Open Visual Studio 2005 or 2008 &gt; Create a new website &gt; Go to the Solution Explorer &gt; Add New Item &gt; Global Application Class &gt; Add.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="color: rgb(79, 129, 189);font-family:Cambria;font-size:13;"  &gt;Examining the methods related to the events in Global.asax&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;There are 2 ‘set’ of methods that fire corresponding to the events. The first set which &lt;u&gt;gets&lt;/u&gt; invoked on each request and the second set which &lt;u&gt;does not get&lt;/u&gt; invoked on each request. Let us explore these methods.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Methods corresponding to events that fire on each request&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_BeginRequest() – fired when a request for the web application comes in.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_AuthenticateRequest –fired just before the user credentials are authenticated. You can specify your own authentication logic over here.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_AuthorizeRequest() – fired on successful authentication of user’s credentials. You can use this method to give authorization rights to user. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_ResolveRequestCache() – fired on successful completion of an authorization request. &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_AcquireRequestState() – fired just before the session state is retrieved for the current request.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_PreRequestHandlerExecute() - fired before the page framework begins before executing an event handler to handle the request.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_PostRequestHandlerExecute() – fired after HTTP handler has executed the request.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_ReleaseRequestState() – fired before current state data kept in the session collection is serialized.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_UpdateRequestCache() – fired before information is added to output cache of the page.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_EndRequest() – fired at the end of each request&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Methods corresponding to events that do not fire on each request&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_Start() – fired when the first resource is requested from the &lt;span class="klink"&gt;&lt;u&gt;&lt;span style="color:blue;"&gt;web server&lt;/span&gt;&lt;/u&gt;&lt;/span&gt; and the web application starts.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Session_Start() – fired when session starts on each new user requesting a page.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_Error() – fired when an error occurs.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Session_End() – fired when the session of a user ends.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_End() – fired when the web application ends.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Application_Disposed() - fired when the web application is destroyed.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="color: rgb(79, 129, 189);font-family:Cambria;font-size:13;"  &gt;Show me an example!!&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Let us see an example of how to use the Global.asax to catch unhandled errors that occur at the application level.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;To catch unhandled errors, do the following. Add a Global.asax file (Right click project &gt; Add New Item &gt; Global.asax). In the Application_Error() method, add the following code:&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;C#&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Application_Error(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;    {&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;        &lt;span style="color:green;"&gt;// Code that runs when an unhandled error occurs&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;        &lt;span style="color: rgb(43, 145, 175);"&gt;Exception&lt;/span&gt; objErr = Server.GetLastError().GetBaseException();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;        &lt;span style="color:blue;"&gt;string&lt;/span&gt; err = &lt;span style="color: rgb(163, 21, 21);"&gt;"Error in: "&lt;/span&gt; + Request.Url.ToString() +&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;                          &lt;span style="color: rgb(163, 21, 21);"&gt;". Error Message:"&lt;/span&gt; + objErr.Message.ToString();&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;        &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;    }&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;VB.NET&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;color:blue;"   &gt;Sub&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt; Application_Error(&lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Object&lt;/span&gt;, &lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:blue;"&gt;As&lt;/span&gt; EventArgs)&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;        &lt;span style="color:green;"&gt;' Code that runs when an unhandled error occurs        &lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;        &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; objErr &lt;span style="color:blue;"&gt;As&lt;/span&gt; Exception = Server.GetLastError().GetBaseException()&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;        &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; err &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;String&lt;/span&gt; = &lt;span style="color: rgb(163, 21, 21);"&gt;"Error in: "&lt;/span&gt; &amp;amp; Request.Url.ToString() &amp;amp; &lt;span style="color: rgb(163, 21, 21);"&gt;". Error Message:"&lt;/span&gt; &amp;amp; objErr.Message.ToString()&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;        &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;font-size:10;"  &gt;    &lt;span style="color:blue;"&gt;End&lt;/span&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;"  &gt;Here we make use of the Application_Error() method to capture the error using the Server.GetLastError().&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="color: rgb(79, 129, 189);font-family:Cambria;font-size:13;"  &gt;Conclusion:&lt;/span&gt;&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;color:black;"   &gt;In this article, we learnt that Global.asax is a file used to declare application-level events and objects. &lt;a name="globalasasx"&gt;The file is responsible for handling higher-level application events such as Application_Start, Application_End, Session_Start, Session_End, and so on&lt;/a&gt;. I would encourage you to explore the methods corresponding to the events and analyze the best possible methods to use them in your application, if needed.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:Verdana;font-size:10;color:black;"   &gt;I hope you liked the article and I thank you for viewing it. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-1806044962693396429?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/1806044962693396429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=1806044962693396429' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/1806044962693396429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/1806044962693396429'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/exploring-globalasax-file-in-aspnet.html' title='Exploring the Global.asax file in ASP.NET'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-2500538117623981161</id><published>2008-04-23T04:43:00.000-07:00</published><updated>2008-04-23T04:44:06.217-07:00</updated><title type='text'>Delegate Function  in VB.NET</title><content type='html'>&lt;p class="MsoNormal"&gt;In your Visual Basic .NET journey, you have more than likely encountered a well used, but little understood phenomenon, called a delegate.&lt;span style=""&gt;  &lt;/span&gt;You use them everyday, but might not know it.&lt;span style=""&gt;  &lt;/span&gt;In this article we will take a look at what a delegate is and how it will help you to develop better software.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;A delegate can be defined as a type-safe function pointer.&lt;span style=""&gt;  &lt;/span&gt;It encapsulates the memory address of a function in your code.&lt;span style=""&gt;  &lt;/span&gt;Whenever you create or use an event in code, you are using a delegate.&lt;span style=""&gt;  &lt;/span&gt;When the event is thrown, the framework examines the delegate behind the event and then calls the function that the delegate points to.&lt;span style=""&gt;  &lt;/span&gt;As we will see later, delegates can be combined to form groups of functions that can be called together.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Let us first take a quick look at how to define and invoke a delegate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;First we declare our delegate in our form class:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Private Delegate Sub MyDelSub() &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Then we use the delegate by simply declaring a variable of the delegate and assigning the sub or function to run when called.&lt;span style=""&gt;  &lt;/span&gt;First the sub to be called:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Private Sub WriteToDebug() &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Debug.WriteLine("Delegate Wrote To DebugWindow") &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End Sub &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;You will notice also that it matches our declaration of MyDelSub; it is a sub routine with no parameters.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;And then our test code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 3&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Dim &lt;st1:state st="on"&gt;&lt;st1:place st="on"&gt;del&lt;/st1:place&gt;&lt;/st1:State&gt; As MyDelSub &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;st1:state st="on"&gt;&lt;st1:place st="on"&gt;del&lt;/st1:place&gt;&lt;/st1:State&gt; = New MyDelSub(AddressOf WriteToDebug) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;del.Invoke() &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;When we invoke the delegate, the WriteToDebug sub is run.&lt;span style=""&gt;  &lt;/span&gt;Visual Basic hides most of the implementation of delegates when you use events, which are based off invoking a delegate.&lt;span style=""&gt;  &lt;/span&gt;This is the equivalent of the above delegate invoke as well.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 4&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Private Event MyEvent()'declare it in the class &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;'to use it, add a handler and raise the event. &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;AddHandler MyEvent, AddressOf WriteToDebug &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;RaiseEvent MyEvent() &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;If delegates stopped at this point, they would be useless since events are less work and do the same thing.&lt;span style=""&gt;  &lt;/span&gt;Let us get into some of the more advanced features of delegates.&lt;span style=""&gt;  &lt;/span&gt;We will start with multicast delegates.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Multicast delegates allow you to chain together several functions or subs that are all called together when the delegate is invoked.&lt;span style=""&gt;  &lt;/span&gt;For the current iteration of the framework, you cannot designate the order that the functions are run, only that they are all run one after another.&lt;span style=""&gt;  &lt;/span&gt;Let us look at the code for the multicast delegate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;First we add a new sub for our second delegate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 5&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Private Sub WriteToDebug2() &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Debug.WriteLine("Delegate Wrote To DebugWindow 2") &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End Sub &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Our declaration of the MySubDelegate stays the same, and here is our new usage code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 6&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Dim &lt;st1:state st="on"&gt;&lt;st1:place st="on"&gt;del&lt;/st1:place&gt;&lt;/st1:State&gt; As MyDelSub &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Dim del2 As MyDelSub &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Dim delAll As [Delegate] &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;st1:state st="on"&gt;&lt;st1:place st="on"&gt;del&lt;/st1:place&gt;&lt;/st1:State&gt; = New MyDelSub(AddressOf WriteToDebug) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;del2 = New MyDelSub(AddressOf WriteToDebug2) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;delAll = MulticastDelegate.Combine(&lt;st1:state st="on"&gt;&lt;st1:place st="on"&gt;del&lt;/st1:place&gt;&lt;/st1:State&gt;, del2) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;delAll.DynamicInvoke(Nothing) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;As we examine this code we see three delegate variables, two for our normal delegates that call our subs and one from the combined other two delegates.&lt;span style=""&gt;  &lt;/span&gt;We set up our normal delegates as always, one points to WriteToDebug and the other to WriteTodebug2.&lt;span style=""&gt;  &lt;/span&gt;When we combine the two delegates into our third, we utilize the static function Combine of the MulticastDelegate class.&lt;span style=""&gt;  &lt;/span&gt;It has two overloads, one that combines two delegates like we used and one that takes an array of delegates.&lt;span style=""&gt;  &lt;/span&gt;Next we invoke all the delegates with the combined delegates' DynamicInvoke property, passing in Nothing for its parameter.&lt;span style=""&gt;  &lt;/span&gt;We could have also passed in an array of objects that would be used for parameters to the invoked subs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;If you check out the declaration of the last sample, you see another huge benefit of delegates.&lt;span style=""&gt;  &lt;/span&gt;Notice that both &lt;st1:state st="on"&gt;&lt;st1:place st="on"&gt;del&lt;/st1:place&gt;&lt;/st1:State&gt; and del2 point to different functions, but are of the same type, MyDelSub.&lt;span style=""&gt;  &lt;/span&gt;This opens up loads of programming potential.&lt;span style=""&gt;  &lt;/span&gt;It allows you to point a MyDelSub variable to ANY sub that has the same signature as itself.&lt;span style=""&gt;  &lt;/span&gt;In our case, it is a simple sub with no parameters.&lt;span style=""&gt;  &lt;/span&gt;This behavior allows you to program more generically.&lt;span style=""&gt;  &lt;/span&gt;Next we will examine this generic behavior in detail.&lt;span style=""&gt;  &lt;/span&gt;It works well on both sides of the equation, either invoking a delegate from inside your class or receiving a delegate from outside your class to work upon.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;You are already familiar with the concept of having a class invoke a delegate that originates from inside it.&lt;span style=""&gt;  &lt;/span&gt;Anytime you handle an event from a control you are catching a delegate that has been invoked from inside the control.&lt;span style=""&gt;  &lt;/span&gt;Just remember that when you register a function via handles or addhandler, you are telling a delegate somewhere to make sure it calls your function when it is invoked.&lt;span style=""&gt;  &lt;/span&gt;If you have multiple functions that have handles for the same event, you are just using a multicast delegate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Let us take a look at some customization with delegates.&lt;span style=""&gt;  &lt;/span&gt;You can create classes that allow users to input delegates for certain routines.&lt;span style=""&gt;  &lt;/span&gt;The classes take a list of delegates to call during specific times.&lt;span style=""&gt;  &lt;/span&gt;This can be used to add different behaviors to your class, such as different sorting routines.&lt;span style=""&gt;  &lt;/span&gt;This is a more modern and slightly different version of the Visitor design pattern as described in the GOF book.&lt;span style=""&gt;  &lt;/span&gt;More information about the Visitor design pattern can be found here.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Implementing the Visitor Design Pattern&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;To start our example, take a simple class that represents a dog.&lt;span style=""&gt;  &lt;/span&gt;It is very simple with only one method and one define for our delegate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 7&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Public Class Bulldog &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;Public Delegate Sub BarkMethod() &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;Public Sub DoBark(ByVal BarksToRun AsBarkMethod) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;BarksToRun.DynamicInvoke(Nothing) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;End Sub &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End Class &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The delegate sub BarkMethod is what we will use to create variables.&lt;span style=""&gt;  &lt;/span&gt;The sub DoBark takes an instance of the delegate to run.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Now for our test code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 8&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Dim bk1 As Bulldog.BarkMethod &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Dim bk2 As Bulldog.BarkMethod &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Dim MyDog As Bulldog &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;MyDog = New Bulldog &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;bk1 = New Bulldog.BarkMethod(AddressOf Bark1) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;bk2 = New Bulldog.BarkMethod(AddressOf Bark2) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;MyDog.DoBark(bk1) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;MyDog.DoBark(bk2) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;We create two delegate variables of the type Bulldog.BarkBethod.&lt;span style=""&gt;  &lt;/span&gt;We then assign each variable to a sub in our test code, which we see here:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 9&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Private Sub Bark1() &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Debug.WriteLine("Woof Woof") &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End Sub &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Private Sub Bark2() &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Debug.WriteLine("Yip Yip") &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End Sub &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The subs simply write to the debug window.&lt;span style=""&gt;  &lt;/span&gt;As we create and use our dog object, we decide we want to make the dog bark by using Bark1 and then by using Bark2.&lt;span style=""&gt;  &lt;/span&gt;We simply pass in the correct delegate to the dog object which calls our external subs to do the work.&lt;span style=""&gt;  &lt;/span&gt;As you can see, this pattern makes for very easy expansion.&lt;span style=""&gt;  &lt;/span&gt;If we decide to make the dog talk, then we just add a delegate variable that points to a sub that returns “Hello.”&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The next step up would be the need to take multiple delegates for the function, instead of the singular bk1 or bk2.&lt;span style=""&gt;  &lt;/span&gt;To facilitate this you can change the dog class to contain add and remove subs.&lt;span style=""&gt;  &lt;/span&gt;These control an internal delegate of what barks to run.&lt;span style=""&gt;  &lt;/span&gt;Here is our new dog class:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 10&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Public Class Bulldog&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Private _Barks As [Delegate]&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Public Delegate Sub BarkMethod()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Public Sub DoBark()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;If Not IsNothing(_Barks) Then 'check to see ifthere is anthing to Invoke&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;      &lt;/span&gt;_Barks.DynamicInvoke(Nothing)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;End If&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Public Sub AddBark(ByVal Bark As BarkMethod)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;_Barks = MulticastDelegate.Combine(_Barks, Bark)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Public Sub RemoveBark(ByVal Bark As BarkMethod)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;_Barks = MulticastDelegate.Remove(_Barks, Bark)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End Class&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;You can see that we have added a private property, _Barks, to keep track of our delegates to call.&lt;span style=""&gt;  &lt;/span&gt;Our AddBark and RemoveBark subs use static functions of the MulticastDelegate to add and remove the delegate.&lt;span style=""&gt;  &lt;/span&gt;These functions could also be easily overloaded to take an array of BarkMethods instead of single instances.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Here is our new test code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 11&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Dim bk1 As Bulldog.BarkMethod &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Dim bk2 As Bulldog.BarkMethod &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Dim MyDog As Bulldog &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;MyDog = New Bulldog &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;bk1 = New Bulldog.BarkMethod(AddressOf Bark1) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;bk2 = New Bulldog.BarkMethod(AddressOf Bark2) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;MyDog.AddBark(bk1) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;MyDog.AddBark(bk2) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;MyDog.DoBark() &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;MyDog.RemoveBark(bk2) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;MyDog.DoBark() &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Our Bark1 and Bark2 subs did not change so I did not show them.&lt;span style=""&gt;  &lt;/span&gt;In the test code, we create our normal two delegates and then, using our new methods, add them to our dog class.&lt;span style=""&gt;  &lt;/span&gt;After we make the dog bark, we remove the bk2 variable from the dog and make him bark again.&lt;span style=""&gt;  &lt;/span&gt;The output is as follows:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Woof Woof &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Yip Yip &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Woof Woof&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Delegates can also be used as CallBacks.&lt;span style=""&gt;  &lt;/span&gt;CallBacks are used in many Windows API calls.&lt;span style=""&gt;  &lt;/span&gt;You pass in a function pointer to the API call.&lt;span style=""&gt;  &lt;/span&gt;When the API call gets finished with its job, it then “calls back” to the function via the function pointer you passed it.&lt;span style=""&gt;  &lt;/span&gt;This allows your code to know when the API call is done.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The framework provides an easy way to use a delegate with an API that needs a callback.&lt;span style=""&gt;  &lt;/span&gt;You can define and pass a delegate as a native-function pointer several ways.&lt;span style=""&gt;  &lt;/span&gt;Here are two.&lt;span style=""&gt;  &lt;/span&gt;First we declare our delegate and the API call we want to make.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 12&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Public Delegate Function MyDelegateCallBack( _&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;ByVal hwnd As Integer, ByVal lParam As Integer) As Boolean &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Declare Function EnumWindows Lib "user32"(ByVal x As MyDelegateCallBack, ByVal y As Integer) As Integer &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;We then define the function that we want to be called by the EnumWindows API call as it finds windows.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 13&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Public Function EnumOutput(ByVal hwnd As Integer,ByVal lParam As Integer) As Boolean &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Console.WriteLine(hwnd) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Return True &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End Function &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;And lastly, our test code that makes the call to EnumWindow.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 14&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Dim del As MyDelegateCallBack &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;del = New MyDelegateCallBack(AddressOf EnumOutput) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;EnumWindows(del, 0) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;We declare our delegate variable and then pass it to EnumWindows, which calls it every time it finds a new window.&lt;span style=""&gt;  &lt;/span&gt;The test code could also be written like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 15&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;EnumWindows(AddressOf EnumOutput, 0) &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The shorter form creates a delegate for you and passes it to EnumWindows.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;To pass multiple delegates to CallBacks is just as easy.&lt;span style=""&gt;  &lt;/span&gt;You cannot use the short form of the CallBack delegate as shown above, since you need to combine delegates.&lt;span style=""&gt;  &lt;/span&gt;In this example the definition of EnumWindows changes along with our test code.&lt;span style=""&gt;  &lt;/span&gt;Here is the whole example.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 16&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Public Delegate Function MyDelegateCallBack( _&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;ByValhwnd As Integer, ByVal lParam As Integer) As Boolean&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Declare FunctionEnumWindows Lib "user32" (ByVal x As [Delegate], ByVal y As Integer)As Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Private Sub btnButton1_Click( _&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;ByVal sender As System.Object, ByVal e As System.EventArgs) _&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;Handles btnButton1.Click&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Dim del As MyDelegateCallBack&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Dim del2 As MyDelegateCallBack&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;del = New MyDelegateCallBack(AddressOf EnumOutput)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;del2 = New MyDelegateCallBack(AddressOfEnumOutput2)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Dim delAll As [Delegate]&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;delall = MulticastDelegate.Combine(del, del2)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;EnumWindows(delAll, 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Public Function EnumOutput(ByVal hwnd As Integer,ByVal lParam As Integer) As Boolean&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Console.WriteLine(hwnd)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Return True&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Public Function EnumOutput2(ByVal hwnd As Integer,ByVal lParam As Integer) As Boolean&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Console.WriteLine("Found HWND")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Return True&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;You will notice that we use a generic delegate for the first parameter of EnumWindows.&lt;span style=""&gt;  &lt;/span&gt;This is necessary because we want to pass a multicast delegate to it.&lt;span style=""&gt;  &lt;/span&gt;We add a new function called EnumOutput2 with the same signature as EnumOutput and create another delegate that points to it.&lt;span style=""&gt;  &lt;/span&gt;After creating our multicast delegate, delAll, we use it to pass to EnumWindows.&lt;span style=""&gt;  &lt;/span&gt;The output shows that both functions get called for each window found.&lt;span style=""&gt;  &lt;/span&gt;Be careful when doing this.&lt;span style=""&gt;  &lt;/span&gt;Since EnumWindows takes a generic delegate, you are responsible for passing in functions with the correct signature that it expects.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Now that we know how a CallBack works, we will take a look at how to implement one of our own and call it asynchronously.&lt;span style=""&gt;  &lt;/span&gt;Like always, we start by defining a delegate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 17&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Public Delegate Sub MyAsyncDelegate() &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Next we will show our test code and delegate functions together and analyze them&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Listing 18&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Private Sub MyWorker()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;System.Threading.Thread.Sleep(2000)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Debug.WriteLine("MyWorker Done!")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Private Sub ImDone(ByVal ar As System.IAsyncResult)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Debug.WriteLine("AsyncDelegate is done")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Private Sub btnButton1_Click( _&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;ByVal sender As System.Object, ByVal e As System.EventArgs) _&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;Handles btnButton1.Click&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Dim del As MyAsyncDelegate&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;del = New MyAsyncDelegate(AddressOf MyWorker)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Dim cb As AsyncCallback = NewAsyncCallback(AddressOf ImDone)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Dim oState As Object&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Dim ar As IAsyncResult = del.BeginInvoke(cb,oState)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;Debug.WriteLine("After DelegateBeginInvoke")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;End Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;If you look at our two delegate functions, you will see that the MyWorker function is the target of our normal MyAsyncDelegate.&lt;span style=""&gt;  &lt;/span&gt;The other function, ImDone, takes a parameter of a System.IAsyncResult.&lt;span style=""&gt;  &lt;/span&gt;This is the signature you need for the class AsyncCallback.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;An AsyncCallback delegate allows you to call a function asynchronously.&lt;span style=""&gt;  &lt;/span&gt;It takes a parameter of the results.&lt;span style=""&gt;  &lt;/span&gt;In our test code you will see that we have created a variable named "cb" for our AsyncCallback.&lt;span style=""&gt;  &lt;/span&gt;This is the delegate that will get called when our function is done.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Next we declare a variable, ar, of the IAsyncResult type and set it equal to our normal delegate’s BeginInvoke method.&lt;span style=""&gt;  &lt;/span&gt;This method takes a Callback delegate and an object that represents its state.&lt;span style=""&gt;  &lt;/span&gt;This call returns immediately.&lt;span style=""&gt;  &lt;/span&gt;The framework does all the work of making the call to MyWorker on another thread for you.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;When MyWorker finishes, we get our asynchronous sub’s output of AsyncDelegate Done.&lt;span style=""&gt;  &lt;/span&gt;If you examine the whole output, you will see that the asynchronous call return immediately, the MyWorker sub finishes and finally the ImDone sub is called.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;After Delegate BeginInvoke &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;MyWorker Done! &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;AsyncDelegate is done &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;In our example, we have done all the work locally behind a form, but one could easily define a method that took a delegate for a callback.&lt;span style=""&gt;  &lt;/span&gt;Instead of defining your delegate variable locally, you would use the passed-in one as the target of the AsyncCallback object.&lt;span style=""&gt;  &lt;/span&gt;After setting up, you would call your internal delegate to do the work and return processing to the calling sub.&lt;span style=""&gt;  &lt;/span&gt;As your delegate worked, it calls the AsyncCallback whenever you decide to notify the client.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Hopefully this article will help you understand delegates and how Visual Basic .NET uses them.&lt;span style=""&gt;  &lt;/span&gt;When applied correctly, they can make your programming very generic and able to handle many different situations.&lt;span style=""&gt;  &lt;/span&gt;Good luck and happy coding!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-2500538117623981161?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/2500538117623981161/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=2500538117623981161' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/2500538117623981161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/2500538117623981161'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/delegate-function-in-vbnet.html' title='Delegate Function  in VB.NET'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-6561113034830315661</id><published>2008-04-23T04:38:00.000-07:00</published><updated>2008-04-23T04:41:42.711-07:00</updated><title type='text'>Stored Procedures Quickstart</title><content type='html'>&lt;p class="MsoNormal"&gt;Stored Procedures Quickstart&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;span style=""&gt;    &lt;/span&gt;Eventually, most ASP programmers will find they need to write stored procedures because they find they are writing the same or similar SQL queries over and over in their web project or will require the performance that only a stored procedure will bring.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;   &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=""&gt;    &lt;/span&gt;Other reasons for using Sprocs is they simplify security settings and aid in the development to an N-Tier architecture, helping to separate out data-access code.&lt;o:p&gt;&lt;/o:p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;   &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=""&gt;   &lt;/span&gt;Some people are put off Sprocs because they perceive them to be difficult; this couldn't be further from the truth, as I will show in this article.&lt;o:p&gt;&lt;/o:p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;What are Stored Procedures?&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt;    &lt;/span&gt;If you think of Sprocs as being sql scripts you won't be far wrong. They are bundles of SQL commands stored in the database but with the added advantage that once it has been run it is compiled and cached, future calls to the Sproc will be much faster.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=""&gt;   &lt;/span&gt;First Stored Procedure&lt;o:p&gt;&lt;/o:p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;CREATE PROCEDURE listArticles&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;span style=""&gt;    &lt;/span&gt;AS&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;span style=""&gt;    &lt;/span&gt;SELECT *&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;span style=""&gt;    &lt;/span&gt;FROM tblArticles&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;    &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;span style=""&gt;    &lt;/span&gt;ORDER BY dtmDateStamp DESC&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;      &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;span style=""&gt;    &lt;/span&gt;This stored procedure is a simple vanilla sql query, but demonstrates how to create a procedure. To test the procedure (assuming you have a tblArticles table!) you would simply enter the name of the procedure (“listArticles”) in SQL Query Analyser.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;&lt;br /&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;In ASP we can initially cut out the SQL query we have been using and put the procedure name in its place, eg.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=""&gt;&lt;br /&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;'Create an ADODB Connection&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;set myConnection = server.createObject("ADODB.Connection")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;myConnection.open "myDSN"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;'Create a recordset&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;set myRecordSet = server.createObject("ADODB.Recordset")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;     &lt;/span&gt;'Fill recordset with records from database&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;           &lt;/span&gt;myRecordSet.open "listArticles", myConnection, 2 ,3&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;'Read records&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;do while not myRecordSet.EOF&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;             &lt;/span&gt;response.write(myRecordSet("strTitle"))&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;      &lt;/span&gt;myRecordSet.movenext&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;     &lt;/span&gt;loop&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;     &lt;/span&gt;'Close connections&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;myRecordSet.Close&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;myConnection.Close&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;This is fine, and it works, but when you are comfortable with the SQL side you might want to look at the Execute command. I find the above code easier to understand for people new to the subject.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-6561113034830315661?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/6561113034830315661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=6561113034830315661' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/6561113034830315661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/6561113034830315661'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/stored-procedures-quickstart.html' title='Stored Procedures Quickstart'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-2360961217687069</id><published>2008-04-23T04:36:00.001-07:00</published><updated>2008-04-23T04:36:35.637-07:00</updated><title type='text'>Retrieving Images from SqlServer in ASP .NET</title><content type='html'>Introduction&lt;br /&gt;&lt;br /&gt;This article is a continuation of my previous article, which talks about Inserting an image to Sql Server. I would recommend to read the above article before continuing this.&lt;br /&gt;&lt;br /&gt;Compared to inserting an image, retreiving is very simple. The only new thing that we need to write an image is, we need to use the method BinaryWrite of the Response Object. Also we need to set the appropriate content type. In this article, we will discuss about retrieving images from a Sql Server.&lt;br /&gt;We will be learning the following aspects in this article.&lt;br /&gt;&lt;br /&gt;   1. How to set the Content Type?&lt;br /&gt;   2. How to use the method, BinaryWrite&lt;br /&gt;&lt;br /&gt;Since we already have data in the table, Person, we will add some statements which retrieves all the rows from the table, person. The following code retrieves all rows from the table, Person.&lt;br /&gt;&lt;br /&gt;Code to retrieve image from sql server.&lt;br /&gt;    Public Sub Page_Load(sender As Object, e As EventArgs)&lt;br /&gt;&lt;br /&gt;        Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))&lt;br /&gt;        Dim myCommand As New SqlCommand("Select * from Person", myConnection)&lt;br /&gt;&lt;br /&gt;        Try&lt;br /&gt;            myConnection.Open()&lt;br /&gt;            Dim myDataReader as SqlDataReader&lt;br /&gt;            myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)&lt;br /&gt;&lt;br /&gt;            Do While (myDataReader.Read())&lt;br /&gt;                Response.ContentType = myDataReader.Item("PersonImageType")&lt;br /&gt;                Response.BinaryWrite(myDataReader.Item("PersonImage"))&lt;br /&gt;            Loop&lt;br /&gt;&lt;br /&gt;            myConnection.Close()&lt;br /&gt;            Response.Write("Person info successfully retrieved!")&lt;br /&gt;        Catch SQLexc As SqlException&lt;br /&gt;            Response.Write("Read Failed : " &amp; SQLexc.ToString())&lt;br /&gt;        End Try&lt;br /&gt;&lt;br /&gt;    End Sub&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-2360961217687069?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/2360961217687069/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=2360961217687069' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/2360961217687069'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/2360961217687069'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/retrieving-images-from-sqlserver-in-asp.html' title='Retrieving Images from SqlServer in ASP .NET'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-5986120671208297558</id><published>2008-04-23T04:33:00.001-07:00</published><updated>2008-04-23T04:33:47.571-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Working with DataSet Objects and XML'/><title type='text'></title><content type='html'>What is a DataSet?&lt;br /&gt;The DataSet is the core component of the disconnected architecture of ADO.NET that is used to cache the data read from the data source in memory.  The data stored in the memory can be modified and written back to the data source.  Hence, DataSet is known as an in-memory representation of data.  DataSets can be used with multiple and different data sources (Database, XML file, etc.).  The DataSet contains one or more DataTable objects.  DataTable object contains DataRows and DataColumns, as well as a primary key, foreign key, and constraint and relation information about the data in the DataTable objects.  The DataTable object represents every table within a DataSet; DataColumn object represents every column within a DataTable.  The DataRow object represents every row within a DataTable.  The DataSet does not validate the XML data against the schema; it simply uses it to infer the structure required for the tables in the DataSet.  The System.Data.DataSet class is provided to support DataSet in .NET.&lt;br /&gt;The XML-Based Methods of the DataSet class&lt;br /&gt;The DataSet class has wonderful support for XML, which will be discussed in detail in this article.  The DataSet class has several methods for reading and writing data as XML, including the following.&lt;br /&gt;•         GetXml Method&lt;br /&gt;•         GetXmlSchema Method&lt;br /&gt;•         InferXmlSchema Method&lt;br /&gt;•         WriteXml Method&lt;br /&gt;•         WriteXmlSchema Method&lt;br /&gt;•         ReadXml Method &lt;br /&gt;•         ReadXmlSchema Method&lt;br /&gt;These methods have been explained in the sections that follow.&lt;br /&gt;The GetXml Method&lt;br /&gt;This method returns a string containing an XML representation of the data stored in the DataSet. No schema is included. The syntax of this method is as follows:&lt;br /&gt;public string GetXml();&lt;br /&gt;The GetXmlSchema Method&lt;br /&gt;This method returns just the schema for an XML representation of the data stored in the DataSet. The GetXmlSchema method returns XML as a string, therefore requiring more overhead than using WriteXmlSchema method to write XML to a file.  The syntax of this method is the following.&lt;br /&gt;public string GetXmlSchema();&lt;br /&gt;InferXmlSchema Method&lt;br /&gt;This method applies XML schema to the DataSet after taking an XML document provided in a TextReader, XmlReader, Stream object or a specified disk file.  The syntax of overloaded versions of this method is as follows.&lt;br /&gt;public void InferXmlSchema(string,string[]);&lt;br /&gt;public void InferXmlSchema(TextReader,string[]);&lt;br /&gt;public void InferXmlSchema(Stream,Stream[]);&lt;br /&gt;public void InferXmlSchema(XmlReader,string[]);&lt;br /&gt;WriteXml Method &lt;br /&gt;This method writes the XML representation of the data in the DataSet object to a TextWriter object, an XmlWriter object, a Stream object or directly to a specified disk file.  The syntax of overloaded versions of this method is below.&lt;br /&gt;public void WriteXml(string);&lt;br /&gt;public void WriteXml(TextWriter);&lt;br /&gt;public void WriteXml(Stream);&lt;br /&gt;public void WriteXml(XmlWriter);&lt;br /&gt;This XML representation can either include or omit the corresponding XML schema. &lt;br /&gt;WriteXmlSchema Method &lt;br /&gt;This method writes the XML schema of the DataSet to a TextWriter object, an XmlWriter object, a Stream object or directly to a specified disk file.  The syntax of overloaded versions of this method is the following.&lt;br /&gt;public void WriteXmlSchema(string);&lt;br /&gt;public void WriteXmlSchema(TextWriter);&lt;br /&gt;public void WriteXmlSchema(Stream);&lt;br /&gt;public void WriteXmlSchema(XmlWriter);&lt;br /&gt;ReadXml Method &lt;br /&gt;This method reads the XML data (including a schema when present) into the DataSet from a TextReader, XmlReader, Stream object or directly to a specified disk file.  The syntax of overloaded versions of this method is below.&lt;br /&gt;public void ReadXml(string);&lt;br /&gt;public void ReadXml(TextReader);&lt;br /&gt;public void ReadXml(Stream);&lt;br /&gt;public void ReadXml(XmlReader);&lt;br /&gt;ReadXmlSchema Method &lt;br /&gt;This method reads the XML schema describing the contents of the DataSet to a TextReader, XmlReader, and Stream object or directly to a specified disk file. The syntax of overloaded versions of this method is the following.&lt;br /&gt;public void ReadXmlSchema(string);&lt;br /&gt;public void ReadXmlSchema(TextReader);&lt;br /&gt;public void ReadXmlSchema(Stream);&lt;br /&gt;public void ReadXmlSchema(XmlReader);&lt;br /&gt;The XmlWriteMode Enumeration&lt;br /&gt;The WriteXml method can be used with a second parameter that specifies XML output of data in more detail.  However, the second parameter is optional.  This method accepts a value from the XmlWriteMode enumeration.  The options/value of enumeration of XmlWriteMode parameter is as follows:&lt;br /&gt;•         WriteSchema&lt;br /&gt;•         IgnoreSchema&lt;br /&gt;•         DiffGram&lt;br /&gt;The following section discusses the above in details.&lt;br /&gt;Write Schema: In this mode it writes the XML data stored in the Dataset along with the loadedschema in DataSet.&lt;br /&gt;Ignore Schema: In this mode only XML data stored in the DataSet will be written.  No schema will be written or even loaded in DataSet.  This is the default mode.&lt;br /&gt;DiffGram: In this mode the data is written out in a form that includes all the original values and any current values for columns in each row that have been modified since the DataSet was loaded.  So the changes made in the DataSet are persisted in the XML file.  Sometimes we need to transfer (XML in DiffGram format) only the changed data in a DataSet to a XML file, then we use GetChange method of DataSet.&lt;br /&gt;DataSet ChangedsProducts = new DataSet();&lt;br /&gt;ChangedsProducts = dsProducts.GetChange();&lt;br /&gt;ChangedsProducts.WriteXml(sPath,XmlWriteMode.DiffGram);&lt;br /&gt;The XmlReadMode Enumeration&lt;br /&gt;The ReadXml method creates the relational schema of the DataSet depending on the option/value of enumeration of XmlReadMode argument specified.  The XmlReadMode enumeration specifies how to read XML data and schema into a DataSet.  This second parameter of ReadXml method is also optional.  The options/value of enumeration of XmlReadMode parameter are as follows.&lt;br /&gt;•         Auto&lt;br /&gt;•         Diffgram&lt;br /&gt;•         Fragment&lt;br /&gt;•         IgnoreSchema&lt;br /&gt;•         InferSchema&lt;br /&gt;•         ReadSchema&lt;br /&gt;The following section discusses the above in details.&lt;br /&gt;Auto: This is the Default mode.  In this mode it reads and examines the XML and chooses the most appropriate option in the following order.&lt;br /&gt;If the XML data is a DiffGram, then the value of enumeration of XmlReadMode argument is set to DiffGram.  If the dataset contains a schema or the XML contains an in-line schema, then the value of enumeration of XmlReadMode argument is set to ReadSchema.  If the DataSet does not contain a schema and the XML does not contain an in-line schema, then the value of enumeration of XmlReadMode argument is set to InferSchema.  It is recommended to set an explicit value for enumeration of XmlReadMode argument, rather than accept the Auto default.  This gives the best performance if we know the format of the XML being read.&lt;br /&gt;DiffGram: In this mode the ReadXml method reads a DiffGram and adds the data to the current schema.  DiffGram merges new rows with existing rows where the unique identifier values match.&lt;br /&gt;Fragment: In this mode the ReadXml method reads the XML documents containing inline XDR schema fragments.  Fragments that match the DataSet schema are appended to the appropriate tables.  Fragments that do not match the DataSet schema are discarded.&lt;br /&gt;Ignore Schema: In this mode the ReadXml method ignores any inline schema and loads data into the existing DataSet schema.  If the data does not match the existing schema, it is discarded.  If no schema exists in the DataSet, no data will be loaded.&lt;br /&gt;Infer Schema: In this mode the ReadXml method ignores any inline schema, infers schema from the data, and loads the data.  If the DataSet already contains a schema, the current schema is extended by adding columns to existing tables, where they exist, or by adding new tables where there is no existing table.  An exception will be thrown if an inferred table already exists with a different namespace or if any inferred columns conflict with existing columns.&lt;br /&gt;Read Schema: In this mode the ReadXml method reads any inline schema and loads the data and schema.  If the DataSet already contains a schema, new tables are added from the inline schema to the existing schema present in the DataSet.  However, an exception is thrown if any tables in the inline schema already exist in the DataSet.  We will not be able to modify the schema of an existing table using XmlReadMode.ReadSchema.  If the DataSet does not contain a schema and there is no inline schema, no data will be read.&lt;br /&gt;Implementing DataSet with Xml&lt;br /&gt;This section shows how we can use the DataSet with an Xml file.  Please follow the stated configuration settings that are required in the web.config file and add the namespaces that have been mentioned.&lt;br /&gt;Add the following in the web.config file.&lt;br /&gt;&lt;appSettings&gt;   &lt;br /&gt; &lt;add key  = "CString" value ="Server=self-r8yilmkzvk; Database = Sanjit; User   &lt;br /&gt; ID=sa;Password = sa;"&gt;&lt;/add&gt;&lt;br /&gt; &lt;add key = "ProductFile" value ="/Test/products.xml"&gt; &lt;/add&gt;&lt;br /&gt;&lt;/appSettings&gt;&lt;br /&gt;Remember to change the above settings (Server, Database, User ID, Password, etc.) in the web.config file as per the settings of the system on which the code is to be executed.&lt;br /&gt;Database structure&lt;br /&gt;In this section I have populated the DataSet from a Sql Server DataBase table.  The following is the table structure.&lt;br /&gt;Table Name:  products&lt;br /&gt;Column Name               DataType               Properties&lt;br /&gt;Prod_ID                       Int(4)                     Primary Key&lt;br /&gt;Prod_Name                  Varchar(50)&lt;br /&gt;Prod_Price                    Money(8)&lt;br /&gt;Prod_Available              Char (3)&lt;br /&gt;Prod_Display                 Bit(1)&lt;br /&gt;Writing Data from a DataSet to an XML File&lt;br /&gt;This example demonstrates how to write data from a DataSet directly to a disk file as an XML document.&lt;br /&gt;Listing 1&lt;br /&gt;SqlConnection conn = &lt;br /&gt;new SqlConnection(ConfigurationSettings.AppSettings["CString"].ToString ()); &lt;br /&gt;SqlDataAdapter DA = &lt;br /&gt;new SqlDataAdapter(&lt;br /&gt;"select Prod_ID, Prod_Name,Prod_Price,Prod_Available,Prod_Display from products ",&lt;br /&gt; conn);&lt;br /&gt;conn.Open();&lt;br /&gt;DataSet DS = new DataSet();&lt;br /&gt;DA.Fill(DS);&lt;br /&gt;DS.WriteXmlSchema(Server.MapPath("products.xml"));&lt;br /&gt;DS.WriteXml(Server.MapPath("products.xml"));&lt;br /&gt;Add data to XML File&lt;br /&gt;This example demonstrates how to add data to an XML file.&lt;br /&gt;Listing 2&lt;br /&gt;dsProducts = PopulateDataSet();&lt;br /&gt;DataRow newProductRow =dsProducts.Tables[0].NewRow();&lt;br /&gt;newProductRow[0] = txtPID.Text;&lt;br /&gt;newProductRow[1] = txtPName.Text;&lt;br /&gt;newProductRow[2] = txtPPrice.Text;&lt;br /&gt;newProductRow[3] = "Yes";&lt;br /&gt;newProductRow[4] = "true";&lt;br /&gt;dsProducts.Tables[0].Rows.Add(newProductRow);&lt;br /&gt;sPath = ConfigurationSettings.AppSettings["ProductFile"];&lt;br /&gt;sPath = Server.MapPath(sPath);&lt;br /&gt;dsProducts.WriteXml(sPath,XmlWriteMode.WriteSchema);&lt;br /&gt;Search from an XML File using DataView&lt;br /&gt;This example demonstrates how to search a result using Sort and RowFilter properties of the DataView object.&lt;br /&gt;Listing 3&lt;br /&gt;dsProducts = PopulateDataSet();&lt;br /&gt;if(dsProducts.Tables["Products"].Rows.Count &gt; 0)&lt;br /&gt;{&lt;br /&gt;  dv = dsProducts.Tables[0].DefaultView;&lt;br /&gt;  dv.Sort = "Prod_Name";&lt;br /&gt;  dv.RowFilter = " Prod_Price &gt;" +txtSearch.Text.Trim();&lt;br /&gt;  if (dv.Count &gt; 0)&lt;br /&gt;  {&lt;br /&gt; &lt;br /&gt;    DataList1.DataSource = dv;&lt;br /&gt;    DataList1.DataBind();&lt;br /&gt; &lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;In the above code I have used DataList control to display the searched result.  We have to write some code in the .aspx file to show the searched result in DataList control, which is as follows:&lt;br /&gt;Here I have displayed the Product Name and Product Price in DataList control.&lt;br /&gt;Listing 4&lt;br /&gt;&lt;asp:DataList id="DataList1"&lt;br /&gt; style="Z-INDEX: 104; LEFT: 128px; POSITION: absolute; TOP: 8px"&lt;br /&gt;runat="server"&lt;br /&gt;RepeatColumns="2"&lt;br /&gt;BorderStyle="None" BorderColor="#DEBA84"&lt;br /&gt;BackColor="#DEBA84" CellSpacing="2"&lt;br /&gt;CellPadding="3" GridLines="Both"&lt;br /&gt;BorderWidth="1px"&gt;&lt;br /&gt;&lt;SelectedItemStyle Font-Bold="True" ForeColor="White"&lt;br /&gt;BackColor="#738A9C"&gt;&lt;/SelectedItemStyle&gt;&lt;br /&gt;&lt;ItemStyle ForeColor="#8C4510"&lt;br /&gt;BackColor="#FFF7E7"&gt;&lt;/ItemStyle&gt;&lt;br /&gt;&lt;ItemTemplate&gt;&lt;br /&gt;&lt;table&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;&lt;br /&gt;Product Name:&lt;%#DataBinder.Eval(Container.DataItem, "Prod_Name")%&gt;&lt;br /&gt;&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;&lt;br /&gt;ProductPrice:&lt;%#DataBinder.Eval(Container.DataItem, "Prod_Price")%&gt;&lt;br /&gt;&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;/ItemTemplate&gt;&lt;br /&gt;&lt;FooterStyle ForeColor="#8C4510"BackColor="#F7DFB5"&gt;&lt;/FooterStyle&gt;&lt;br /&gt;&lt;HeaderStyle Font-Bold="True"ForeColor="White" BackColor="#A55129"&gt;&lt;/HeaderStyle&gt;&lt;br /&gt;&lt;/asp:DataList&gt;&lt;br /&gt;We can also use DataGrid control or Repeter control to display the searched result.&lt;br /&gt;Refer to the code listing above.  The PopulateDataSet method populates a DataSet object from an XML File and returns the same.&lt;br /&gt;Listing 5&lt;br /&gt;private DataSet PopulateDataSet()&lt;br /&gt;{&lt;br /&gt;  dsProducts =(DataSet)(Cache[ProductCacheName]);&lt;br /&gt;  if (dsProducts == null)&lt;br /&gt;  {&lt;br /&gt;    sPath = ConfigurationSettings.AppSettings["ProductFile"];&lt;br /&gt;    sPath = Server.MapPath(sPath);&lt;br /&gt;    if (File.Exists(sPath))&lt;br /&gt;    {&lt;br /&gt;      dsProducts = new DataSet();&lt;br /&gt;      dsProducts.ReadXml(sPath,XmlReadMode.ReadSchema);&lt;br /&gt;      Cache.Insert(ProductCacheName, dsProducts,new CacheDependency(sPath));&lt;br /&gt; &lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;  return dsProducts;&lt;br /&gt;}&lt;br /&gt;Note: Although I have populated cache object with DataSet and made its expiration dependent upon changes to the XML file, a detail discussion of caching is beyond the scope of this article.&lt;br /&gt;We can also use the Select method of DataTable class to search the data as shown in the previous listing.&lt;br /&gt;Listing 6&lt;br /&gt;DataSet dsProducts = PopulateDataSet();&lt;br /&gt;DataSet.Tables["Products"].Select("Prod_Price&gt;150","Prod_IDDESC");&lt;br /&gt;Use of the GetXML Method&lt;br /&gt;The following example will demonstrate the use of GetXML method of DataSet.  To read the complete XML file as a stream, we can use the GetXml method of the DataSet class.  The following code read the Products.xml file into a DataSet and then uses the GetXml method of the DataSet class to display the data in a TextBox.&lt;br /&gt;Listing 7&lt;br /&gt;sPath = ConfigurationSettings.AppSettings["ProductFile"];&lt;br /&gt;sPath = Server.MapPath(sPath);&lt;br /&gt;dsProducts.ReadXml(sPath);&lt;br /&gt;txtXml.Text=ds.GetXml();&lt;br /&gt;Delete Data from XML File &lt;br /&gt;The Delete method demonstrates how to delete data from an XML file.  It takes the PID as the primary key (Prod_ID) to delete a particular product data from the XML file.&lt;br /&gt;Listing 8&lt;br /&gt;private void Delete(int PID)&lt;br /&gt;{&lt;br /&gt;  dsProducts = PopulateDataSet();&lt;br /&gt;  DataTable dt = new DataTable();&lt;br /&gt;  dt = dsProducts.Tables[0];&lt;br /&gt;  DataView dvProducts = new DataView();&lt;br /&gt;  dvProducts = dt.DefaultView;&lt;br /&gt;  dvProducts.Sort = "P_ID";&lt;br /&gt;  int rowIndex =dvProducts.Find("PID");&lt;br /&gt;  if (rowIndex ==  - 1)&lt;br /&gt;  {&lt;br /&gt;    Response.Write("Product notfound");&lt;br /&gt;  }&lt;br /&gt;  else&lt;br /&gt;  {&lt;br /&gt;    dvProducts.RowFilter = "P_ID=" +PID;&lt;br /&gt;    dvProducts.Delete(0);&lt;br /&gt;    dsProducts.WriteXml(sPath,XmlWriteMode.WriteSchema);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;Edit Data in XML File &lt;br /&gt;The Update method demonstrates how to update data in an XML file.  It takes the PID as Prod_ID to edit a particular product data.  Here I have edited the price of a particular product after taking the new price from the textbox control named txtPPrice.  We can also update other data of a particular product in a similar way.&lt;br /&gt;Listing 9&lt;br /&gt;private void Update(int PID)&lt;br /&gt;{&lt;br /&gt;  dsProducts = PopulateDataSet();&lt;br /&gt;  DataTable dt = new DataTable();&lt;br /&gt;  dt = dsProducts.Tables[0];&lt;br /&gt;  DataView dvProducts = new DataView();&lt;br /&gt;  dvProducts = dt.DefaultView;&lt;br /&gt;  dvProducts.Sort = "P_ID";&lt;br /&gt;  int rowIndex = dvProducts.Find(PID);&lt;br /&gt;  if (rowIndex ==  - 1)&lt;br /&gt;  {&lt;br /&gt;    Response.Write("Product notfound");&lt;br /&gt;  }&lt;br /&gt;  else&lt;br /&gt;  {&lt;br /&gt;    dvProducts.RowFilter = "P_ID=" +PID;&lt;br /&gt;    dvProducts[0]["P_Price"] =txtPPrice.Text;&lt;br /&gt;    dsProducts.WriteXml(sPath,XmlWriteMode.WriteSchema);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;This section shows how we can execute the code snippets that have been discussed so far.  For this, we require the creation of objects of the DataSet and the DataView classes.  To use the DataSet class, add the following namespaces along with the default namespaces in your application’s code.&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Web.Caching;&lt;br /&gt;Add the following code to run the code mentioned in this article.&lt;br /&gt;DataSet dsProducts = new DataSet();&lt;br /&gt;string sPath;&lt;br /&gt;string ProductCacheName = "";&lt;br /&gt;DataView dv=new DataView();&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-5986120671208297558?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/5986120671208297558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=5986120671208297558' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/5986120671208297558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/5986120671208297558'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/what-is-dataset-dataset-is-core.html' title=''/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-1936123260781116565</id><published>2008-04-23T04:25:00.000-07:00</published><updated>2008-04-23T04:29:09.121-07:00</updated><title type='text'>object-oriented and event-driven programming model</title><content type='html'>  &lt;h2&gt;&lt;span style=";font-family:&amp;quot;;font-size:12;"  &gt;Introduction&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Microsoft’s ASP.NET technology brings an object-oriented and event-driven programming model and unites it with the benefits of compiled code. However, its server-side processing model has several drawbacks inherent in the technology:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Page updates require a round-trip to the server,      which requires a page refresh.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Round-trips do not persist any effects generated by      Javascript or other client-side technology (such as Adobe Flash)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;During postback, browsers other than Microsoft      Internet Explorer do not support automatically restoring the scroll      position. And even in Internet Explorer, there is still a flicker as the      page is refreshed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Postbacks may involve a high amount of bandwidth as      the __VIEWSTATE form field may grow, especially when dealing with controls      such as the GridView control or repeaters.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;There is no unified model for accessing Web Services      through JavaScript or other client-side technology.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Enter Microsoft’s ASP.NET AJAX extensions. &lt;st1:place st="on"&gt;&lt;st1:city st="on"&gt;AJAX&lt;/st1:city&gt;&lt;/st1:place&gt;, which stands for &lt;b&gt;A&lt;/b&gt;synchronous &lt;b&gt;J&lt;/b&gt;avaScript &lt;b&gt;A&lt;/b&gt;nd &lt;b&gt;X&lt;/b&gt;ML, is an integrated framework for providing incremental page updates via cross-platform JavaScript, composed of server-side code comprising the Microsoft AJAX Framework, and a script component called the Microsoft AJAX Script Library. The ASP.NET AJAX extensions also provide cross-platform support for accessing ASP.NET Web Services via JavaScript.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;This whitepaper examines the partial page updates functionality of the ASP.NET AJAX Extensions, which includes the ScriptManager component, the UpdatePanel control, and the UpdateProgress control, and considers scenarios in which they should or should not be utilized.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;This whitepaper is based on the Beta 2 release of the Visual Studio 2008 and the .NET Framework 3.5, which integrates the ASP.NET AJAX Extensions into the Base Class Library (where it was previously an add-on component available for ASP.NET 2.0). This whitepaper also assumes that you are using Visual Studio 2008 and not Visual Web Developer Express Edition; some project templates that are referenced may not be available to Visual Web Developer Express users.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2&gt;&lt;span style=";font-family:&amp;quot;;font-size:12;"  &gt;Partial Page Updates&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Perhaps the most visible feature of the ASP.NET AJAX Extensions is the ability to do a partial or incremental page updates without doing a full postback to the server, with no code changes and minimal markup changes. The advantages are extensive – the state of your multimedia (such as Adobe Flash or Windows Media) is unchanged, bandwidth costs are reduced, and the client does not experience the flicker usually associated with a postback.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;The ability to integrate partial page rendering is integrated into ASP.NET with minimal changes into your project.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2&gt;&lt;span style=";font-family:&amp;quot;;font-size:12;"  &gt;Walkthrough: Integrating Partial Rendering into an Existing Project&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;ol start="1" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;In Microsoft Visual Studio 2008, create a new ASP.NET      Web Site project by going to &lt;i&gt;File –&gt; New –&gt; Web Site…&lt;/i&gt; and      selecting “ASP.NET Web Site” from the dialog. You can name it whatever you      like, and you may install it either to the file system or into Internet      Information Services (IIS).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;You will be presented with the blank default page      with basic ASP.NET markup (a server-side form and an &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;@Page&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;      directive). Drop a Label called &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Label1&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; and a Button called &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Button1&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;      onto the page within the form element. You may set their text properties      to whatever you like.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;In Design view, double-click &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Button1&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;      to generate a code-behind event handler. Within this event handler, set &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Label1.Text&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; to “You clicked the button!”.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt;&lt;b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Listing 1: Markup for default.aspx before partial rendering is enabled&lt;/span&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;span style=""&gt; &lt;/span&gt;    &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;       &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;title&gt;Untitled Page&lt;/title&gt;         &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;   &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;            &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;form id="form1" runat="server"&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/form&gt;&lt;/span&gt;&lt;/code&gt;  &lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;          &lt;div&gt;                  &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;   &lt;asp: id="Label1" runat="server" text="This is a label!"&gt;&lt;/asp:&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;asp: id="Button1" runat="server" text="Click Me" onclick="Button1_Click"&gt;      &lt;o:p&gt;&lt;/o:p&gt;&lt;/asp:&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;                  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;   &lt;/span&gt;    &lt;o:p&gt;&lt;/o:p&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Listing 2: Code behind (trimmed) in default.aspx.cs&lt;/span&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Public partial class _Default: System.Web.UI.Page&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;span style=""&gt; &lt;/span&gt;{    &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;  protected void Button1_Click(object sender, EventArgs e)    &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;  {       &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;    Label1.Text = "You clicked the button!";  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;    } &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;}&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol start="4" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Press F5 to launch your web site. Visual Studio will      prompt you to add a web.config file to enable debugging; do so. When you      click the button, notice that the page refreshes to change the text in the      label, and there is a brief flicker as the page is redrawn.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;After closing your browser window, return to Visual      Studio and to the markup page. Scroll down in the Visual Studio toolbox,      and find the tab labeled “AJAX Extensions.” (If you do not have this tab      because you are using an older version of &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; or Atlas extensions, refer to the      walkthrough for registering the AJAX Extensions toolbox items later in      this whitepaper, or install the current version with the Windows Installer      downloadable from the website).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol start="1" type="a"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;i&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Known Issue: &lt;/span&gt;&lt;/i&gt;&lt;span style=";font-family:&amp;quot;;" &gt;If you install Visual Studio 2008 Beta 2 onto a      computer that already has Visual Studio 2005 installed with the ASP.NET      2.0 AJAX Extensions, Visual Studio 2008 will import the “AJAX Extensions”      toolbox items. You can determine whether this is the case by examining the      tooltip of the components; they should say “Version 3.5.0.0”. If they say      “Version 2.0.0.0,” then you have imported your old toolbox items, and will      need to manually import them by using the “Choose Toolbox Items” dialog in      Visual Studio. You will be unable to add Version 2 controls via the      designer.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;ol start="6" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Before the &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;asp:label&gt;&lt;/asp:label&gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; tag begins, create a line of      whitespace, and double-click on the UpdatePanel control in the toolbox.      Note that a new &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;@Register&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; directive is included at the top      of the page, indicating that controls within the System.Web.UI namespace      should be imported using the &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;asp:&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; prefix.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Drag the closing &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; tag past the end of the Button      element, so that the element is well-formed with the Label and Button      controls wrapped.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;After the opening &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;asp:updatepanel&gt;&lt;/asp:updatepanel&gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; tag, begin opening a new tag.      Note that IntelliSense prompts you with two options. In this case, create      a &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;contenttemplate&gt;&lt;/contenttemplate&gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; tag. Be sure to wrap this tag      around your Label and Button so that the markup is well-formed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol start="9" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Anywhere within the &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;form&gt;&lt;/form&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;" &gt; element, include a ScriptManager control by      double-clicking on the &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;ScriptManager&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; item in the toolbox.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Edit the &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;asp:scriptmanager&gt;&lt;/asp:scriptmanager&gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; tag so that it includes the      attribute &lt;/span&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;EnablePartialRendering=”true”&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Listing 3: Markup for default.aspx with partial rendering enabled&lt;/span&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;%@ Page Language="C#" AutoEventWireup="true"      CodeFile="Default.aspx.cs" Inherits="_Default" %&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,      PublicKeyToken=31bf3856ad364e35"      Namespace="System.Web.UI" TagPrefix="asp" %&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;               &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;title&gt;Untitled Page&lt;/title&gt;       &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;        &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;  &lt;asp:scriptmanager enablepartialrendering="true" id="ScriptManager1" runat="server"&gt;&lt;/asp:scriptmanager&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;               &lt;div&gt;                  &lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;   &lt;asp: id="UpdatePanel1" runat="server"&gt;                          &lt;contenttemplate&gt;                             &lt;o:p&gt;&lt;/o:p&gt;&lt;/contenttemplate&gt;&lt;/asp:&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;  &lt;asp: id="Label1" runat="server" text="This is a label!"&gt;&lt;/asp:&gt;       &lt;asp:button id="Button1" runat="server" text="Click Me" onclick="Button1_Click"&gt;                          &lt;o:p&gt;&lt;/o:p&gt;&lt;/asp:button&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;                    &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;               &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;         &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;    &lt;/span&gt;    &lt;o:p&gt;&lt;/o:p&gt;&lt;/code&gt;&lt;/p&gt;&lt;/ol&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;code&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;/span&gt;&lt;/code&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol start="11" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Open your web.config file. Notice that Visual Studio      has automatically added a compilation reference to      System.Web.Extensions.dll.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;ol start="1" type="a"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;What’s New in Visual Studio 2008: The web.config that      comes with the ASP.NET Web Site project templates automatically includes      all necessary references to the ASP.NET AJAX Extensions, and includes      commented sections of configuration information that can be un-commented      to enable additional functionality. Visual Studio 2005 had similar      templates when ASP.NET 2.0 AJAX Extensions were installed. However, in      Visual Studio 2008, the AJAX Extensions are opt-out by default (that is,      they are referenced by default, but can be removed as references).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="caption"&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Press F5 to launch your website. Note how no source code changes were required to support partial rendering – only markup was changed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;When you launch your website, you should see that partial rendering is now enabled, because when you click on the button there will be no flicker, nor will there be any change in the page scroll position (this example does not demonstrate that). If you were to look at the rendered source of the page after clicking the button, it will confirm that in fact a post-back has not occurred – the original label text is still part of the source markup, and the label has changed through JavaScript.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Visual Studio 2008 Beta 2 does not appear to come with a pre-defined template for an ASP.NET AJAX-Enabled web site. However, such a template was available within Visual Studio 2005 if the Visual Studio 2005 and ASP.NET 2.0 AJAX Extensions were installed. Consequently, configuring a web site and starting with the AJAX-Enabled Web Site template will likely be even easier, as the template should include a fully-configured web.config file (supporting all of the ASP.NET AJAX Extensions, including Web Services access and JSON serialization – JavaScript Object Notation) and includes an UpdatePanel and ContentTemplate within the main Web Forms page by default. Enabling partial rendering with this default page is as simple as revisiting Step 10 of this walkthrough and dropping controls onto the page.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-1936123260781116565?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/1936123260781116565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=1936123260781116565' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/1936123260781116565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/1936123260781116565'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/object-oriented-and-event-driven.html' title='object-oriented and event-driven programming model'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-963809020790897184</id><published>2008-04-23T04:22:00.000-07:00</published><updated>2008-04-23T04:24:48.131-07:00</updated><title type='text'></title><content type='html'>&lt;h2&gt;&lt;span style=";font-family:&amp;quot;;font-size:12;"  &gt;Simple ASP.NET 2.0 Tips and Tricks that You May (or may not) have Heard About &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;ASP.NET 2.0 is an awesome framework for developing Web applications.  If you've worked with it for awhile then that's no secret.  It offers some great new features that you can implement with a minimal amount of code.  I wanted to start a list of some of the most simple (yet cool) things you could do with it that required little or no C#/VB.NET code.  If you have other suggestions add a comment and I'll update the list if the suggestion is a simple task that can be applied easily.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt; 1.&lt;/span&gt;&lt;/strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;  &lt;strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Maintain the position of the scrollbar on postbacks&lt;/span&gt;&lt;/strong&gt;:  In ASP.NET 1.1 it was a pain to maintain the position of the scrollbar when doing a postback operation.  This was especially true when you had a grid on the page and went to edit a specific row.  Instead of staying on the desired row, the page would reload and you'd be placed back at the top and have to scroll down.  In ASP.NET 2.0 you can simply add the MaintainScrollPostionOnPostBack attribute to the Page directive:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:blue;"  &gt;&lt;&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:maroon;"  &gt;%@&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:red;"  &gt; Page Language&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:blue;"  &gt;="C#"&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:red;"  &gt; MaintainScrollPositionOnPostback&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:blue;"  &gt;="true" &lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:red;"  &gt;AutoEventWireup&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:blue;"  &gt;="true"&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:red;"  &gt; CodeFile&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:blue;"  &gt;="..."&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:red;"  &gt; Inherits&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:blue;"  &gt;="..."&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:red;"  &gt; %&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:blue;"  &gt;&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;2.  Set the default focus to a control when the page loads&lt;/span&gt;&lt;/strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;:  This is another extremely simple thing that can be done without resorting to writing JavaScript.  If you only have a single textbox (or two) on a page why should the user have to click in the textbox to start typing?  Shouldn't the cursor already be blinking in the textbox so they can type away?  Using the DefaultFocus property of the HtmlForm control you can easily do this.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;&lt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:maroon;"  &gt;form&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; id&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="frm"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; DefaultFocus&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="txtUserName"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; runat&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="server"&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:black;"  &gt;&lt;br /&gt; ...&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;&lt;!--&lt;/span--&gt;&lt;span style=";font-family:&amp;quot;;color:maroon;"  &gt;form&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;3. Set the default button that is triggered when the user hits the enter key:&lt;/span&gt;&lt;/strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;  This was a major pain point in ASP.NET 1.1 and required some JavaScript to be written to ensure that when the user hit the enter key that the appropriate button on the form triggered a "click" event on the server-side.  Fortunately, you can now use the HtmlForm control's DefaultButton property to set which button should be clicked when the user hits enter.  This property is also available on the Panel control in cases where different buttons should be triggered as a user moves into different Panels on a page.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;&lt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:maroon;"  &gt;form&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; id&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="frm"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; DefaultButton&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="btnSubmit"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; runat&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="server"&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:black;"  &gt;&lt;br /&gt; ...&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;&lt;!--&lt;/span--&gt;&lt;span style=";font-family:&amp;quot;;color:maroon;"  &gt;form&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;4.&lt;/span&gt;&lt;/strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Locate nested controls easily&lt;/span&gt;&lt;/strong&gt;: Finding controls within a Page's control hierarchy can be painful but if you know how the controls are nested you can use the lesser known "$" shortcut to find controls without having to write recursive code.The following example shows how to use the DefaultFocus property to set the focus on a textbox that is nested inside of a FormView control.  Notice that the "$" is used to delimit the nesting:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;&lt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:maroon;"  &gt;form&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;span style="color:red;"&gt;id&lt;/span&gt;&lt;span style="color:blue;"&gt;="form1"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&lt;/span&gt; &lt;span style="color:red;"&gt;DefaultFocus&lt;/span&gt;&lt;span style="color:blue;"&gt;="formVw$txtName"&gt;&lt;br /&gt;   &lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;div&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;br /&gt;       &lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:maroon;"&gt;FormView&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="formVw"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&gt;&lt;br /&gt;           &lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;br /&gt;               &lt;/span&gt;Name:&lt;br /&gt;               &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:maroon;"&gt;TextBox&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="txtName"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&lt;br /&gt;                   &lt;/span&gt;&lt;span style="color:red;"&gt;Text&lt;/span&gt;&lt;span style="color:blue;"&gt;='&lt;/span&gt;&lt;%# Eval("FirstName") + " " + Eval("LastName") %&gt;&lt;span style="color:blue;"&gt;'&lt;/span&gt; &lt;span style="color:blue;"&gt;/&gt;&lt;br /&gt;           &lt;!--&lt;/span--&gt;&lt;span style="color:maroon;"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;br /&gt;       &lt;!--&lt;/span--&gt;&lt;span style="color:maroon;"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color:maroon;"&gt;FormView&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;br /&gt;   &lt;!--&lt;/span--&gt;&lt;span style="color:maroon;"&gt;div&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color:maroon;"&gt;form&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;This little trick can also be used on the server-side when calling FindControl.Here's an example:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;color:black;"  &gt;TextBox tb &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;= this&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:black;"  &gt;.FindControl(&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:gray;"  &gt;"form1$formVw$txtName"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:black;"  &gt;) &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;as &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:black;"  &gt;TextBox&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;;&lt;br /&gt;if &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:black;"  &gt;(tb !&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;= null&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:black;"  &gt;)&lt;br /&gt;{&lt;br /&gt;   &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:darkgreen;"  &gt;//Access TextBox control&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:black;"  &gt;}&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;5.&lt;/span&gt;&lt;/strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Strongly-typed access to cross-page postback controls:&lt;/span&gt;&lt;/strong&gt;  This one is a little more involved than the others, but quite useful.  ASP.NET 2.0 introduced the concept of cross-page postbacks where one page could postback information to a page other than itself.  This is done by setting the PostBackUrl property of a button to the name of the page that the button should postback data to.  Normally, the posted data can be accessed by doing something like PreviousPage.FindControl("ControlID").  However, this requires a cast if you need to access properties of the target control in the previous page (which you normally need to do).  If you add a public property into the code-behind page that initiates the postback operation, you can access the property in a strongly-typed manner by adding the PreviousPageType directive into the target page of the postback.  That may sound a little confusing if you haven't done it so let me explain a little more.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;If you have a page called Default.aspx that exposes a public property that returns a Textbox that is defined in the page, the page that data is posted to (lets call it SearchResults.aspx) can access that property in a strongly-typed manner (no FindControl() call is necessary) by adding the PreviousPageType directive into the top of the page:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:blue;"  &gt;&lt;&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:maroon;"  &gt;%@&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:red;"  &gt; PreviousPageType VirtualPath&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:blue;"  &gt;="Default.aspx"&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:red;"  &gt; %&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:blue;"  &gt;&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;By adding this directive, the code in SearchResults.aspx can access the TextBox defined in Default.aspx in a strongly-typed manner.  The following example assumes the property defined in Default.aspx is named SearchTextBox.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;color:black;"  &gt;TextBox tb &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;= &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:black;"  &gt;PreviousPage.SearchTextBox&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;This code obviously only works if the previous page is Default.aspx.  PreviousPageType also has a TypeName property as well where you could define a base type that one or more pages derive from to make this technique work with multiple pages.  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;6. Strongly-typed access to Master Pages controls:&lt;/span&gt;&lt;/strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt; The PreviousPageType directive isn't the only one that provides strongly-typed access to controls.  If you have public properties defined in a Master Page that you'd like to access in a strongly-typed manner you can add the MasterType directive into a page as shown next (note that the MasterType directive also allows a TypeName to be defined as with the PreviousPageType directive):&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:blue;"  &gt;&lt;&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:maroon;"  &gt;%@&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:red;"  &gt; MasterType VirtualPath&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:blue;"  &gt;="MasterPage.master"&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:red;"  &gt; %&lt;/span&gt;&lt;span style="background: rgb(255, 255, 153) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:&amp;quot;;color:blue;"  &gt;&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;You can then access properties in the target master page from a content page by writing code like the following:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;this&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:black;"  &gt;.Master.HeaderText &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;= &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:gray;"  &gt;"Label updated using MasterType directive with VirtualPath attribute."&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;7. Validation groups&lt;/span&gt;&lt;/strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: You may have a page that has multiple controls and multiple buttons.  When one of the buttons is clicked you want specific validator controls to be evaluated rather than all of the validators defined on the page.  With ASP.NET 1.1 there wasn't a great way to handle this without resorting to some hack code.  ASP.NET 2.0 adds a ValidationGroup property to all validator controls and buttons (Button, LinkButton, etc.) that easily solves the problem.  If you have a TextBox at the top of a page that has a RequiredFieldValidator next to it and a Button control, you can fire that one validator when the button is clicked by setting the ValidationGroup property on the button and on the RequiredFieldValidator to the same value.  Any other validators not in the defined ValidationGroup will be ignored when the button is clicked. Here's an example:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;&lt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:maroon;"  &gt;form&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; id&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="form1"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; runat&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="server"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:black;"  &gt;&lt;br /&gt;   Search Text: &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;&lt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:maroon;"  &gt;asp: Textbox&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; ID&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="txtSearch"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; runat&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="server"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;/&gt;&lt;br /&gt;&lt;br /&gt;   &lt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:maroon;"  &gt;asp: RequiredFieldValidator&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; ID&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="valSearch"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; runat&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="Server"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt;&lt;br /&gt;     ControlToValidate&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="txtSearch"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; &lt;strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;ValidationGroup&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="SearchGroup"&lt;/span&gt;&lt;/strong&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;/&gt;&lt;br /&gt;&lt;br /&gt;   &lt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:maroon;"  &gt;asp: Button&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; ID&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="btnSearch"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; runat&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="server"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; Text&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="Search"&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt;&lt;br /&gt;     &lt;strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;ValidationGroup&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;="SearchGroup"&lt;/span&gt;&lt;/strong&gt;&lt;span style=";font-family:&amp;quot;;color:red;"  &gt; &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;/&gt;&lt;br /&gt;   ....&lt;br /&gt;   Other controls with validators and buttons defined here&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style=";font-family:&amp;quot;;color:maroon;"  &gt;form&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;color:blue;"  &gt;&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;8. Finding control/variable names while typing code:&lt;/span&gt;&lt;/strong&gt;&lt;span style=";font-family:&amp;quot;;" &gt;  This tip is a bit more related to VS.NET than to ASP.NET directly, but it's definitely helpful for those of you who remember the first few characters of control variable name (or any variable for that matter) but can't remember the complete name.  It also gives me the chance to mention two great downloads from Microsoft.  First the tip though.  After typing the first few characters of a control/variable name, hit CTRL + SPACEBAR and VS.NET will bring up a short list of matching items.  Definitely a lot easier than searching for the control/variable definition.  Thanks to Darryl for the tip.  For those who are interested, Microsoft made all of the VS.NET keyboard shortcuts available in a nice downloadable and printable guide.  Get the C# version here and the VB.NET version here.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div  style="border-style: none none solid; padding: 0in 0in 1pt;color:-moz-use-text-color -moz-use-text-color windowtext;"&gt;  &lt;p style="border: medium none ; padding: 0in;"&gt;&lt;span style=";font-family:&amp;quot;;" &gt;That's all for now.  There are a lot of other things that could be mentioned and I'll try to keep this post updated.  Have a great (simple) ASP.NET 2.0 tip or trick?  Post the details in the comments and I'll add it if the content is appropriate for the list.  Make sure to list your name so I can give proper credit.&lt;/span&gt;&lt;/p&gt;  &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-963809020790897184?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/963809020790897184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=963809020790897184' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/963809020790897184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/963809020790897184'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/simple-asp.html' title=''/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-6033025397289135015</id><published>2008-04-17T00:34:00.000-07:00</published><updated>2008-04-17T00:36:13.531-07:00</updated><title type='text'>Acronyms in .NET  Part 3</title><content type='html'>&lt;p class="a"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;WC&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt; - Windows Cardspace - Part of .NET 3.0 framework, that enables users to secure and store digital identities of a person, and a provision to a unified interface for choosing the identity for a particular transaction, like logging in to a website.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;WCF&lt;/b&gt; - Windows Communication Foundation - Part of .NET 3.0 framework, that enables communication between applications across machines.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;WF&lt;/b&gt; - Windows Workflow Foundation - Part of .NET 3.0 framework, used for defining, execution and management of reusable workflows.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;WKO&lt;/b&gt; - Well Known Object - These are MBR types whose lifetime is controlled by the server's application domain.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;WPF&lt;/b&gt; - Windows Presentation Foundation - Part of .NET 3.0 framework, is the graphical subsystem of the .NET 3.0 framework.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;WSDL&lt;/b&gt; - Web Services Description Language - is an XML based language for describing web services.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;WML&lt;/b&gt; - Wireless Markup Language - is a content format for those devices that use Wireless Application Protocol.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;VB.NET&lt;/b&gt; - Visual Basic .NET - .NET based language. Its the .NET implementation of VB6, the most widely used language in the world.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;VBC.exe&lt;/b&gt; - VB.NET Compiler&lt;br /&gt;&lt;br /&gt;&lt;b&gt;VES&lt;/b&gt; - Virtual Execution System - It provides the environment for execution of managed code. It provides direct support for a set of built in data types, defines a hypothetical machine with an associated machine model and state, a set of control flow constructs, and an exception handling model. To a large extent, the purpose of the VES is to provide the support required to execute the Common Intermediate Language instruction set.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;VS&lt;/b&gt; - Visual Studio&lt;br /&gt;&lt;br /&gt;&lt;b&gt;VSS&lt;/b&gt; - Visual Source Safe - An IDE by Microsoft, to maintain source code versions and security.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;VSTS&lt;/b&gt; - Visual Studio Team Suite - Visual Studio Team System - it is an extended version of Visual Studio .NET. It has a set of collaboration and development tools for software development process.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;XML&lt;/b&gt; - Extensible Markup Language - is a general purpose well formed markup language. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-6033025397289135015?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/6033025397289135015/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=6033025397289135015' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/6033025397289135015'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/6033025397289135015'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/acronyms-in-net-part-3.html' title='Acronyms in .NET  Part 3'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-8566965725552050684</id><published>2008-04-17T00:33:00.000-07:00</published><updated>2008-04-17T00:34:04.065-07:00</updated><title type='text'>Acronyms in .NET  Part 2</title><content type='html'>&lt;b&gt;&lt;span style="font-size: 12pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;IDE&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 12pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt; - Integrated Development Environment - is a development environment with source code editor with a compiler(or interpretor), debugging tools, designer, solution explorer, property window, object explorer etc.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;IDL&lt;/b&gt; - Interface Definition Language - is a language for defining software components interface.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;ILDASM&lt;/b&gt; - Intermediate Language Disassembler - The contents of an assembly may be viewed using the ILDASM utility, that comes with the .NET SDK or the Visual Studio.NET. The ildasm.exe tool may also be used in the command line compiler.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;IIS&lt;/b&gt; - Internet Information Server - Is a server that provides services to websites and even hosts websites.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;IL&lt;/b&gt; - Intermediate Language - is the compiled form of the .NET language source code. When .NET source code is compiled by the language specific compiler (say we compile C# code using csc.exe), it is compiled to a .NET binary, which is platform independent, and is called Intermediate Language code. The .NET binary also comprises of metadata.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;JIT&lt;/b&gt; - Just in Time (Jitter) - is a technology for boosting the runtime performance of a system. It converts during runtime, code from one format into another, just like IL into native machine code. Note that JIT compilation is processor specific. Say a processor is X86 based, then the JIT compilation will be for this type of processor.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;MBR&lt;/b&gt; - MarshallByReference - The caller recieves a proxy to the remote object.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;MBV&lt;/b&gt; - MarshallByValue - The caller recieves a copy of the object in its own application domain.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;MDI&lt;/b&gt; - Multiple Document Interface - A window that resides under a single parent window.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;MSIL&lt;/b&gt; - Microsoft Intermediate Language - now called CIL.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Orcas&lt;/b&gt; - Codename for Visual Studio 2008&lt;br /&gt;&lt;br /&gt;&lt;b&gt;PE&lt;/b&gt; - Portable Executable - an exe format file that is portable.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;RAD&lt;/b&gt; - Rapid Application Development&lt;br /&gt;&lt;br /&gt;&lt;b&gt;RCW&lt;/b&gt; - Runtime Callable Wrapper - This component is used when a .NET needs to use a COM component.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;SAX&lt;/b&gt; - Simple API for XML - It is a serial access parser API for XML. The parser is event driven and the event gets triggered when an XML feature is encountered.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;SDK&lt;/b&gt; - Software Development Kit&lt;br /&gt;&lt;br /&gt;&lt;b&gt;SMTP&lt;/b&gt; - Simple Mail Transfer Protocol - a text based protocol for sending mails.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;SN.exe&lt;/b&gt; - Strong Name Utility - a tool to make strong named assemblies.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;SQL&lt;/b&gt; - Structured Query Language - a language for management of data in a relational structure.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;SOAP&lt;/b&gt; - Simple Object Access Protocol - a protocol used for exchange of xml based messages across networks.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;TCP&lt;/b&gt; - Transmission Control Protocol - data exchange protocol across networks using streamed sockets.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;UI&lt;/b&gt; - User Interface&lt;br /&gt;&lt;br /&gt;&lt;b&gt;URI&lt;/b&gt; - Uniform Resource Identifier&lt;br /&gt;&lt;br /&gt;&lt;b&gt;URL&lt;/b&gt; - Uniform Resource Locator&lt;br /&gt;&lt;br /&gt;&lt;b&gt;UDDI&lt;/b&gt; - Universal Description, Discovery and Integration - it is a platform independent business registration across the internet.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;WAP&lt;/b&gt; - Wireless Access Protocol - a protocol that enables access to the internet from mobile phones and PDAs. &lt;br /&gt; &lt;!--[if !supportLineBreakNewLine]--&gt;&lt;br /&gt; &lt;!--[endif]--&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-8566965725552050684?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/8566965725552050684/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=8566965725552050684' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/8566965725552050684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/8566965725552050684'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/acronyms-in-net-part-2.html' title='Acronyms in .NET  Part 2'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-6489774697518836100</id><published>2008-04-17T00:32:00.000-07:00</published><updated>2008-04-17T00:33:03.049-07:00</updated><title type='text'>Acronyms in .NET  Part 1</title><content type='html'>&lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;&lt;b&gt;&lt;span style="font-size: 12pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;ADO&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;/st1:City&gt;&lt;span style="font-size: 12pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt; - ActiveX Data Object - Microsoft ActiveX Data Objects (ADO) is a collection of Component Object Model objects for accessing different types of data sources.&lt;br /&gt;&lt;br /&gt;&lt;st1:city st="on"&gt;&lt;b&gt;AJAX&lt;/b&gt;&lt;/st1:City&gt; - Asynchronouse Javascript and XML - &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Ajax&lt;/st1:place&gt;&lt;/st1:City&gt; is a web development technology used for creating interactive web pages with fast data rendering by enabling partial postbacks on a web page (That means a section of the web page is rendered again, instead of the complete web page. This is achieved using Javascript, XML, JSON (Javascript Notation Language) and the XMLHttpRequest object in javascript.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;ASP&lt;/b&gt; - Active Server Pages - Microsoft's Server side script engine for creating dynamic web page.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;C#&lt;/b&gt; - C Sharp - Microsoft Visual C# is an object oriented programming language based on the .NET Framework. It includes features of powerful languages like C++, Java, &lt;st1:place st="on"&gt;Delphi&lt;/st1:place&gt; and Visual Basic.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;CAO&lt;/b&gt; - Client Activated Object - Objects created on the server upon the client's request. This is used in Remoting.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;CCW&lt;/b&gt; - COM Callable Wrapper - This component is used when a .NET component needs to be used in COM.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;CIL&lt;/b&gt; - Common Intermediate Language - Its actually a low level human readable language implementation of CLI. All .NET-aware languages compile the source oode to an intermediate language called Common Intermediate Language using the language specific compiler.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;CLI&lt;/b&gt; - Common Language Infrastructure - This is a subset of CLR and base class libraries that Microsoft has submitted to ECMA so that a third-party vendor can build a .NET runtime on another platform.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;CLR&lt;/b&gt; - Common Language Runtime - It is the main runtime machine of the Microsoft .NET Framework. It includes the implementation of CLI. The CLR runs code in the form of bytes, called as bytecode and this is termed MSIL in .NET.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;CLS&lt;/b&gt; - Common Language Specification - A type that is CLS compliant, may be used across any .NET language. CLS is a set of language rules that defines language standards for a .NET language and types declared in it. While declaring a new type, if we make use of the [CLSCompliant] attribute, the type is forced to conform to the rules of CLS.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;COFF&lt;/b&gt; - Common Object File Format - It is a specification format for executables.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;COM&lt;/b&gt; - Component Object Model - reusable software components. The tribe of COM components includes COM+, Distributed COM (DCOM) and ActiveX® Controls.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;CSC.exe&lt;/b&gt; - C Sharp Compiler utility&lt;br /&gt;&lt;br /&gt;&lt;b&gt;CTS&lt;/b&gt; - Common Type System - It is at the core of .NET Framework's cross-language integration, type safety, and high-performance code execution. It defines a common set of types that can be used with many different language syntaxes. Each language (C#, VB.NET, Managed C++, and so on) is free to define any syntax it wishes, but if that language is built on the CLR, it will use at least some of the types defined by the CTS.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;DBMS&lt;/b&gt; - Database Management System - a software application used for management of databases.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;DISCO&lt;/b&gt; - Discovery of Web Services. A Web Service has one or more. DISCO files that contain information on how to access its WSDL.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;DLL&lt;/b&gt; - Dynamic Link Library - a shared reusable library, that exposes an interface of usable methods within it.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;DOM&lt;/b&gt; - Document Object Model - is a language independent technology that permits scripts to dynamically updated contents of a document (a web page is also a document).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;ECMA&lt;/b&gt; - European Computer Manufacturer's Association - Is an internation organisation for computer standards.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;GC&lt;/b&gt; - Garbage Collector - an automatic memory management system through which objects that are not referenced are cleared up from the memory.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;GDI&lt;/b&gt; - Graphical Device Interface - is a component in Windows based systems, that performs the activity of representing graphical objects and outputting them to output devices.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;GAC&lt;/b&gt; - Global Assembly Cache - Is a central repository of reusable libraries in the .NET environment.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;GUI&lt;/b&gt; - Graphic User Interface - a type of computer interface through which user's may interact with the Computer using different types of input &amp;amp; output devices with a graphical interface.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;GUID&lt;/b&gt; - Globally Unique Identifier - is a unique reference number used in applications to refer an object.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;HTTP&lt;/b&gt; - Hyper Text Transfer Protocol - is a communication protocol used to transfer information in the internet. HTTP is a request-response protocol between servers and clients. &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-6489774697518836100?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/6489774697518836100/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=6489774697518836100' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/6489774697518836100'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/6489774697518836100'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/acronyms-in-net-part-1.html' title='Acronyms in .NET  Part 1'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-5199193302138537123</id><published>2008-04-17T00:30:00.002-07:00</published><updated>2008-04-17T00:31:05.631-07:00</updated><title type='text'>Part 5</title><content type='html'>&lt;div style="border-style: none none solid; border-color: -moz-use-text-color -moz-use-text-color windowtext; border-width: medium medium 1pt; padding: 0in 0in 1pt;"&gt;  &lt;p class="a" style="border: medium none ; padding: 0in;"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Q81. What technique is used to figure out that the page request is a postback?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;br /&gt;Ans. The IsPostBack property of the page object may be used to check whether the page request is a postback or not. IsPostBack property is of the type Boolean.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q82. Which event of the ASP.NET page life cycle completely loads all the controls on the web page?&lt;/b&gt;&lt;br /&gt;Ans. The Page_load event of the ASP.NET page life cycle assures that all controls are completely loaded. Even though the controls are also accessible in Page_Init event but here, the viewstate is incomplete.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q83. How is ViewState information persisted across postbacks in an ASP.NET webpage?&lt;/b&gt;&lt;br /&gt;Ans. Using HTML Hidden Fields, ASP.NET creates a hidden field with an ID="__VIEWSTATE" and the value of the page's viewstate is encoded (hashed) for security.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q84. What is the ValidationSummary control in ASP.NET used for?&lt;/b&gt;&lt;br /&gt;Ans. The ValidationSummary control in ASP.NET displays summary of all the current validation errors.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q85. What is AutoPostBack feature in ASP.NET?&lt;/b&gt;&lt;br /&gt;Ans. In case it is required for a server side control to postback when any of its event is triggered, then the AutoPostBack property of this control is set to true.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q86. What is the difference between Web.config and Machine.Config in .NET?&lt;/b&gt;&lt;br /&gt;Ans. Web.config file is used to make the settings to a web application, whereas Machine.config file is used to make settings to all ASP.NET applications on a server(the server machine).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q87. What is the difference between a session object and an application object?&lt;/b&gt;&lt;br /&gt;Ans. A session object can persist information between HTTP requests for a particular user, whereas an application object can be used globally for all the users.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q88. Which control has a faster performance, Repeater or Datalist?&lt;/b&gt;&lt;br /&gt;Ans. Repeater.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q89. Which control has a faster performance, Datagrid or Datalist?&lt;/b&gt;&lt;br /&gt;Ans. Datalist.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q90. How to we add customized columns in a Gridview in ASP.NET?&lt;/b&gt;&lt;br /&gt;Ans. Make use of the TemplateField column.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q91. Is it possible to stop the clientside validation of an entire page?&lt;/b&gt;&lt;br /&gt;Ans. Set Page.Validate = false;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q92. Is it possible to disable client side script in validators?&lt;/b&gt;&lt;br /&gt;Ans. Yes. simply EnableClientScript = false.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q93. How do we enable tracing in .NET applications?&lt;/b&gt;&lt;br /&gt;Ans. &lt;%@ Page Trace="true" %&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q94. How to kill a user session in ASP.NET?&lt;/b&gt;&lt;br /&gt;Ans. Use the Session.abandon() method.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q95. Is it possible to perform forms authentication with cookies disabled on a browser?&lt;/b&gt;&lt;br /&gt;Ans. No, it is not possible.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q96. What are the steps to use a checkbox in a gridview?&lt;/b&gt;&lt;br /&gt;Ans. &lt;itemtemplate&gt;&lt;br /&gt;&lt;asp:CheckBox id="CheckBox1" runat="server" AutoPostBack="True"&lt;br /&gt;OnCheckedChanged="Check_Clicked"&gt;&lt;/asp:CheckBox&gt;&lt;br /&gt;&lt;/itemtemplate&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q97. What are design patterns in .NET?&lt;/b&gt;&lt;br /&gt;Ans. A Design pattern is a repeatitive solution to a repeatitive problem in the design of a software architecture.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q98. What is difference between dataset and datareader in ADO.NET?&lt;/b&gt;&lt;br /&gt;Ans. A DataReader provides a forward-only and read-only access to data, while the DataSet object can carry more than one table and at the same time hold the relationships between the tables. Also note that a DataReader is used in a connected architecture whereas a Dataset is used in a disconnected architecture.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q99. Can connection strings be stored in web.config?&lt;/b&gt;&lt;br /&gt;Ans. Yes, in fact this is the best place to store the connection string information.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q100. Whats the difference between web.config and app.config?&lt;/b&gt;&lt;br /&gt;Ans. Web.config is used for web based asp.net applications whereas app.config is used for windows based applications. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-5199193302138537123?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/5199193302138537123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=5199193302138537123' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/5199193302138537123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/5199193302138537123'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/part-5.html' title='Part 5'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-9080038422662897640</id><published>2008-04-17T00:30:00.001-07:00</published><updated>2008-04-17T00:30:14.058-07:00</updated><title type='text'>Part 4</title><content type='html'>&lt;p class="a"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Q61. Is a delegate a type-safe functions pointer?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;br /&gt;Ans. Yes&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q62. What is the return type of an event in .NET?&lt;/b&gt;&lt;br /&gt;Ans. There is No return type of an event in .NET.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q63. Is it possible to specify an access specifier to an event in .NET?&lt;/b&gt;&lt;br /&gt;Ans. Yes, though they are public by default.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q64. Is it possible to create a shared event in .NET?&lt;/b&gt;&lt;br /&gt;Ans. Yes, but shared events may only be raised by shared methods.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q65. How to prevent overriding of a class in .NET?&lt;/b&gt;&lt;br /&gt;Ans. Use the keyword NotOverridable in VB.NET and sealed in C#.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q66. How to prevent inheritance of a class in .NET?&lt;/b&gt;&lt;br /&gt;Ans. Use the keyword NotInheritable in VB.NET and sealed in C#.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q67. What is the purpose of the MustInherit keyword in VB.NET?&lt;/b&gt;&lt;br /&gt;Ans. MustInherit keyword in VB.NET is used to create an abstract class.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q68. What is the access modifier of a member function of in an Interface created in .NET?&lt;/b&gt;&lt;br /&gt;Ans. It is always public, we cant use any other modifier other than the public modifier for the member functions of an Interface.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q69. What does the virtual keyword in C# mean?&lt;/b&gt;&lt;br /&gt;Ans. The virtual keyword signifies that the method and property may be overridden.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q70. How to create a new unique ID for a control?&lt;/b&gt;&lt;br /&gt;Ans. ControlName.ID = "ControlName" + Guid.NewGuid().ToString(); //Make use of the Guid class&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q71A. What is a HashTable in .NET?&lt;/b&gt;&lt;br /&gt;Ans. A Hashtable is an object that implements the IDictionary interface, and can be used to store key value pairs. The key may be used as the index to access the values for that index.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q71B. What is an ArrayList in .NET?&lt;/b&gt;&lt;br /&gt;Ans. Arraylist object is used to store a list of values in the form of a list, such that the size of the arraylist can be increased and decreased dynamically, and moreover, it may hold items of different types. Items in an arraylist may be accessed using an index.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q72. What is the value of the first item in an Enum? 0 or 1?&lt;/b&gt;&lt;br /&gt;Ans. 0&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q73. Can we achieve operator overloading in VB.NET?&lt;/b&gt;&lt;br /&gt;Ans. Yes, it is supported in the .NET 2.0 version, the "operator" keyword is used.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q74. What is the use of Finalize method in .NET?&lt;/b&gt;&lt;br /&gt;Ans. .NET Garbage collector performs all the clean up activity of the managed objects, and so the finalize method is usually used to free up the unmanaged objects like File objects, Windows API objects, Database connection objects, COM objects etc.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q75. How do you save all the data in a dataset in .NET?&lt;/b&gt;&lt;br /&gt;Ans. Use the AcceptChanges method which commits all the changes made to the dataset since last time Acceptchanges was performed.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q76. Is there a way to suppress the finalize process inside the garbage collector forcibly in .NET?&lt;/b&gt;&lt;br /&gt;Ans. Use the GC.SuppressFinalize() method.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q77. What is the use of the dispose() method in .NET?&lt;/b&gt;&lt;br /&gt;Ans. The Dispose method in .NET belongs to IDisposable interface and it is best used to release unmanaged objects like File objects, Windows API objects, Database connection objects, COM objects etc from the memory. Its performance is better than the finalize() method.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q78. Is it possible to have have different access modifiers on the get and set methods of a property in .NET?&lt;/b&gt;&lt;br /&gt;Ans. No we can not have different modifiers of a common property, which means that if the access modifier of a property's get method is protected, and it must be protected for the set method as well.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q79. In .NET, is it possible for two catch blocks to be executed in one go?&lt;/b&gt;&lt;br /&gt;Ans. This is NOT possible because once the correct catch block is executed then the code flow goes to the finally block.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q80. Is there any difference between System.String and System.StringBuilder classes?&lt;/b&gt;&lt;br /&gt;Ans. System.String is immutable by nature whereas System.StringBuilder can have a mutable string in which plenty of processes may be performed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-9080038422662897640?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/9080038422662897640/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=9080038422662897640' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/9080038422662897640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/9080038422662897640'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/part-4.html' title='Part 4'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-3523087039109325856</id><published>2008-04-17T00:29:00.001-07:00</published><updated>2008-04-17T00:29:32.886-07:00</updated><title type='text'>Part 3</title><content type='html'>&lt;p class="a"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Q41. How to instruct the garbage collector to collect unreferenced data?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;br /&gt;Ans. We may call the garbage collector to collect unreferenced data by executing the System.GC.Collect() method.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q42. How can we set the Focus on a control in ASP.NET?&lt;/b&gt;&lt;br /&gt;Ans. txtBox123.Focus (); OR Page.SetFocus(NameOfControl);&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q43. What are Partial Classes in Asp.Net 2.0?&lt;/b&gt;&lt;br /&gt;Ans. In .NET 2.0, a class definition may be split into multiple physical files but partial classes do not make any difference to the compiler as during compile time, the compiler groups all the partial classes and treats them as a single class.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q44. How to set the default button on a Web Form? &lt;/b&gt;&lt;br /&gt;Ans. &lt;asp:form id="form1" runat="server" defaultbutton="btnGo"&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q45.Can we force the garbage collector to run?&lt;/b&gt;&lt;br /&gt;Ans. Yes, using the System.GC.Collect(), the garbage collector is forced to run in case required to do so.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q46. What is Boxing and Unboxing?&lt;/b&gt;&lt;br /&gt;Ans. Boxing is the process where any value type can be implicitly converted to a reference type object while Unboxing is the opposite of boxing process where the reference type is converted to a value type.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q47. What is Code Access security? What is CAS in .NET?&lt;/b&gt;&lt;br /&gt;Ans. CAS is the feature of the .NET security model that determines whether an application or a piece of code is permitted to run and decide the resources it can use while running.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q48. What is Multi-tasking?&lt;/b&gt;&lt;br /&gt;Ans. It is a feature of operating systems through which multiple programs may run on the operating system at the same time, just like a scenario where a Notepad, a Calculator and the Control Panel are open at the same time.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q49. What is Multi-threading?&lt;/b&gt;&lt;br /&gt;Ans. When an application performs different tasks at the same time, the application is said to exhibit multithreading as several threads of a process are running.2&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q50. What is a Thread?&lt;/b&gt;&lt;br /&gt;Ans. A thread is an activity started by a process and its the basic unit to which an operating system allocates processor resources.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q51. What does AddressOf in VB.NET operator do?&lt;/b&gt;&lt;br /&gt;Ans. The AddressOf operator is used in VB.NET to create a delegate object to a method in order to point to it.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q52. How to refer to the current thread of a method in .NET?&lt;/b&gt;&lt;br /&gt;Ans. In order to refer to the current thread in .NET, the Thread.CurrentThread method can be used. It is a public static property.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q53. How to pause the execution of a thread in .NET?&lt;/b&gt;&lt;br /&gt;Ans. The thread execution can be paused by invoking the Thread.Sleep(IntegerValue) method where IntegerValue is an integer that determines the milliseconds time frame for which the thread in context has to sleep.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q54. How can we force a thread to sleep for an infinite period?&lt;/b&gt;&lt;br /&gt;Ans. Call the Thread.Interupt() method.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q55. What is Suspend and Resume in .NET Threading?&lt;/b&gt;&lt;br /&gt;Ans. Just like a song may be paused and played using a music player, a thread may be paused using Thread.Suspend method and may be started again using the Thread.Resume method. Note that sleep method immediately forces the thread to sleep whereas the suspend method waits for the thread to be in a persistable position before pausing its activity.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q56. How can we prevent a deadlock in .Net threading?&lt;/b&gt;&lt;br /&gt;Ans. Using methods like Monitoring, Interlocked classes, Wait handles, Event raising from between threads, using the ThreadState property.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q57. What is Ajax?&lt;/b&gt;&lt;br /&gt;Ans. Asyncronous Javascript and XML - Ajax is a combination of client side technologies that sets up asynchronous communication between the user interface and the web server so that partial page rendering occur instead of complete page postbacks.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q58. What is XmlHttpRequest in Ajax?&lt;/b&gt;&lt;br /&gt;Ans. It is an object in Javascript that allows the browser to communicate to a web server asynchronously without making a postback.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q59. What are the different modes of storing an ASP.NET session?&lt;/b&gt;&lt;br /&gt;Ans. InProc (the session state is stored in the memory space of the Aspnet_wp.exe process but the session information is lost when IIS reboots), StateServer (the Session state is serialized and stored in a separate process call Viewstate is an object in .NET that automatically persists control setting values across the multiple requests for the same page and it is internally maintained as a hidden field on the web page though its hashed for security reasons.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q60. What is a delegate in .NET?&lt;/b&gt;&lt;br /&gt;Ans. A delegate in .NET is a class that can have a reference to a method, and this class has a signature that can refer only those methods that have a signature which complies with the class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-3523087039109325856?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/3523087039109325856/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=3523087039109325856' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/3523087039109325856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/3523087039109325856'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/part-3.html' title='Part 3'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-74349638370372792</id><published>2008-04-17T00:28:00.000-07:00</published><updated>2008-04-17T00:29:04.423-07:00</updated><title type='text'>Part 2</title><content type='html'>&lt;p class="a"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Q21. What is encapsulation?&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;br /&gt;Ans. Encapsulation is the OOPs concept of binding the attributes and behaviors in a class, hiding the implementation of the class and exposing the functionality.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q22. What is Overloading?&lt;/b&gt;&lt;br /&gt;Ans. When we add a new method with the same name in a same/derived class but with different number/types of parameters, the concept is called overluoad and this ultimately implements Polymorphism.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q23. What is Overriding?&lt;/b&gt;&lt;br /&gt;Ans. When we need to provide different implementation in a child class than the one provided by base class, we define the same method with same signatures in the child class and this is called overriding.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q24. What is a Delegate? &lt;/b&gt;&lt;br /&gt;Ans. A delegate is a strongly typed function pointer object that encapsulates a reference to a method, and so the function that needs to be invoked may be called at runtime.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q25. Is String a Reference Type or Value Type in .NET? &lt;/b&gt;&lt;br /&gt;Ans. String is a Reference Type object.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q26. What is a Satellite Assembly? &lt;/b&gt;&lt;br /&gt;Ans. Satellite assemblies contain resource files corresponding to a locale (Culture + Language) and these assemblies are used in deploying an application globally for different languages.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q27. What are the different types of assemblies and what is their use?&lt;/b&gt;&lt;br /&gt;Ans. Private, Public(also called shared) and Satellite Assemblies.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q28. Are MSIL and CIL the same thing?&lt;/b&gt;&lt;br /&gt;Ans. Yes, CIL is the new name for MSIL.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q29. What is the base class of all web forms?&lt;/b&gt;&lt;br /&gt;Ans. System.Web.UI.Page&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q30. How to add a client side event to a server control?&lt;/b&gt;&lt;br /&gt;Ans. Example... BtnSubmit.Attributes.Add("onclick","javascript:fnSomeFunctionInJavascript()");&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q31. How to register a client side script from code-behind?&lt;/b&gt;&lt;br /&gt;Ans. Use the Page.RegisterClientScriptBlock method in the server side code to register the script that may be built using a StringBuilder.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q32. Can a single .NET DLL contain multiple classes?&lt;/b&gt;&lt;br /&gt;Ans. Yes, a single .NET DLL may contain any number of classes within it.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q33. What is DLL Hell?&lt;/b&gt;&lt;br /&gt;Ans. DLL Hell is the name given to the problem of old unmanaged DLL's due to which there was a possibility of version conflict among the DLLs.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q34. can we put a break statement in a finally block?&lt;/b&gt;&lt;br /&gt;Ans. The finally block cannot have the break, continue, return and goto statements.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q35. What is a CompositeControl in .NET?&lt;/b&gt;&lt;br /&gt;Ans. CompositeControl is an abstract class in .NET that is inherited by those web controls that contain child controls within them.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q36. Which control in asp.net is used to display data from an xml file and then displayed using XSLT?&lt;/b&gt;&lt;br /&gt;Ans. Use the asp:Xml control and set its DocumentSource property for associating an xml file, and set its TransformSource property to set the xml control's xsl file for the XSLT transformation.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q37. Can we run ASP.NET 1.1 application and ASP.NET 2.0 application on the same computer?&lt;/b&gt;&lt;br /&gt;Ans. Yes, though changes in the IIS in the properties for the site have to be made during deployment of each.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q38. What are the new features in .NET 2.0?&lt;/b&gt;&lt;br /&gt;Ans. Plenty of new controls, Generics, anonymous methods, partial classes, iterators, property visibility (separate visibility for get and set) and static classes.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q39. Can we pop a MessageBox in a web application?&lt;/b&gt;&lt;br /&gt;Ans. Yes, though this is done clientside using an alert, prompt or confirm or by opening a new web page that looks like a message box.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q40. What is managed data?&lt;/b&gt;&lt;br /&gt;Ans. The data for which the memory management is taken care by .Net runtime’s garbage collector, and this includes tasks for allocation de-allocation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-74349638370372792?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/74349638370372792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=74349638370372792' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/74349638370372792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/74349638370372792'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/part-2.html' title='Part 2'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-1053547973131351365</id><published>2008-04-17T00:25:00.000-07:00</published><updated>2008-04-17T00:28:29.787-07:00</updated><title type='text'>ASP.NET INTERVIEW QUESTIONS WITH ANSWER</title><content type='html'>&lt;p class="a"&gt;&lt;b&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Q1. Explain the differences between Server-side and Client-side code? &lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;br /&gt;Ans. Server side code will execute at server (where the website is hosted) end, &amp;amp; all the business logic will execute at server end where as client side code will execute at client side (usually written in javascript, vbscript, jscript) at browser end.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q2. What type of code (server or client) is found in a Code-Behind class? &lt;/b&gt;&lt;br /&gt;Ans. Server side code.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q3. How to make sure that value is entered in an asp:Textbox control?&lt;/b&gt;&lt;br /&gt;Ans. Use a RequiredFieldValidator control.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q4. Which property of a validation control is used to associate it with a server control on that page?&lt;/b&gt;&lt;br /&gt;Ans. ControlToValidate property.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q5. How would you implement inheritance using VB.NET &amp;amp; C#? &lt;/b&gt;&lt;br /&gt;Ans. C# Derived Class : Baseclass&lt;br /&gt;VB.NEt : Derived Class Inherits Baseclass&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q6. Which method is invoked on the DataAdapter control to load the generated dataset with data?&lt;/b&gt;&lt;br /&gt;Ans. Fill() method.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q7. What method is used to explicitly kill a user's session? &lt;/b&gt;&lt;br /&gt;Ans. Session.Abandon()&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q8. What property within the asp:gridview control is changed to bind columns manually? &lt;/b&gt;&lt;br /&gt;Ans. Autogenerated columns is set to false&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q9. Which method is used to redirect the user to another page without performing a round trip to the client?&lt;/b&gt;&lt;br /&gt;Ans. Server.Transfer method.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q10. How do we use different versions of private assemblies in same application without re-build? &lt;/b&gt;&lt;br /&gt;Ans.Inside the Assemblyinfo.cs or Assemblyinfo.vb file, we need to specify assembly version.&lt;br /&gt;assembly: AssemblyVersion&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q11. Is it possible to debug java-script in .NET IDE? If yes, how? &lt;/b&gt;&lt;br /&gt;Ans. Yes, simply write "debugger" statement at the point where the breakpoint needs to be set within the javascript code and also enable javascript debugging in the browser property settings.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q12. How many ways can we maintain the state of a page? &lt;/b&gt;&lt;br /&gt;Ans. 1. Client Side - Query string, hidden variables, viewstate, cookies&lt;br /&gt;2. Server side - application , cache, context, session, database&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q13. What is the use of a multicast delegate? &lt;/b&gt;&lt;br /&gt;Ans. A multicast delegate may be used to call more than one method.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q14. What is the use of a private constructor? &lt;/b&gt;&lt;br /&gt;Ans. A private constructor may be used to prevent the creation of an instance for a class.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q15. What is the use of Singleton pattern? &lt;/b&gt;&lt;br /&gt;Ans. A Singleton pattern .is used to make sure that only one instance of a class exists.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q16. When do we use a DOM parser and when do we use a SAX parser?&lt;/b&gt;&lt;br /&gt;Ans. The DOM Approach is useful for small documents in which the program needs to process a large portion of the document whereas the SAX approach is useful for large documents in which the program only needs to process a small portion of the document.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q17. Will the finally block be executed if an exception has not occurred?&lt;/b&gt;&lt;br /&gt;Ans.Yes it will execute.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q18. What is a Dataset?&lt;/b&gt;&lt;br /&gt;Ans. A dataset is an in memory database kindof object that can hold database information in a disconnected environment.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q19. Is XML a case-sensitive markup language? &lt;/b&gt;&lt;br /&gt;Ans. Yes.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q20. What is an .ashx file?&lt;/b&gt;&lt;br /&gt;Ans. It is a web handler file that produces output to be consumed by an xml consumer client (rather than a browser). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-1053547973131351365?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/1053547973131351365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=1053547973131351365' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/1053547973131351365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/1053547973131351365'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/aspnet-interview-questions-with-answer.html' title='ASP.NET INTERVIEW QUESTIONS WITH ANSWER'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-2689208818010055124</id><published>2008-04-16T22:52:00.000-07:00</published><updated>2008-04-16T22:53:07.497-07:00</updated><title type='text'>Sample ASP.NET AJAX Application</title><content type='html'>&lt;form&gt;  &lt;h1&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Sample ASP.NET &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:City&gt; Application&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h1&gt;  &lt;h2&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Introduction&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;This tutorial creates a basic sample application that uses features of Microsoft ASP.NET AJAX. You can read more about what ASP.NET AJAX is, what technical issues it is designed to solve, and what its important components are in the following introductory ASP.NET AJAX documents:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.25in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;In this tutorial you will build an application that displays pages of employee data from the Adventure Works sample database. The application uses the &lt;span class="nolink"&gt;UpdatePane&lt;/span&gt;l control to refresh only the part of the page that has changed, without the page flash that occurs with a postback. This is referred to as a partial-page update. The sample application also uses the UpdateProgress control to display a status message while the partial-page update is processing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;You can see the code in action in this tutorial by clicking the &lt;span class="ui"&gt;Run It&lt;/span&gt; button. To implement the procedures in your own development environment you need:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Microsoft Visual Studio 2005 or Microsoft Visual Web Developer Express Edition.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;The latest release of Microsoft ASP.NET AJAX installed and configured. For more information, see Installing ASP.NET AJAX.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;An ASP.NET AJAX Web site.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-size: 10pt; font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;The Adventure Works sample database. You can download and install the Adventure Works database from the Microsoft Download Center. (Search for "SQL Server 2005 Samples and Sample Databases (December 2006)").&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Creating an ASP.NET AJAX-Enabled Web Site&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;You can create ASP.NET AJAX-enabled Web sites in Visual Studio by using the template installed with ASP.NET AJAX.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;To create an ASP.NET AJAX-enabled Web Site&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Start Visual Studio.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;In the &lt;span class="ui"&gt;File&lt;/span&gt; menu, click &lt;span class="ui"&gt;New Web Site&lt;/span&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;The &lt;span class="ui"&gt;New Web Site&lt;/span&gt; dialog box is displayed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Under &lt;span class="ui"&gt;Visual Studio installed templates&lt;/span&gt;, select &lt;span class="ui"&gt;ASP.NET AJAX-Enabled Web Site&lt;/span&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;4.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Enter a location and a language, and then click &lt;span class="ui"&gt;OK&lt;/span&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Adding an UpdatePanel Control to an ASP.NET Web Page&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;After you create an AJAX-enabled Web site, you create an ASP.NET Web page that includes an &lt;span class="nolink"&gt;UpdatePane&lt;/span&gt;l control. Before you add an &lt;span class="nolink"&gt;UpdatePane&lt;/span&gt;l control to the page, you must add a ScriptManager control. The &lt;span class="nolink"&gt;UpdatePane&lt;/span&gt;l control relies on the ScriptManager control to manage partial-page updates.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;To create a new ASP.NET Web page&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;In Solution Explorer, right-click the name of the site and then click &lt;span class="ui"&gt;Add New Item&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;The &lt;span class="ui"&gt;Add New Item&lt;/span&gt; dialog box is displayed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Under &lt;span class="ui"&gt;Visual Studio installed templates&lt;/span&gt;, select &lt;span class="ui"&gt;Web Form&lt;/span&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Name the new page Employees.aspx and clear the &lt;span class="ui"&gt;Place code in separate file&lt;/span&gt; check box. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;4.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Select the language you want to use. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;5.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Click &lt;span class="ui"&gt;Add&lt;/span&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;6.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Switch to Design view.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;7.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;In the &lt;span class="ui"&gt;AJAX Extensions&lt;/span&gt; tab of the toolbox, double-click the ScriptManager control to add it to the page.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;8.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Drag an UpdatePanel control from the toolbox and drop it underneath the ScriptManager control.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Adding Content to an UpdatePanel Control&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;The UpdatePanel control performs partial-page updates and identifies content that is updated independently of the rest of the page. In this part of the tutorial, you will add a data-bound control that displays data from the AdventureWorks database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;To add content to an UpdatePanel control&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;From the &lt;span class="ui"&gt;Data&lt;/span&gt; tab of the toolbox, drag a GridView control into the editable area of the UpdatePanel control.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;In the &lt;span class="ui"&gt;GridView Tasks&lt;/span&gt; menu, click &lt;span class="ui"&gt;Auto Format&lt;/span&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;In the &lt;span class="ui"&gt;Auto Format&lt;/span&gt; panel, under &lt;span class="ui"&gt;Select a scheme&lt;/span&gt;, select &lt;span class="ui"&gt;Colorful&lt;/span&gt; and then click &lt;span class="ui"&gt;OK&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;4.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;In the &lt;span class="ui"&gt;GridView Tasks&lt;/span&gt; menu, select &lt;span class="ui"&gt;&lt;new&gt;&lt;/span&gt; from the &lt;span class="ui"&gt;Choose Data Source&lt;/span&gt; list.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;The&lt;span class="ui"&gt; Data Source Configuration&lt;/span&gt; wizard is displayed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;5.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Under &lt;span class="ui"&gt;Where will the application get data from&lt;/span&gt;, select &lt;span class="ui"&gt;Database&lt;/span&gt; and then click &lt;span class="ui"&gt;OK&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;6.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;In the &lt;span class="ui"&gt;Configure Data Source&lt;/span&gt; wizard, for the &lt;span class="ui"&gt;Choose Your Data Connection&lt;/span&gt; step, configure a connection to the AdventureWorks database and then click &lt;span class="ui"&gt;Next&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;7.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;For the &lt;span class="ui"&gt;Configure the Select Statement&lt;/span&gt; step, select &lt;span class="ui"&gt;Specify a custom SQL statement or stored procedure&lt;/span&gt; and then click &lt;span class="ui"&gt;Next&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;8.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;In the &lt;span class="ui"&gt;SELECT&lt;/span&gt; tab of the &lt;span class="ui"&gt;Define Custom Statement or Stored Procedures&lt;/span&gt; step, enter the following SQL statement:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;pre style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;SELECT FirstName, LastName FROM HumanResources.vEmployee ORDER BY LastName, FirstName&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;9.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Click &lt;span class="ui"&gt;Next&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;10.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Click &lt;span class="ui"&gt;Finish&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;11.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;In the &lt;span class="ui"&gt;GridView Tasks&lt;/span&gt; menu, select the &lt;span class="ui"&gt;Enable paging&lt;/span&gt; check box.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;12.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Save your changes, and then press CTRL+F5 to view the page in a browser. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Notice that there is no page flash when you select different pages of data. This is because the page is not performing a postback and updating the whole page every time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Adding an UpdateProgress Control to the Page&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;The UpdateProgress control displays a status message while new content for an UpdatePanel control is being requested. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;To add an UpdateProgress control to the page&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;From the &lt;span class="ui"&gt;AJAX Extensions&lt;/span&gt; tab of the toolbox, drag an UpdateProgress control onto the page and drop it underneath the UpdatePanel control. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Select the UpdateProgress control, and in the Properties window, set the &lt;span class="nolink"&gt;AssociatedUpdatePanelID&lt;/span&gt; property to &lt;span class="input"&gt;UpdatePanel1.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;This associates the UpdateProgress control with the Update Panel control that you added previously.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;In the editable area of the UpdateProgress control, type &lt;span class="input"&gt;Getting Employees ... .&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;4.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Save your changes, and then press CTRL+F5 to view the page in a browser. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;If there is a delay while the page runs the SQL query and returns the data, the UpdateProgress control displays the message that you entered into the UpdateProgress control.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Adding a Delay to the Sample Application&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;  &lt;p&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;If your application updates each page of data quickly, you might not see the content of the UpdateProgress control on the page. The UpdateProgress control supports a Display After property that enables you to set a delay before the control is displayed. This prevents the control from flashing in the browser if the update occurs very fast. By default, the delay is set to 500 milliseconds (.5 second), meaning that the UpdateProgress control will not be displayed if the update takes less than half a second.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;In a development environment, you can add an artificial delay to your application to make sure that the UpdateProgress control is functioning as intended. This is an optional step and is only for testing your application.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h3&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;To add a delay to the sample application&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;1.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Inside the Update Panel control, select the GridView control. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;2.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;In the Properties window, click the &lt;span class="ui"&gt;Events&lt;/span&gt; button. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;3.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Double-click the PageIndexChanged event to create an event handler.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;4.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Add the following code to the PageIndexChanged event handler to artificially create a three-second delay:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h4 style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;CS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h4&gt;  &lt;pre style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;//Include three second delay for example only.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;System.Threading.Thread.Sleep(3000);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;  &lt;h4 style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;VB&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h4&gt;  &lt;pre style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;'Include three second delay for example only.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;System.Threading.Thread.Sleep(3000)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in;"&gt;&lt;strong&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;note&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;The handler for the PageIndexChanged event intentionally introduces a delay for this tutorial. In practice, you would not introduce a delay. Instead, the delay would be the result of server traffic or of server code that takes a long time to process, such as a long-running database query.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style=""&gt;5.&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Save your changes, and then press CTRL+F5 to view the page in a browser. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in;"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Because there is now a three-second delay every time that you move to a new page of data, you will be able to see the UpdateProgress control.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;span style="display: none;"&gt;&lt;input name="__EVENTVALIDATION" value="/wEWBAKH6vWGCwKz5ZDUBgKOis67CgL5irK7Cro5jXjtetXtIkLr/LjFU4BCAw9c" type="hidden"&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;/form&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-2689208818010055124?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/2689208818010055124/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=2689208818010055124' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/2689208818010055124'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/2689208818010055124'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/04/sample-aspnet-ajax-application.html' title='Sample ASP.NET AJAX Application'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-3756085751979913858</id><published>2008-02-26T21:25:00.001-08:00</published><updated>2008-02-26T21:25:46.170-08:00</updated><title type='text'>Convert DOCX files to DOC (and PPTX files to PPT)</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;a href="http://www.greghughes.net/rant/ConvertDOCXFilesToDOCAndPPTXFilesToPPT.aspx"&gt;Convert DOCX files to DOC (and PPTX files to PPT)&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Clear has created a useful service for people who receive Office 2007 Word documents (.docx) and PowerPoint files (.pptx). His service allows you to upload the docx/pptx file to his web server, where the system he has put together will convert the Office 2007 files to classic Office 2003/XP/2000/97/etc. style files (of the .doc and .ppt form).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;The services are called, appropriately, &lt;a href="http://www.docx2doc.com/" target="_blank"&gt;DOCX2DOC&lt;/a&gt; and &lt;a href="http://www.pptx2ppt.com/" target="_blank"&gt;PPTX2PPT.&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;While I suppose one could argue that providing a service that enables you to go backward from a strict technology standpoint is Not A Good Thing&lt;sup&gt; TM&lt;/sup&gt;, there is a market out there for people who:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol style="margin-top: 0in;" start="1" type="1"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Don't have Office      2007. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Don't want to (or      can't) install the respective Office viewers. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Don't want to (or      can't) ask the original sender to convert the file and resend it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;So, for those people this is an interesting service.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;The creator has automated the conversion process and made it possible to do the transformations online in much the same way Office 2007 allows you to do save-As and then choose the legacy formats. The service is offered on the honor system: If you use it, you're asked to pay $2 on the page where you download your converted file. Running a system like this costs money, and while on the order of 600 people a day have converted files in the week or so the service has been online, only a very, very small handful (less than you can count on one hand) have paid. If you read this and use the service I certainly hope you'll add to the paid-user count.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;The process is rather simple from the end-user standpoint. Browse to the service web page for .DOCX or. PPTX files, browse to find the file on your computer that you wish to convert, choose the output format you prefer (you can choose from the legacy office formats, as well as .RTF, .TXT and .HTM), and then click the resulting hyperlink to download your converted file. It's pretty slick.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Being the security wonk I am, my antennae immediately went up as I thought of business users uploading potentially sensitive documents to the system, where they have to be stored in both the original and converted form for at least some period of time in order for a system like this to work. Clear responded by saying that he agrees, and that he &lt;a href="http://www.docx2doc.com/AboutUs.aspx" target="_blank"&gt;warns people on the web site&lt;/a&gt; not to upload private, confidential or sensitive files. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;His system appears to be well-secured (I did some quick checking and there is no way to browse for files without knowing the actual filenames) and while the file-naming and identification convention is strong (it uses filenames built up with a date-time value plus a randomly generated GUID, so you have to know the unique and random name in order to access any given file), the ultimate risk on a system like this is the guy who runs it. The files are cleaned up (deleted) from the system automatically every day. But, he says one should realize that since he controls the system, he has the ability to view any and all files up until the time they are automatically deleted. In other words, he's the biggest risk. I like the honesty in that statement. I asked him if the original and converted files could be deleted more often than once a day, and he said they could be and that he would consider doing so.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;If you have a need to convert and don't have Office 2007 handy, this might be the right service for you.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;Some technical details about how it works are available at: &lt;a href="http://www.docx2doc.com/Newbies-Guide-To-docx.aspx" title="http://www.docx2doc.com/Newbies-Guide-To-docx.aspx"&gt;http://www.docx2doc.com/Newbies-Guide-To-docx.aspx&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Palatino Linotype&amp;quot;;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-3756085751979913858?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/3756085751979913858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=3756085751979913858' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/3756085751979913858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/3756085751979913858'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/02/convert-docx-files-to-doc-and-pptx.html' title='Convert DOCX files to DOC (and PPTX files to PPT)'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-5487931751480720987</id><published>2008-02-06T22:46:00.000-08:00</published><updated>2008-02-26T19:20:45.173-08:00</updated><title type='text'>Overview of Common AJAX Techniques</title><content type='html'>&lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Technique 1 - Server-centric &lt;st1:city st="on"&gt;AJAX&lt;/st1:city&gt; Containers (ASP.NET &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; UpdatePanel)&lt;/span&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;The server-centric &lt;st1:city st="on"&gt;AJAX&lt;/st1:city&gt; container technique is employed by the ASP.NET AJAX UpdatePanel control as well as several &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; solutions sold by the leading 3rd party control vendors. UpdatePanels are driven entirely by ASP.NET postbacks. &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; applications are created by wrapping postback-based ASP.NET portions of the page and specifying which triggers (server-side events) will cause certain page areas to re-render. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;  &lt;v:stroke joinstyle="miter"&gt;  &lt;v:formulas&gt;   &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;   &lt;v:f eqn="sum @0 1 0"&gt;   &lt;v:f eqn="sum 0 0 @1"&gt;   &lt;v:f eqn="prod @2 1 2"&gt;   &lt;v:f eqn="prod @3 21600 pixelWidth"&gt;   &lt;v:f eqn="prod @3 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @0 0 1"&gt;   &lt;v:f eqn="prod @6 1 2"&gt;   &lt;v:f eqn="prod @7 21600 pixelWidth"&gt;   &lt;v:f eqn="sum @8 21600 0"&gt;   &lt;v:f eqn="prod @7 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @10 21600 0"&gt;  &lt;/v:formulas&gt;  &lt;v:path extrusionok="f" gradientshapeok="t" connecttype="rect"&gt;  &lt;o:lock ext="edit" aspectratio="t"&gt; &lt;/v:shapetype&gt;&lt;v:shape id="_x0000_i1025" type="#_x0000_t75" alt="" style="'width:487.5pt;"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\VIJAY\LOCALS~1\Temp\msohtml1\01\clip_image001.png" href="http://aspalliance.com/ArticleFiles/1582/Diagram1.png"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;br /&gt;&lt;!--[endif]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Ease of use&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: The most obvious advantage of this approach is that it is extremely easy to implement. It is really not much harder than building a vanilla postback-based ASP.NET application and then wrapping certain areas of the page with UpdatePanels. This approach is ideal for quickly adding &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; features to existing ASP.NET applications. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Performance&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: The biggest downside of this approach is performance. UpdatePanels always post the entire page - including full viewstate - to the server. Even though the required &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; update to the page is often minimal, its server-side page processing essentially takes the same resources as when doing a full postback. The response sends raw HTML back to the browser, adding kilobytes to the required network traffic to process the &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; request. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Elegance&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: The server-centric &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; container technique is fairly elegant from the implementation point of view. Page areas are cleanly wrapped by UpdatePanel instances and &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; updates are accomplished by mapping server-side events to triggers. All &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; magic is performed by the UpdatePanel control itself. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Features&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: All features exposed to the developer using the UpdatePanel control are entirely on the server side. The control was not designed to be driven by client-side logic. The server-centric approach lacks the finer level of control on the client, which is definitely needed to build sophisticated &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; apps with hyper-responsive user interfaces.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;st1:city st="on"&gt;&lt;span style=";font-family:&amp;quot;;" &gt;AJAX&lt;/span&gt;&lt;/st1:city&gt;&lt;span style=";font-family:&amp;quot;;" &gt; Explorer Example: &lt;a href="http://www.componentart.com/entry.aspx?id=121&amp;amp;page=/webui/demos/ajax/technique1/"&gt;&lt;b&gt;Technique 1 - Server-centric AJAX Containers (ASP.NET AJAX UpdatePanel)&lt;/b&gt;&lt;/a&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Technique 2 - Client-centric &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; Containers (ComponentArt CallBack)&lt;/span&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;ComponentArt CallBack is similar to the UpdatePanel control in its high-level concept of acting as a generic &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; container for ASP.NET content. Both controls allow rendering custom ASP.NET content (including server controls, user controls as well as literal content) through &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; callbacks - without reloading the entire page. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;However, ComponentArt CallBack is driven entirely by its client-side API. Developers specify exactly when a callback will be triggered and exactly which parameters will be sent to the server (CallBack doesn't post the page by default). This triggers a server-side event, where the developer has full control over what will be rendered back to the client. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1026" type="#_x0000_t75" alt="" style="'width:487.5pt;height:251.25pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\VIJAY\LOCALS~1\Temp\msohtml1\01\clip_image003.png" href="http://aspalliance.com/ArticleFiles/1582/Diagram2.png"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;br /&gt;&lt;!--[endif]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Ease of use: ComponentArt CallBack is not as easy to use as the UpdatePanel control. It requires JavaScript code to initiate the callback request through the control's client-side API as well as implementing a server-side event handler to render content back to the browser. In most cases this amounts to just a few lines of code on the client and the same amount on the server. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Performance&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: Requests made through the CallBack control are extremely lightweight in terms of network traffic. However, each request has to go through the full page life cycle and the response typically generates HTML and sends it back to the browser. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Elegance&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: The CallBack control hooks into the page life cycle and exposes the native ASP.NET object for rendering (HtmlTextWriter) to the developer. While the developer needs to write custom code both on the server and the client to perform an &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; request, the level of control that is gained makes it worthwhile in most cases.  &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Features&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: The client-centric &lt;st1:city st="on"&gt;AJAX&lt;/st1:city&gt; approach exposes more capabilities to rich web applications with highly-responsive user interfaces because all &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; request decision-making logic resides within the client-side event-driven code. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;st1:city st="on"&gt;&lt;span style=";font-family:&amp;quot;;" &gt;AJAX&lt;/span&gt;&lt;/st1:city&gt;&lt;span style=";font-family:&amp;quot;;" &gt; Explorer Example: &lt;a href="http://www.componentart.com/entry.aspx?id=121&amp;amp;page=/webui/demos/ajax/technique2/"&gt;&lt;b&gt;Technique 2 - Client-centric AJAX Containers (ComponentArt CallBack)&lt;/b&gt;&lt;/a&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Technique 3 - Manual JavaScript Coding Against Server-side Logic (Ajax.NET, ASP.NET 3.5 Script Services)&lt;/span&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;The previous two techniques revolve around the ASP.NET page model and are essentially delivered as ASP.NET server controls. In contrast with these techniques is a pure JavaScript approach originally introduced by Michael Schwarz with his Ajax.NET library. The core idea is to provide a way to mark methods of any server-side class with the "[AjaxMethod]" attribute and then be able to invoke that method from client-side code. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;A similar technique is available with ASP.NET AJAX/3.5, which makes it incredibly easy to expose a web service and invoke it directly from client-side code. Significant performance improvements of this approach over the previous two are probably the main reason for its incredible popularity within the development community.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1027" type="#_x0000_t75" alt="" style="'width:487.5pt;height:251.25pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\VIJAY\LOCALS~1\Temp\msohtml1\01\clip_image005.png" href="http://aspalliance.com/ArticleFiles/1582/Diagram3.png"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;br /&gt;&lt;!--[endif]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Ease of use&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: Invoking server-side logic on the client is easy with Ajax.NET / ASP.NET 3.5. However, this solution assumes quite a bit of manual JavaScript coding in order to generate and update user interface elements of the page. This is why it doesn't get high marks in the "ease of use" category. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Performance&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: There are two important performance breakthroughs of this approach: 1) Since methods of any class can be invoked through client-side code, the server-side request processing doesn't need to go through the ASP.NET page life cycle. The client-side request hits exactly the method it needs and it receives exactly the response it needs. There is no waste of server resources. 2) The response doesn't contain HTML markup. Rather, it contains only the data requested by the client. This can reduce the network traffic required to process the &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; request by an order of magnitude. The received data is used on the client side to generate or update user interface elements. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Elegance&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: All functionality included with Ajax.NET or ASP.NET 3.5 Script Services is well architected. However, the overall solution is missing a piece of the &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; puzzle and this is the reason why this approach loses points in the "elegance" category. The fact that developers are stuck with generating the user interface layer leaves the application with quite a bit of JavaScript code to maintain. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Features&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: The Ajax.NET library as well as ASP.NET 3.5 Script Services are loaded with client-side features. They contain the ability to easily invoke server-side logic as well as serialize .NET objects to their JSON representations. They don't, however, have the ability to manipulate high level UI elements (menus, treeviews, grids, etc.). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;&lt;b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;AJAX&lt;/span&gt;&lt;/b&gt;&lt;/st1:place&gt;&lt;/st1:city&gt;&lt;b&gt;&lt;span style=";font-family:&amp;quot;;" &gt; 2.0 - Client-side Controls Invoking Web Services&lt;/span&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;The new &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; approach builds on best performance practises presented in the previous technique: efficiently executing server-side logic by invoking ASP.NET 3.5 web services and only sending data over the network. However, instead of requiring manual JavaScript coding to create and manipulate user interface elements, this functionality is now built into ComponentArt Web.UI client controls. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1028" type="#_x0000_t75" alt="" style="'width:487.5pt;height:251.25pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\VIJAY\LOCALS~1\Temp\msohtml1\01\clip_image007.png" href="http://aspalliance.com/ArticleFiles/1582/Diagram4.png"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;br /&gt;&lt;!--[endif]--&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Ease of use&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: High-level client controls expose API methods to invoke web services. The structure and content of those controls is automatically populated with the results returned by the web service and the update is immediately visible on the screen. Even though some client-side coding is required to create and maintain user interface elements, it is reduced from many hundreds of lines to just a handful of high-level API calls. Not as easy as using the UpdatePanel control, but pretty close. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Performance&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: As already stated, this approach builds on best performance practises presented in the previous technique. However, the overall performance of an application built with this new approach actually exceeds the previous one. Additional performance improvements come from extensive client-side UI generation optimizations that we've built into the ComponentArt Web.UI suite. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Elegance&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: A high-level description of this technique is simple and powerful: "Objects on the client (client-side controls) communicate directly with objects on the server (web services)". The server-side logic of the application is delivered as a collection of web services - without any preconceived user interface decisions. This produces a real separation of tiers and greater code reuse options. Those web services could potentially be reused by multiple types of applications: mobile, smart client, Silverlight or other ASP.NET apps. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;u&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Features&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;: Not only is &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; request decision-making logic in the same domain as the rest of the app, but it is transparent to it. Updating a portion of the user interface through a fast &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; request is no different than invoking any other client-side API method. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;&lt;span style=";font-family:&amp;quot;;" &gt;AJAX&lt;/span&gt;&lt;/st1:place&gt;&lt;/st1:city&gt;&lt;span style=";font-family:&amp;quot;;" &gt; Explorer Example: &lt;a href="http://www.componentart.com/entry.aspx?id=121&amp;amp;page=/webui/demos/ajax/technique4/"&gt;&lt;b&gt;Technique 4 - Client Controls Invoking Web Services&lt;/b&gt;&lt;/a&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;Summary&lt;/span&gt;&lt;/b&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;The new &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; technique presented here is an evolution of the previously available techniques, rather than a radical departure from them. It builds on the strengths of &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;AJAX&lt;/st1:place&gt;&lt;/st1:city&gt; best practises, while introducing something new: full fledged client-side controls capable of communicating directly with web services. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;It's important to note that there is no clear winner for all application scenarios. All of these techniques deserve consideration, depending on the specific situation. For example, ASP.NET AJAX UpdatePanels might end up being chosen for apps that run on fast internal networks. Client-controls invoking web services are a great option for high-performance apps with rich and responsive user interfaces. Mixing various techniques within the same application is also a perfectly viable strategy. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-5487931751480720987?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/5487931751480720987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=5487931751480720987' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/5487931751480720987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/5487931751480720987'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/02/overview-of-common-ajax-techniques.html' title='Overview of Common AJAX Techniques'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-7824978610278409701</id><published>2008-02-06T22:44:00.000-08:00</published><updated>2008-02-06T22:45:56.486-08:00</updated><title type='text'>Selecting nth Highest Value of a Column Using Oracle</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Introduction &lt;/span&gt;&lt;br /&gt;This code snippet will allow the viewer to select the nth highest value of a column from any table in Oracle database. This article also deals with the other possible methods of selection along with the risks involved in using them.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Requirements&lt;/span&gt;&lt;br /&gt;Oracle 9i or above versions&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Working&lt;/span&gt;&lt;br /&gt;In order to find nth maximum record of EMPLOYEE_ID column, the query in listing 1 first does a self-join on itself in the sub query.&lt;br /&gt;Listing 1&lt;br /&gt;select EMPLOYEE_ID from emp a where n=&lt;br /&gt;(select count(*) from emp b where a.EMPLOYEE_ID &lt;= b.EMPLOYEE_ID);&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Explanation&lt;/span&gt;&lt;br /&gt;There each EMPLOYEE_ID is compared with all the EMPLOYEE_IDs including itself to return the count =n for that EMPLOYEE_ID which is n times less than or equal to all the EMPLOYEE_IDs present including itself.&lt;br /&gt;Let me explain with the following example.&lt;br /&gt;Say we have a table having two fields like name and ID as follows.&lt;br /&gt;       ID    N&lt;br /&gt;     ---------- -&lt;br /&gt;        1    D&lt;br /&gt;        2    E&lt;br /&gt;        3    F&lt;br /&gt;        4    P&lt;br /&gt;Now say we need to find the 2nd max id from the table, which is 3 in this case.&lt;br /&gt;Our query compares each id with all the other ids including itself to find which id is twice less than or equal to as compared to others.&lt;br /&gt;And only id 3 is twice less than or equal to as compared to all the other records (i.e. 3 &lt;=3 and 3&lt;=4 making the count=2).&lt;br /&gt;Validation for Listing 1 through querying emp table&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Listing 2&lt;/span&gt;&lt;br /&gt;select EMPLOYEE_ID from emp a where 2=(&lt;br /&gt;select count (*) from emp b where a.EMPLOYEE_ID &lt;= b.EMPLOYEE_ID);&lt;br /&gt;Figure 1&lt;br /&gt;&lt;br /&gt;Now let us find another solution.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Listing 3&lt;/span&gt;&lt;br /&gt;Select EMPLOYEE_ID FROM (SELECT EMPLOYEE_ID ,RANK() OVER&lt;br /&gt;(ORDER BY EMPLOYEE_ID DESC) DEPTRANK FROM emp) WHERE DEPTRANK=n;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Explanation&lt;/span&gt;&lt;br /&gt;This fetches the nth highest record through a table.&lt;br /&gt;The sub query does a vital role here in ranking the EMPLOYEE_ID column in descending manner.&lt;br /&gt;The major functionality is achieved by rank () over () function.&lt;br /&gt;It arranges the EMPLOYEE_ID column in descending order and does a ranking beginning from highest value. Such that highest EMPLOYEE_ID gets rank 1, the 2nd highest EMPLOYEE_ID gets rank 2 so on.&lt;br /&gt;The following example illustrates the out come of sub query used.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Listing 4&lt;/span&gt;&lt;br /&gt;SELECT EMPLOYEE_ID, RANK () OVER (ORDER BY EMPLOYEE_ID DESC) DEPTRANK FROM emp;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Figure 2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then it is the responsibility of the outer query to select the nth highest record.&lt;br /&gt;Validation for Listing 3 through querying emp table&lt;br /&gt;Listing 5&lt;br /&gt;SELECT EMPLOYEE_ID FROM (SELECT EMPLOYEE_ID, RANK () OVER&lt;br /&gt;(ORDER BY EMPLOYEE_ID DESC) DEPTRANK FROM emp ) WHERE DEPTRANK=2;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Figure 3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Both the methods explained above are well and good. The first one does not use any oracle function. Where it is explicitly asked not to use any functions this approach can be followed.&lt;br /&gt;But the second approach does the same through RANK () OVER () function. Many other useful facts about the RANK () OVER () function can be revealed by exploring it more.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-7824978610278409701?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/7824978610278409701/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=7824978610278409701' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/7824978610278409701'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/7824978610278409701'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/02/selecting-nth-highest-value-of-column.html' title='Selecting nth Highest Value of a Column Using Oracle'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-8818522269247823920</id><published>2008-01-11T23:46:00.000-08:00</published><updated>2008-01-11T23:49:03.142-08:00</updated><title type='text'>Web.Config file</title><content type='html'>Web.Config file &lt;br /&gt;Web.config is a configuration file for the Asp .net web application. Asp.net application has one web.config file which keeps the configurations required for the corresponding application.It is also possible that there should be more then on configuration file but different for diffrent folder. Web.config file is written in XML with specific tags having specific meanings.Machine.config file is used to configure the application in a particular machine.That is to be , configuration done in machine.config file is affected on any application that runs on a particular machine. Usually, this file is not altered and only web.config is used which configuring application.There should be only one Machine.config file in System.Now question arise what it had and how it helps:- &lt;br /&gt;There are number of important settings that can be stored in the configuration file. Here are some of the most of thenm in configurations, stored inside Web.config file.&lt;br /&gt;• Database connections&lt;br /&gt;• Session States&lt;br /&gt;• Error Handling&lt;br /&gt;• Trace&lt;br /&gt;• Security &lt;br /&gt;• Globalization&lt;br /&gt;Database Connections:-Data that can be stored inside the web.config file is the database connection string. Storing the connection string in the web.config file makes sense, this help u when u wanna made any modification to database can have to change only on sigle place.nor u will to keep it either as a class level variable in all associated source files or probably keep it in another class as a public static variable.But if this is stored in the Web.config file,it can be used anywhere in the program. This will certainly save us a lot of alteration in different files where we used the old connection.here is a small example of the connection string which is stored in the web.config file.&lt;br /&gt;&lt;configuration&gt;&lt;br /&gt;&lt;appSettings&gt;&lt;br /&gt;&lt;add key="conn" value="server=servername;uid=uid;pwd=pass;database=database" /&gt;&lt;br /&gt;&lt;/appSettings&gt;&lt;br /&gt;&lt;/configuration&gt;&lt;br /&gt;it is very simple to store the connection string in the web.config file.The connection string is referenced by a key which in this case is "Connstring". The value attribute of the configuration file denotes the information about the database. Here we get the database name, userid and password and the server name.we can aslo use this for any other information that we not to show the user.now question how to access the connection string from our Asp .net web application. &lt;br /&gt;using System.Configuration;&lt;br /&gt;string connectionString = (string )ConfigurationSettings.AppSettings["conn"]; &lt;br /&gt;Session States:-Session in Asp .net web application is very important. Becasue HTTP is a stateless protocol and we needs session to keep the state alive. Asp .net stores the sessions in different ways. By default the session is stored in the asp .net process.You can always configure the application so that the session will be stored in one of the way.&lt;br /&gt;1) Session State Service:- The state service is not running in the same process the asp .net application. So even the asp.net application application crashes the sessions will not be destroyed. Any advantage is sharing the state information across a Web garden (Multiple processors for the same computer).Here is example of Session State Service.&lt;br /&gt;&lt;sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:55455" sqlConnectionString="data source=127.0.0.1;user id=;password=''' cookieless="false" timeout="20"/&gt;&lt;br /&gt;(2)Sql Server:-The Second choice for session information is to use Sql Server 2000 database. For using Sql Server to storing session state we require the following operation to be held: we have to Run the InstallSqlState.sql script on the Microsoft SQL Server to store the session.&lt;br /&gt;&lt;sessionState mode = "SqlServer" stateConnectionString="tcpip=127.0.0.1:45565" sqlConnectionString="data source="SERVERNAME;user id='';password='' cookiesless="false" timeout="20"/&gt; &lt;br /&gt;SQL Server help us to share session state among the processors in a Web garden or the servers in a Web farm. we also get extra space to store the session. The SQL Server is slow as comparision to session in the state inproc mode.But one advantage is we can do anything with the session becuse it is in database now.&lt;br /&gt;(3) InProc:-That is default Session State. one of the advantage of inproc session state is the applications will run faster as compare to other Session state types. But the disadvantage is Sessionsare not stored when there if problem occurs in the application, Also there could be frequent loss of session data experienced.&lt;br /&gt;&lt;br /&gt;Error Handling:-Its play a major role in the application realtes to error management. Each error has to be caught and suitable action has to be taken to resolve that problem. Asp.net web.config filelets us configure, what to do when an error occurs in our application.Check the following xml tag in the web.config file that deals with errors:&lt;br /&gt;&lt;customErrors mode = "On"&gt;&lt;br /&gt;&lt;error statusCode = "404" redirect = "errorPage.aspx" /&gt;&lt;br /&gt;&lt;/customErrors&gt;&lt;br /&gt;when we use mode=on this will show the error to remote client too that is errorpage.aspx other mode of customerrors is off it helps us when we not wanna show any error description to remote clientand show a default error msg to remote client.&lt;br /&gt;Trace:-If tracing is enabled in the web.config file (set enabled="true" pageOutput="true") detailed information about the life of the page will be displayed at the end of every page. This can be helpful for debugging. If you set pageOutput="false" a trace.axd file will be creating in your applications root folder and trace information will be stored there. If pageOutputis set to false, the requestLimit attribute will designate the number of requests to write to the page log. Setting localonly="true" will allow you to view the trace file from a remote computer. Tracemode has two valid values: SortByTimeand SortByCategory. These define how the trace information should be displayed.&lt;br /&gt;&lt;trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" /&gt;&lt;br /&gt;&lt;br /&gt;Security:- The most admireable aspect of any application is security question arise how to handle this and what the method to handle this there are four method of security.&lt;br /&gt;(1) No Authentication: As the name suggest No Authentication , meaning that Asp.net there will no implementation of security.&lt;br /&gt;(2) Windows Authentication: Windows authentication allows us to use the windows user accounts means authenticate the user against the user name password relates to window means login name and password . &lt;br /&gt;(i)Basic &lt;br /&gt;(ii)integrated&lt;br /&gt;(iii)Diggest &lt;br /&gt;User.Identity.Name;This returns the DOMAIN\UserName of the current user of the local machine.&lt;br /&gt;(3) Passport Authentication:Passport Authentication provider uses Microsoft's Passport service to authenticate users. You need to purchase this service in order to use it.&lt;br /&gt;(4)Forms Authentication:-Forms Authentication uses HTML forms to collect the user information and than it takes required actions on those HTML collected values.In order to use Forms Authentication you must set the Anonymous Access checkbox checked. Now we need that whenever user tries to run theapplication he will be redirected to the login page.&lt;br /&gt;&lt;authentication mode="Forms"&gt;&lt;br /&gt;&lt;forms loginUrl = "Login.aspx" name="gitesh" timeout="1"/&gt;&lt;br /&gt;&lt;/authentication&gt;&lt;br /&gt;&lt;authorization&gt;&lt;br /&gt;&lt;deny users="?" /&gt;&lt;br /&gt;&lt;/authorization&gt;&lt;br /&gt;we have to set Authentication mode to "Forms". The forms loginUrl is the first page being displayed when the application is run by any user.The authorization tags has the deny users element which contains "?", this means that full access will be given to the authenticated users and none access will be given to the unauthenticated users. You can replace "?" with "*" meaning that all access is given to all the users no matter what.But when session is expired it will automatically redirect user to login page . Form authentication also helpsto make authentication to all the page of application by usingif(User.identity.isauthenticate)to check wheater user is valid or not.&lt;br /&gt;Globalization:-&lt;br /&gt;&lt;globalization requestEncoding="encoding string" responseEncoding="encoding string" fileEncoding="encoding string"culture="culture string" uiCulture="culture string"/&gt;&lt;br /&gt;requestEncoding:-Default encoding is UTF-8, shown in the tag included in the Machine.config file created when the .NET Framework is installed. If request encoding is not specified in a Machine.config or Web.config file, encoding defaults to the computer's Regional Options locale setting. In single-server applications, requestEncoding and responseEncoding should be the same.&lt;br /&gt;fileEncoding:-Default value for .aspx, .asmx, and .asax file parsing. Unicode and UTF-8 files saved with the byte order mark prefix will be automatically recognized regardless of the value of &lt;br /&gt;fileEncoding.culture:-valid culture strings.&lt;br /&gt;uiCulture:-Specifies the default culture for processing locale-dependent resource searches&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-8818522269247823920?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/8818522269247823920/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=8818522269247823920' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/8818522269247823920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/8818522269247823920'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/01/webconfig-file.html' title='Web.Config file'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-4998172571405634034</id><published>2008-01-09T23:52:00.000-08:00</published><updated>2008-01-09T23:53:24.698-08:00</updated><title type='text'>ASP.NET repeater control - databind with style</title><content type='html'>ASP.NET repeater control - databind with style&lt;br /&gt;Posted by admin under Controls&lt;br /&gt;If I had to name *one* single control as my favorite ASP.NET server control, it would&lt;br /&gt;most probably be the asp:repeater. &lt;br /&gt;When I started ASP.NET programming the datagrid was my best friend - or I wanted it to be - I tried in every way to use it whereever possible. I even used the inline editing features, which I at the time thought was the coolest way possible to write ASP.NET code ( I managed to write code to hide all other rows and only show the current one - the row being edited). With a nicelooking EditTemplate it looked indeed very slick but it really turned into giant and hard to manage code behind files. &lt;br /&gt;Nowadays I always do inserts/editing in its own aspx page.  Listing objects in listfoos.aspx and editing/adding in editfoo.aspx. &lt;br /&gt;So what about the repeater. Well, supporting templates for databound item (my number one feature in a control) - it lets you create your own type of datastructure (with header, footer and rows) but it's up to you how you decide to render it. If you want to render it as a table, fine. Put &lt;table&gt; in header, &lt;/table&gt; in footer and &lt;tr&gt;&lt;td&gt;item data in here&lt;/td&gt;&lt;/tr&gt; in the template. However if you want a &lt;ul&gt;&lt;li&gt;&lt;/li&gt;&lt;/ul&gt; structure instead, fine - put &lt;ul&gt; in header, &lt;/ul&gt; in footer and the actual li items in the ItemTemplate.&lt;br /&gt;Cause the "problem" with the more complicated ASP.NET databound controls such as the grid is just that they are typically tied to render certain html tags. &lt;br /&gt;So, lets create a little demo - let's databind some repeaters to the MSSQL sample database northwind, the table categories:&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;    protected void Page_Load(object sender, EventArgs e) &lt;br /&gt;    { &lt;br /&gt;        if (!IsPostBack) &lt;br /&gt;        { &lt;br /&gt;            rptTable.DataSource = GetTable(); &lt;br /&gt;            rptTable.DataBind(); &lt;br /&gt; &lt;br /&gt;... &lt;br /&gt;... &lt;br /&gt;.. &lt;br /&gt; &lt;br /&gt;And - first lets use a simple table approach:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;asp:Repeater ID="rptTable" runat="server"&gt;&lt;br /&gt;    &lt;HeaderTemplate&gt;&lt;br /&gt;        &lt;table&gt;&lt;br /&gt;    &lt;/HeaderTemplate&gt;&lt;br /&gt;    &lt;ItemTemplate&gt;&lt;br /&gt;        &lt;tr&gt;&lt;td&gt;&lt;br /&gt;        &lt;asp:HyperLink id="hlEdit" runat="server" NavigateUrl="#" Text='&lt;%# DataBinder.Eval(Container.DataItem, "CategoryName") %&gt;'&gt;&lt;br /&gt;        &lt;/asp:HyperLink&gt;&lt;br /&gt;        &lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;    &lt;/ItemTemplate&gt;&lt;br /&gt;    &lt;FooterTemplate&gt;&lt;br /&gt;        &lt;/table&gt;&lt;br /&gt;    &lt;/FooterTemplate&gt;&lt;br /&gt;    &lt;/asp:Repeater&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Not very beautyful, but you get the point:&lt;br /&gt; &lt;br /&gt;But now comes the point. Lets change the repeater template like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;HeaderTemplate&gt;&lt;br /&gt;        &lt;ul&gt;&lt;br /&gt;    &lt;/HeaderTemplate&gt;&lt;br /&gt;    &lt;ItemTemplate&gt;&lt;br /&gt;        &lt;li&gt;&lt;br /&gt;        &lt;asp:HyperLink id="hlEdit" runat="server" NavigateUrl="#" Text='&lt;%# DataBinder.Eval(Container.DataItem, "CategoryName") %&gt;'&gt;&lt;br /&gt;        &lt;/asp:HyperLink&gt;&lt;br /&gt;        &lt;/li&gt;&lt;br /&gt;    &lt;/ItemTemplate&gt;&lt;br /&gt;    &lt;FooterTemplate&gt;&lt;br /&gt;        &lt;/ul&gt;&lt;br /&gt;    &lt;/FooterTemplate&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;and we get a list instead:&lt;br /&gt; &lt;br /&gt;And lists are indeed very good for displaying structured data. The cool thing about it is that you can change the looks completely just by using stylesheet:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;style type="text/css"&gt;&lt;br /&gt;ul#navlist&lt;br /&gt;{&lt;br /&gt;margin-left: 0;&lt;br /&gt;padding-left: 0;&lt;br /&gt;white-space: nowrap;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#navlist li&lt;br /&gt;{&lt;br /&gt;display: inline;&lt;br /&gt;list-style-type: none;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#navlist a { padding: 3px 10px; }&lt;br /&gt;&lt;br /&gt;#navlist a:link, #navlist a:visited&lt;br /&gt;{&lt;br /&gt;color: #fff;&lt;br /&gt;background-color: #036;&lt;br /&gt;text-decoration: none;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#navlist a:hover&lt;br /&gt;{&lt;br /&gt;color: #fff;&lt;br /&gt;background-color: #369;&lt;br /&gt;text-decoration: none;&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt; &lt;/style&gt;&lt;br /&gt;...&lt;br /&gt;...&lt;br /&gt;    &lt;asp:Repeater ID="rptStyle2" runat="server"&gt;&lt;br /&gt;    &lt;HeaderTemplate&gt;&lt;br /&gt;        &lt;div id="navcontainer"&gt;&lt;br /&gt;        &lt;ul id="navlist"&gt;&lt;br /&gt;    &lt;/HeaderTemplate&gt;&lt;br /&gt;    &lt;ItemTemplate&gt;&lt;br /&gt;        &lt;li&gt;&lt;br /&gt;        &lt;asp:HyperLink id="hlEdit" runat="server" NavigateUrl="#" Text='&lt;%# DataBinder.Eval(Container.DataItem, "CategoryName") %&gt;'&gt;&lt;br /&gt;        &lt;/asp:HyperLink&gt;&lt;br /&gt;        &lt;/li&gt;&lt;br /&gt;    &lt;/ItemTemplate&gt;&lt;br /&gt;    &lt;FooterTemplate&gt;&lt;br /&gt;        &lt;/ul&gt;&lt;br /&gt;        &lt;/div&gt;&lt;br /&gt;    &lt;/FooterTemplate&gt;&lt;br /&gt;    &lt;/asp:Repeater&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Now we have a horizontal style list. &lt;br /&gt;My point is - use repeaters instead of the datagrid/gridview. The built in editing features in those controls are simply not worth it, IMHO.  Take control of your rendering - you will have so much more freedom to accomplish what you want.&lt;br /&gt;Note: the CSS style was taken from MaxDesign Listamatic which shows you lots of different CSS styles to apply to lists. But using lists instead of table is not the point in this article - the point is simply : use repeaters instead of grid controls.&lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-4998172571405634034?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/4998172571405634034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=4998172571405634034' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/4998172571405634034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/4998172571405634034'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/01/aspnet-repeater-control-databind-with.html' title='ASP.NET repeater control - databind with style'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-8359407763058002253</id><published>2008-01-09T23:49:00.000-08:00</published><updated>2008-02-13T22:47:45.761-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Creating an RSS feed for your ASP.NET site'/><title type='text'>Creating an RSS feed for your ASP.NET site</title><content type='html'>  &lt;p class="MsoNormal"&gt;&lt;b&gt;Creating an RSS feed for your ASP.NET site&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;How useful a RSS feed actually is is hard for me to say something about, I personally have a hard time understanding the buzz about blogs (why should that be better than a regular website).&lt;br /&gt;&lt;br /&gt;While the content people present in blogs might be really good - I just love &lt;a href="http://weblogs.asp.net/scottgu/"&gt;Scott Guthries blog&lt;/a&gt;, the big problem with blogs (and I mean the actual blog applications) is categorization of data. How fun is it to try t find a specific article - to find you have to browse to the month you believe it was published. While the search engines might have been approved and categorization with Tags is becoming more popular in blog software I still think the actual navigation is pretty lame.&lt;br /&gt;&lt;br /&gt;But for news aggregating - fine, I can buy that idea, RSS has been tightly coupled with blogs but there is no reason as to why you couldn't put up a RSS feed for your (non-blog) site. So, that's what I have decided to do - and will describe for you here.&lt;br /&gt;&lt;br /&gt;First, we are using a ASHX handler - that technique is described in a separate &lt;a href="http://www.aspcode.net/articles/l_en-US/t_default/ASP.NET/Creating-an-ASHX-handler-in-ASP.NET_article_275.aspx"&gt;article&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now lets try to fins out what RSS is about. Basically you (the website owner) should return a RSS feed - and that's simply an XML document following a certain standard, describing new articles on your site.&lt;br /&gt;&lt;br /&gt;Lets have a look on a part of my RSS feed: &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;http://www.aspcode.net/articles/default.aspx &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;Articles about ASP.NET, C# and development with Visual Studio &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;5 &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;http://www.aspcode.net/articles/l_en-US/t_default/ASP.NET/Creating-an-RSS-feed-for-your-ASP.NET-site_article_277.aspx &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;http://www.aspcode.net/articles/l_en-US/t_default/ASP.NET/Creating-an-RSS-feed-for-your-ASP.NET-site_article_277.aspx &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;How useful a RSS feed actually is is hard for me to say something about, I personally have a hard time understanding the buzz about blogs (why should that be better than a regular website). While the content people present in blogs might be really good - ... &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;Wed, 30 Aug 2006 13:00:09 GMT &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;Lets talk a little about the different tags in the XML file.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;title&lt;/b&gt;&lt;br /&gt;The name of the channel. It's how people refer to your service&lt;br /&gt;&lt;b&gt;link&lt;/b&gt;&lt;br /&gt;The url to the website&lt;br /&gt;&lt;b&gt;description&lt;/b&gt;&lt;br /&gt;Phrase or sentence describing the channel&lt;br /&gt;&lt;b&gt;ttl&lt;/b&gt;&lt;br /&gt;It's a number of minutes that indicates how long a channel can be cached before refreshing from the source. So, it's information for the news aggregator/reader program how often it should update it's content from the feed.&lt;br /&gt;&lt;br /&gt;For each item(articles)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;title&lt;/b&gt;&lt;br /&gt;The header of the article&lt;br /&gt;&lt;b&gt;link&lt;/b&gt;&lt;br /&gt;The url of the article&lt;br /&gt;&lt;b&gt;description&lt;/b&gt;&lt;br /&gt;Short description - synopsis&lt;br /&gt;&lt;b&gt;guid&lt;/b&gt;&lt;br /&gt;A string that uniquely identifies each article. Often you have unique page (url) for each article on your website (for example showart.aspx?id=123) so it's most often ok to use the link as guid.&lt;br /&gt;&lt;b&gt;pubDate&lt;/b&gt;&lt;br /&gt;date when the article was published, ex format Sat, 07 Sep 2002 00:00:01 GMT&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This was just a brief overview of what tags you might want to use in your RSS feed, for an extensive explaination, please go to &lt;a href="http://blogs.law.harvard.edu/tech/rss"&gt;RSS 2.0 Specification&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So that's what we are gonna create - when people/programs(news aggregators) access the page rss.ashx the document should be returned as an XML file.&lt;br /&gt;All action takes place in the handlers ProcessRequest &lt;/p&gt;  &lt;p class="MsoNormal"&gt;public void ProcessRequest (HttpContext context)&lt;/p&gt;  &lt;p class="MsoNormal"&gt;{&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;string sTxt = BuildXmlString();&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style=""&gt;    &lt;/span&gt;context.Response.ContentType = "text/xml";&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;context.Response.ContentEncoding = System.Text.Encoding.UTF8;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;context.Response.Write( sTxt );&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;}&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;Well, maybe not so much action there, the building of the XML is done in BuildXmlString &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;private string BuildXmlString()&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;string sTitle = "The title if your blog";&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;string sSiteUrl = "http://www.aspcode.net";&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;string sDescription = "The site is the coolest bla bla and this rss feed is the best!";&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;string sTTL = "60";&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;System.Text.StringBuilder oBuilder = new System.Text.StringBuilder();&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;oBuilder.Append("&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;br /&gt;This builds up the basic structure of the document, with title, description, ttl etc and now we are gonna add the actual articles - thats what happens in AppendItems &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public void AppendItems(System.Text.StringBuilder oBuilder)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;//read from database or whatever and retrieve the 10 latest articles&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;//I have a class, ObjClasses.Article and a collection&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;//ObjClasses.ArticleList which does the retrieving&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;ObjClasses.ArticleList oList = new ObjClasses.ArticleList();&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;oList.OpenLatest(10);&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;foreach( ObjClasses.Article oArt in oList )&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;string sTitle = oArt.Header;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;string sLink = "http://www.aspcode.net/wharver/showarticle.aspx?id=" + oArtId.ToString() ;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;string sDescription = oArt.ShortDescr;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;string sPubDate = oArt.LastModified.ToString("R");&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append(sLink);&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append(sLink);&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append(sDescription);&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append(sPubDate);&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;        &lt;/span&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;This is everything, actually. I will still make one improvement - caching: &lt;/p&gt;  &lt;p class="MsoNormal"&gt;public void ProcessRequest (HttpContext context)&lt;/p&gt;  &lt;p class="MsoNormal"&gt;{&lt;span style=""&gt;  &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;string sTxt = "";&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;if ( context.Cache["RSSFEED123"] == null )&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;               &lt;/span&gt;sTxt = BuildXmlString(context);&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;               &lt;/span&gt;context.Cache.Insert( "RSSFEED123", sTxt );&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;else&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;               &lt;/span&gt;sTxt = context.Cache["RSSFEED123"].ToString();&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;                      &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;context.Response.ContentType = "text/xml";&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;context.Response.ContentEncoding = System.Text.Encoding.UTF8;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;        &lt;/span&gt;context.Response.Write( sTxt );&lt;/p&gt;  &lt;p class="MsoNormal"&gt;}&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;br /&gt;You might spot the potential problem here - the cached string lives forever (until the webapplication restarts actually) but you can of course insert your string with a CacheDependency - or do as I do - please read the related article about &lt;a href="http://www.aspcode.net/articles/l_en-US/t_default/ASP.NET/ASP.NET---caching-control_article_278.aspx"&gt;ASP.NET caching control&lt;/a&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;i&gt;Added: 2006-09-20&lt;br /&gt;&lt;/i&gt;I use pretty much this exact script on this very site but after a while I found that the rss feed generated was corrupt. It turned out that I had added some articles with quotes etc and it of course broke the xml.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The fix is to add CDATA sections:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;oBuilder.Append(sLink);&lt;br /&gt;&lt;br /&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;oBuilder.Append(sLink);&lt;br /&gt;&lt;br /&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;oBuilder.Append("&lt;![CDATA[ "&lt;/span&gt;&lt;code&gt;&lt;span style="color: rgb(68, 68, 68);"&gt;); &lt;/span&gt;&lt;/code&gt;&lt;span style="COLOR: rgb(68,68,68)"&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;oBuilder.Append(sDescription); &lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;oBuilder.Append(&lt;/code&gt;&lt;/span&gt;&lt;span class="string3"&gt;" ]]&amp;gt; ");&lt;br /&gt;&lt;br /&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;oBuilder.Append(sPubDate);&lt;br /&gt;&lt;br /&gt;oBuilder.Append("");&lt;br /&gt;&lt;br /&gt;oBuilder.Append(""); &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-3958246690785851";
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_cpa_choice = "CAEaCI2-BlldXY3nUB9QIFC6Ag";
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7412293528094012160-8359407763058002253?l=projectcreatersworld.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://projectcreatersworld.blogspot.com/feeds/8359407763058002253/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7412293528094012160&amp;postID=8359407763058002253' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/8359407763058002253'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7412293528094012160/posts/default/8359407763058002253'/><link rel='alternate' type='text/html' href='http://projectcreatersworld.blogspot.com/2008/01/creating-rss-feed-for-your-aspnet-site.html' title='Creating an RSS feed for your ASP.NET site'/><author><name>Mr.Clear</name><uri>http://www.blogger.com/profile/15270782418713597883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7412293528094012160.post-1787952134345554174</id><published>2008-01-09T23:47:00.000-08:00</published><updated>2008-01-09T23:49:14.772-08:00</updated><title type='text'>Online Polling in Asp.Net</title><content type='html'>&lt;h2 style="text-align: center;" align="center"&gt;Introduction&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;There are many websites that have polls on their front page where users (anonymous and members) give their opinions. You should also have noticed that although you are an anonymous user, you are not allowed to vote more than once. In this article, we will look at how to design a polling system, having a back-end to insert new polls along with their answers as well as how to process and store the votes of the users.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;We will be using stored procedures extensively for interacting with MS SQL 2005 tables. You can download complete source code for this project &lt;a href="http://www.beansoftware.com/ASP.NET-Tutorials/Examples/Polls.zip"&gt;here&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="text-align: center;" align="center"&gt;Building blocks&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;There are many approaches to problem solving. One of them is the bottom-up approach. That is, we will begin to design the tables, write down the stored procedures that will interact with the tables and finally the remaining UI logic.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="text-align: center;" align="center"&gt;Functionalities&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;The functionalities that are to be implemented are:&lt;br /&gt;  1) Put up an active poll:&lt;br /&gt;      a. Enter the poll question&lt;br /&gt;      b. Enter the poll answers / options&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;  2) Displaying the current active poll.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;  3) Accept a vote from the user and recording the vote.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="text-align: center;" align="center"&gt;Table schema&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;We shall add a database (.mdf file) directly to our solution for simplicity. So, open Visual Web Developer 2005 Express edition and create a new website and call it "Polls". To add the SQL database file, right click on the project and click on "Add New Item". Then select "SQL Database" and name it "Poll.mdf".&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;  &lt;v:stroke joinstyle="miter"&gt;  &lt;v:formulas&gt;   &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;   &lt;v:f eqn="sum @0 1 0"&gt;   &lt;v:f eqn="sum 0 0 @1"&gt;   &lt;v:f eqn="prod @2 1 2"&gt;   &lt;v:f eqn="prod @3 21600 pixelWidth"&gt;   &lt;v:f eqn="prod @3 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @0 0 1"&gt;   &lt;v:f eqn="prod @6 1 2"&gt;   &lt;v:f eqn="prod @7 21600 pixelWidth"&gt;   &lt;v:f eqn="sum @8 21600 0"&gt;   &lt;v:f eqn="prod @7 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @10 21600 0"&gt;  &lt;/v:formulas&gt;  &lt;v:path extrusionok="f" gradientshapeok="t" connecttype="rect"&gt;  &lt;o:lock ext="edit" aspectratio="t"&gt; &lt;/v:shapetype&gt;&lt;v:shape id="_x0000_i1025" type="#_x0000_t75" alt="" style="'width:274.5pt;"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\VIJAY\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg" href="http://www.beansoftware.com/ASP.NET-Tutorials/Images/Poll-Database-File.jpg"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img src="file:///C:/DOCUME%7E1/VIJAY/LOCALS%7E1/Temp/msohtml1/01/clip_image001.jpg" shapes="_x0000_i1025" border="0" height="319" width="366" /&gt;&lt;!--[endif]--&gt;&lt;br /&gt;Figure 1. Step to add a new Database File&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1026" type="#_x0000_t75" alt="" style="'width:273.75pt;height:182.25pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\VIJAY\LOCALS~1\Temp\msohtml1\01\clip_image002.jpg" href="http://www.beansoftware.com/ASP.NET-Tutorials/Images/Poll-Mdf-File.jpg"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img src="file:///C:/DOCUME%7E1/VIJAY/LOCALS%7E1/Temp/msohtml1/01/clip_image002.jpg" shapes="_x0000_i1026" border="0" height="243" width="365" /&gt;&lt;!--[endif]--&gt;&lt;br /&gt;Figure 2. Selecting a database file and naming it "Poll.mdf"&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;Next comes the definition of the tables as shown in the diagrams below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1027" type="#_x0000_t75" alt="" style="'width:247.5pt;height:84pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\VIJAY\LOCALS~1\Temp\msohtml1\01\clip_image003.jpg" href="http://www.beansoftware.com/ASP.NET-Tutorials/Images/Poll-Table.jpg"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img src="file:///C:/DOCUME%7E1/VIJAY/LOCALS%7E1/Temp/msohtml1/01/clip_image003.jpg" shapes="_x0000_i1027" border="0" height="112" width="330" /&gt;&lt;!--[endif]--&gt;&lt;br /&gt;Figure 3. Table "Polls" with "PK_PollId" as primary key&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1028" type="#_x0000_t75" alt="" style="'width:247.5pt;height:99.75pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\VIJAY\LOCALS~1\Temp\msohtml1\01\clip_image004.jpg" href="http://www.beansoftware.com/ASP.NET-Tutorials/Images/Poll-Options-Table.jpg"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img src="file:///C:/DOCUME%7E1/VIJAY/LOCALS%7E1/Temp/msohtml1/01/clip_image004.jpg" shapes="_x0000_i1028" border="0" height="133" width="330" /&gt;&lt;!--[endif]--&gt;&lt;br /&gt;Figure 4. Table "PollOptions" with "PK_OptionId" as primary key and "FK_PollId" as a foreign key referencing the primary key "Pk_PollId" in the "Polls" table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1029" type="#_x0000_t75" alt="" style="'width:310.5pt;height:95.25pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\VIJAY\LOCALS~1\Temp\msohtml1\01\clip_image005.jpg" href="http://www.beansoftware.com/ASP.NET-Tutorials/Images/Poll-Table-Relation.jpg"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img src="file:///C:/DOCUME%7E1/VIJAY/LOCALS%7E1/Temp/msohtml1/01/clip_image005.jpg" shapes="_x0000_i1029" border="0" height="127" width="414" /&gt;&lt;!--[endif]--&gt;&lt;br /&gt;Figure 5. Table schema representing the tables' definitions. Pay attention to the primary and foreign key. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="text-align: center;" align="center"&gt;Stored Procedures&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;Stored procedures will be used to implement the functionalities discussed earlier. Right click on the Stored Procedures subfolder and select "Add New Stored Procedure".&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="text-align: center;" align="center"&gt;1) Putting up an active poll&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;The algorithm to put an active poll is to first set all the polls as inactive and then insert the active one in the &lt;b&gt;Polls&lt;/b&gt; table, as shown in the stored procedure below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana; color: blue;"&gt;ALTER PROCEDURE &lt;/span&gt;&lt;span style="font-family: Verdana;"&gt;dbo.NewPoll&lt;br /&gt;       (&lt;br /&gt;       @v_Question         &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;(200)&lt;br /&gt;       )&lt;br /&gt;&lt;span style="color: blue;"&gt;AS&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;--     FINDING THE ID OF THE NEW QUESTION&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;&lt;span style="font-size: 10pt; color: blue;"&gt;DECLARE &lt;/span&gt;&lt;span style="font-size: 10pt;"&gt;@i_NextQuestionID  &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;--     INITIALISIG QUESTION ID&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;SET &lt;/span&gt;@i_NextQuestionID = 1&lt;br /&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;--     IF THERE ARE MORE POLLS, THEN SET THE QUESTION ID TO MAX ID + 1&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;IF &lt;/span&gt;((&lt;span style="color: blue;"&gt;SELECT COUNT&lt;/span&gt;(*) &lt;span style="color: blue;"&gt;FROM &lt;/span&gt;Polls) &gt; 0)&lt;br /&gt;       &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;             &lt;span style="color: blue;"&gt;SET &lt;/span&gt;@i_NextQuestionID = (&lt;span style="color: blue;"&gt;SELECT MAX&lt;/span&gt;(PK_PollId) + 1 &lt;span style="color: blue;"&gt;FROM &lt;/span&gt;Polls)&lt;br /&gt;       &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;--     FIRST, SET THE OTHER QUESTIONS AS INAVTIVE&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;UPDATE &lt;/span&gt;Polls&lt;br /&gt;       &lt;span style="color: blue;"&gt;SET    &lt;/span&gt;       Active = 0&lt;br /&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;--     INSERT THE NEW QUESTION IN THE TABLE POLLS&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;INSERT INTO &lt;/span&gt;Polls&lt;br /&gt;                    (PK_PollId, Question, Active)&lt;br /&gt;       &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;(@i_NextQuestionID, @v_Question, 1)&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;RETURN&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;The input parameter @v_Question is the text describing the question of the poll. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;Secondly, the options for the poll need to be linked with the question itself. This is done by the following store procedure, using the id of the active poll. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana; color: blue;"&gt;ALTER PROCEDURE &lt;/span&gt;&lt;span style="font-family: Verdana;"&gt;dbo.SetPollOption&lt;br /&gt;       (&lt;br /&gt;       @v_option    &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;(100)&lt;br /&gt;       )&lt;br /&gt;&lt;span style="color: blue;"&gt;AS&lt;/span&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;--     FINDING THE ID OF THE NEW QUESTION&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;DECLARE &lt;/span&gt;@i_NextPollOptionID       &lt;span style="color: blue;"&gt;INT&lt;/span&gt;,&lt;br /&gt;              @i_PollId                 &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;--     GETS THE ACTIVE POLL ID&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;SELECT &lt;/span&gt;@i_PollId = PK_PollId &lt;span style="color: blue;"&gt;FROM &lt;/span&gt;Polls &lt;span style="color: blue;"&gt;WHERE &lt;/span&gt;Active = 1&lt;br /&gt;      &lt;br /&gt;&lt;span style="color: green;"&gt;--     INITIALISIG QUESTION ID&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;SET &lt;/span&gt;@i_NextPollOptionID = 1&lt;br /&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;--     IF THERE ARE MORE POLLS, THEN SET THE QUESTION ID TO MAX ID + 1&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;IF &lt;/span&gt;((&lt;span style="color: blue;"&gt;SELECT COUNT&lt;/span&gt;(*) &lt;span style="color: blue;"&gt;FROM &lt;/span&gt;PollOptions) &gt; 0)&lt;br /&gt;       &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;             &lt;span style="color: blue;"&gt;SET &lt;/span&gt;@i_NextPollOptionID = (&lt;span style="color: blue;"&gt;SELECT MAX&lt;/span&gt;(PK_OptionId) + 1 &lt;span style="color: blue;"&gt;FROM &lt;/span&gt;PollOptions)&lt;br /&gt;       &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;--     INSERT THE NEW QUESTION IN THE TABLE POLLS&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;INSERT INTO &lt;/span&gt;PollOptions&lt;br /&gt;                    (PK_OptionId, FK_PollId, Answer, Votes)&lt;br /&gt;       &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;(@i_NextPollOptionID, @i_PollId, @v_option, 0)&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;RETURN&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;@v_option holds description of the option&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="text-align: center;" align="center"&gt;2) Displaying the current active poll.&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;The following stored procedure will retrieve the current active poll as well as the options linked with the poll. The stored procedure will return a dataset containing 2 tables, based on the 2 SELECT statement, the first containing the question and the second table containing the options.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana; color: blue;"&gt;ALTER PROCEDURE &lt;/span&gt;&lt;span style="font-family: Verdana;"&gt;dbo.GetActivePoll&lt;br /&gt;&lt;span style="color: blue;"&gt;AS&lt;/span&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;--     GETS THE ACTIVE QUESTION FROM THE POLL TABLE&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;SELECT &lt;/span&gt;PK_PollId, Question&lt;br /&gt;       &lt;span style="color: blue;"&gt;FROM   &lt;/span&gt;Polls&lt;br /&gt;       &lt;span style="color: blue;"&gt;WHERE  &lt;/span&gt;Active = 1&lt;br /&gt;      &lt;br /&gt;&lt;span style="color: green;"&gt;--     GETS THE OPTIONS LINKED WITH THE ACTIVE POLL&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;SELECT &lt;/span&gt;PK_OptionId, Answer, Votes&lt;br /&gt;       &lt;span style="color: blue;"&gt;FROM   &lt;/span&gt;PollOptions&lt;br /&gt;       &lt;span style="color: blue;"&gt;WHERE  &lt;/span&gt;Fk_PollId &lt;span style="color: blue;"&gt;IN &lt;/span&gt;            &lt;br /&gt;                    (&lt;span style="color: blue;"&gt;SELECT &lt;/span&gt;PK_PollID &lt;span style="color: blue;"&gt;FROM &lt;/span&gt;Polls &lt;span style="color: blue;"&gt;WHERE &lt;/span&gt;Active = 1)&lt;br /&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;       &lt;span style="color: blue;"&gt;RETURN&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="text-align: center;" align="center"&gt;3) Recording a vote&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;Recording a vote is simple. The only thing that has to be done is to increment the number of votes for the option that was selected. The stored procedure below illustrates how this is done.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana; color: blue;"&gt;ALTER PROCEDURE &lt;/span&gt;&lt;span style="font-family: Verdana;"&gt;dbo.IncrementVote&lt;br /&gt;       (&lt;br /&gt;       @i_OptionId  &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&lt;br /&gt;       )&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;AS&lt;/span&gt;&lt;br /&gt;&lt;span style="color: green;"&gt;--     GETS THE CURRENT NUMBER OF VOTES FOR THAT OPTION&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;DECLARE      &lt;/span&gt;@i_NumberOfVoteS &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&lt;br /&gt;      &lt;br /&gt;       &lt;span style="color: blue;"&gt;SELECT &lt;/span&gt;@i_NumberOfVotes = Votes&lt;br /&gt;       &lt;span style="color: blue;"&gt;FROM   &lt;/span&gt;PollOptions&lt;br /&gt;       &lt;span style="color: blue;"&gt;WHERE  &lt;/span&gt;PK_OptionId = @i_OptionId&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;UPDATE &lt;/span&gt;PollOptions&lt;br /&gt;       &lt;span style="color: blue;"&gt;SET    &lt;/span&gt;       Votes = (@i_NumberOfVotes + 1)&lt;br /&gt;       &lt;span style="color: blue;"&gt;WHERE  &lt;/span&gt;PK_OptionId = @i_OptionId&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;RETURN&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;The stored procedure takes as parameter the option of the poll that was selected. The logic of preventing more than 1 time vote per poll will be explained later in this article.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2 style="text-align: center;" align="center"&gt;Designing the User Interface and Implementation&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;Below is the screen design where the poll would be input. The various options will be separated by the enter key and processed accordingly.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shape id="_x0000_i1030" type="#_x0000_t75" alt="" style="'width:293.25pt;height:183pt'"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\VIJAY\LOCALS~1\Temp\msohtml1\01\clip_image006.jpg" href="http://www.beansoftware.com/ASP.NET-Tutorials/Images/Poll-User-Interface.jpg"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;img src="file:///C:/DOCUME%7E1/VIJAY/LOCALS%7E1/Temp/msohtml1/01/clip_image006.jpg" shapes="_x0000_i1030" border="0" height="244" width="391" /&gt;&lt;!--[endif]--&gt;&lt;br /&gt;Figure 5. Screen for inputting a new poll. Note that the options must be separated by &lt;enter&gt;key &lt;o:p&gt;&lt;/o:p&gt;&lt;/enter&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;Clicking on the "Update Poll" button will set the poll as the active one with all the options. The following code illustrates the idea.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana; color: blue;"&gt;Protected&lt;/span&gt;&lt;span style="font-family: Verdana;"&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; btnUpdatePoll_Click(&lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Object&lt;/span&gt;, &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: blue;"&gt;Handles&lt;/span&gt; btnUpdatePoll.Click&lt;br /&gt;        &lt;span style="color: blue;"&gt;Try&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;'   Adds the question&lt;/span&gt;&lt;br /&gt;            addPollQuestion()&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;'   adds the options&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; strOptions() &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;String&lt;/span&gt; = txtOptions.Text.Split(vbCrLf)&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;For&lt;/span&gt; &lt;span style="color: blue;"&gt;Each&lt;/span&gt; strOption &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;String&lt;/span&gt; &lt;span style="color: blue;"&gt;In&lt;/span&gt; strOptions&lt;br /&gt;                addPollOptions(strOption)&lt;br /&gt;            &lt;span style="color: blue;"&gt;Next&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Catch&lt;/span&gt; ex &lt;span style="color: blue;"&gt;As&lt;/span&gt; Exception&lt;br /&gt;            &lt;span style="color: blue;"&gt;Throw&lt;/span&gt; ex&lt;br /&gt;        &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Try&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;Firstly, the question is added to the table and then the options, in that order.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana; color: blue;"&gt;Private&lt;/span&gt;&lt;span style="font-family: Verdana;"&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; addPollQuestion()&lt;br /&gt;        &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; strConnString &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;String&lt;/span&gt; = System.Configuration.ConfigurationManager.ConnectionStrings.Item(&lt;span style="color: maroon;"&gt;"ConnectionString"&lt;/span&gt;).ToString()&lt;br /&gt;        &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; sqlConn &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;New&lt;/span&gt; SqlConnection(strConnString)&lt;br /&gt;&lt;br /&gt;        sqlConn.Open()&lt;br /&gt;        &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; sqlCmd &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;New&lt;/span&gt; SqlCommand()&lt;br /&gt;&lt;br /&gt;        sqlCmd.CommandText = &lt;span style="color: maroon;"&gt;"NewPoll"&lt;/span&gt;&lt;br /&gt;        sqlCmd.CommandType = Data.CommandType.StoredProcedure&lt;br /&gt;        sqlCmd.Connection = sqlConn&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'   Creation parameters&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; sqlParamQuestion &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;New&lt;/span&gt; SqlParameter(&lt;span style="color: maroon;"&gt;"@v_Question"&lt;/span&gt;, Data.SqlDbType.VarChar)&lt;br /&gt;&lt;br /&gt;        sqlParamQuestion.Value = txtQuestion.Text&lt;br /&gt;&lt;br /&gt;        sqlCmd.Parameters.Add(sqlParamQuestion)&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'   Execute stored procedure&lt;/span&gt;&lt;br /&gt;        sqlCmd.ExecuteNonQuery()&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'   Close connection&lt;/span&gt;&lt;br /&gt;        sqlConn.Close()&lt;br /&gt;    &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana;"&gt;Finally the function addPollOptions is called to add one by one the options to the table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="articletext"&gt;&lt;span style="font-family: Verdana; color: blue;"&gt;Private&lt;/span&gt;&lt;span style="font-family: Verdana;"&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; addPollOptions(&lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; strOption &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;String&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; strConnString &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;String&lt;/span&gt; = Syst
