<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The SAVAGErider.NET blog</title>
	<atom:link href="http://savagerider.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://savagerider.wordpress.com</link>
	<description>SAVAGErider.NET = unleash the power of .net</description>
	<lastBuildDate>Sun, 14 Oct 2007 04:02:19 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='savagerider.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/5dc01fbf9567125133469bd54a575db7?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>The SAVAGErider.NET blog</title>
		<link>http://savagerider.wordpress.com</link>
	</image>
			<item>
		<title>security in ASP.NET</title>
		<link>http://savagerider.wordpress.com/2007/10/14/security-in-aspnet/</link>
		<comments>http://savagerider.wordpress.com/2007/10/14/security-in-aspnet/#comments</comments>
		<pubDate>Sun, 14 Oct 2007 04:02:19 +0000</pubDate>
		<dc:creator>savagerider</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://savagerider.wordpress.com/2007/10/14/security-in-aspnet/</guid>
		<description><![CDATA[Focusing on the authentication and authorization in ASP.NET. There are several authentication methods, namely, Windows, forms and passport. Comparing these three authentication methods, windows is the most straightforward approach. And passport is the most expensive approach. Let&#8217;s focus the discussion on forms. With this authentication, we need to create a login page for authentication. Instead [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=18&subd=savagerider&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Focusing on the authentication and authorization in ASP.NET. There are several authentication methods, namely, Windows, forms and passport. Comparing these three authentication methods, windows is the most straightforward approach. And passport is the most expensive approach. Let&#8217;s focus the discussion on forms. With this authentication, we need to create a login page for authentication. Instead of putting checking on every content page if the user is authenticated. We make sure of the authentication and authorization in web.config.</p>
<p>we need to add the following codes in web.config.</p>
<p><font size="2"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#800000">authentication</font><font size="2" color="#ff00ff"> </font><font size="2" color="#ff0000">mode</font><font size="2" color="#0000ff">=&#8221;Forms&#8221;&gt;</font></p>
<p></font><font size="2"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#800000">forms</font><font size="2" color="#ff00ff"> </font><font size="2" color="#ff0000">name</font><font size="2" color="#0000ff">=&#8221;.ASPXAUTH&#8221;</font><font size="2" color="#ff00ff"> </font><font size="2" color="#ff0000">loginUrl</font><font size="2" color="#0000ff">=&#8221;login.aspx&#8221;&gt;</font></p>
<p></font><font size="2"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#800000">credentials</font><font size="2" color="#ff00ff"> </font><font size="2" color="#ff0000">passwordFormat</font><font size="2" color="#0000ff">=&#8221;Clear&#8221;&gt;</font></p>
<p></font><font size="2"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#800000">user</font><font size="2" color="#ff00ff"> </font><font size="2" color="#ff0000">name</font><font size="2" color="#ff00ff"> </font><font size="2" color="#0000ff">=&#8221;test&#8221;</font><font size="2" color="#ff00ff"> </font><font size="2" color="#ff0000">password</font><font size="2" color="#0000ff">=&#8221;test&#8221;&gt;&lt;/</font><font size="2" color="#800000">user</font><font size="2" color="#0000ff">&gt;</font></p>
<p></font><font size="2"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#800000">user</font><font size="2" color="#ff00ff"> </font><font size="2" color="#ff0000">name</font><font size="2" color="#ff00ff"> </font><font size="2" color="#0000ff">=&#8221;Kelvin&#8221;</font><font size="2" color="#ff00ff"> </font><font size="2" color="#ff0000">password</font><font size="2" color="#0000ff">=&#8221;test&#8221;&gt;&lt;/</font><font size="2" color="#800000">user</font><font size="2" color="#0000ff">&gt;</font></p>
<p></font><font size="2"><font size="2" color="#0000ff">&lt;/</font><font size="2" color="#800000">credentials</font><font size="2" color="#0000ff">&gt;</font></p>
<p></font><font size="2"><font size="2" color="#0000ff">&lt;/</font><font size="2" color="#800000">forms</font><font size="2" color="#0000ff">&gt;</font></p>
<p></font><font size="2"><font size="2" color="#0000ff">&lt;/</font><font size="2" color="#800000">authentication</font><font size="2" color="#0000ff">&gt;</font></p>
<p></font>loginUrl indicates the login page location. Credentials child element shows the authenticatic user id and password.</p>
<p> Please note that if &lt;authorization&gt; is set to all users (*). Whatever inside &lt;authentication&gt; will not function.</p>
<p><strong><u>For login.aspx</u></strong></p>
<p>We can make use of the asp.net API to check the user credential and redirect him/her back to the original accessing page. We can add the following when user hit enter.</p>
<p><font size="2" color="#0000ff">if</font><font size="2"> (FormsAuthentication.Authenticate(TextBox1.Text,TextBox2.Text))</font><font size="2">{</p>
<p>FormsAuthentication.RedirectFromLoginPage(TextBox1.Text,</font><font size="2" color="#0000ff">false</font><font size="2">);</font><font size="2">}</p>
<p></font>We can also make sure of <font size="2">User.Identity.Name, to show the user name.</font></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/savagerider.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/savagerider.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/savagerider.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/savagerider.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/savagerider.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/savagerider.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/savagerider.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/savagerider.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/savagerider.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/savagerider.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/savagerider.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/savagerider.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=18&subd=savagerider&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://savagerider.wordpress.com/2007/10/14/security-in-aspnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d24ede27a698225ef6a4890f3d169ab8?s=96&#38;d=identicon" medium="image">
			<media:title type="html">savagerider</media:title>
		</media:content>
	</item>
		<item>
		<title>Navigating in ASP.NET pages</title>
		<link>http://savagerider.wordpress.com/2007/09/23/navigating-in-aspnet-pages/</link>
		<comments>http://savagerider.wordpress.com/2007/09/23/navigating-in-aspnet-pages/#comments</comments>
		<pubDate>Sun, 23 Sep 2007 10:49:33 +0000</pubDate>
		<dc:creator>savagerider</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://savagerider.wordpress.com/2007/09/23/navigating-in-aspnet-pages/</guid>
		<description><![CDATA[There are 3 ways for us to navigate in ASP.NET pages.
 1. Response.redirect(&#8220;yourWebPage.aspx&#8221;);
This is way of navigating to new page is not new to us. We could redirect the page from any webserver. There several limitations on this method:
a) Unable to pass VIEWSTATE / Session / Application session parameters to redirected page.
2. Server.Transfer(&#8220;yourWebPage.aspx&#8221;, isPreserveForm);
We could pass the parameters [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=16&subd=savagerider&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There are 3 ways for us to navigate in ASP.NET pages.</p>
<p> 1. Response.redirect(&#8220;yourWebPage.aspx&#8221;);</p>
<p>This is way of navigating to new page is not new to us. We could redirect the page from any webserver. There several limitations on this method:</p>
<p>a) Unable to pass <strong>VIEWSTATE</strong> / Session / Application session parameters to redirected page.</p>
<p>2. Server.Transfer(&#8220;yourWebPage.aspx&#8221;, isPreserveForm);</p>
<p>We could pass the parameters from originating page to destinated page if isPreserveForm is set to true. The <strong>viewstate</strong> field of the originating page will be added to the destinated page, this causes the response stream is different with only destinated page alone. In this case, we need to turn off the consistency checking (ViewStateMac) on <strong>viewstate</strong>.We will have limitation on using this method to redirect page from the same web server, this will limit the scalability of the application.</p>
<p>3. Server.Execute(&#8220;yourWebPage.aspx&#8221;,TextWriter);</p>
<p>Page B will return back to Page A (originating page) after execution. This inherited the limitation from Server.Transfer, where the page must be from the same web server. The result of Page B is stored in TextWriter if it is set in 2nd parameter.</p>
<p><font size="2">StringWriter sw = </font><font size="2" color="#0000ff">new</font><font size="2"> StringWriter();</font><font size="2">Server.Execute(&#8220;WebForm2.aspx&#8221;,sw);</p>
<p>TextBox2.Text = sw.ToString();</p>
<p></font></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/savagerider.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/savagerider.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/savagerider.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/savagerider.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/savagerider.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/savagerider.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/savagerider.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/savagerider.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/savagerider.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/savagerider.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/savagerider.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/savagerider.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=16&subd=savagerider&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://savagerider.wordpress.com/2007/09/23/navigating-in-aspnet-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d24ede27a698225ef6a4890f3d169ab8?s=96&#38;d=identicon" medium="image">
			<media:title type="html">savagerider</media:title>
		</media:content>
	</item>
		<item>
		<title>Managing State</title>
		<link>http://savagerider.wordpress.com/2007/09/09/managing-state/</link>
		<comments>http://savagerider.wordpress.com/2007/09/09/managing-state/#comments</comments>
		<pubDate>Sun, 09 Sep 2007 03:01:59 +0000</pubDate>
		<dc:creator>savagerider</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://savagerider.wordpress.com/2007/09/09/managing-state/</guid>
		<description><![CDATA[HTTP protocol is a stateless protocol. Information is not maintained from one page to another page. In this case it is not possible to keep continuity of user information on website.
Server-state Management 
Store state information on server side which has higher security. 
1. Application State
State information is available to all users of the web application. It makes use [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=15&subd=savagerider&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>HTTP protocol is a stateless protocol. Information is not maintained from one page to another page. In this case it is not possible to keep continuity of user information on website.</p>
<p><strong><u><font color="#008080">Server-state Management</font> </u></strong></p>
<p>Store state information on server side which has higher security. </p>
<p>1. <strong>Application State</strong></p>
<p><em>State information is available to all users of the web application. It makes use of</em>  <strong><u>HttpApplicationState</u></strong> <em>class for application state.</em> <font color="#ff0000"><strong><em>Generally, data that is common to all users and does not change often will stay on Application State.</em></strong></font></p>
<p><font color="#000000">Since more than one user is able to access and modify the Application data at the same time, it is necessary for us to have a mechanism to handle concurrent issues. We could use </font></p>
<p><font color="#808080">Application.Lock(); // to lock the application data, prevent it from updating</font></p>
<p><font color="#808080">Application["TestValue"] = 123 ;</font></p>
<p><font color="#808080">Application.Unlock();// unlock it, allow other to update it.</font></p>
<p>2. <strong>Session State</strong></p>
<p><em>Maintain the state information for each user of a specific session. It makes use of</em> <strong><u>HttpSessionState</u></strong> <em>class for each active Web Application session. </em><font color="#ff0000"><strong><em>Generally, sensitive data and short-lived variables are stored in session state. This is useful when session state is used in web farm / web garden configuration. </em></strong></font></p>
<p><font color="#000000"><em>An unique</em> sessionID (120 bits) is assigned to session for identification purpose. Default session timeout is 20 mins, it is configurable in web.config, <strong><font color="#3366ff">&lt;sessionState timeout=&#8221;10&#8243; /&gt;</font></strong></font></p>
<p><strong><font color="#3366ff">Session</font></strong> is used to access related property or method from Session state value. There are two ways to add new session data.</p>
<p><font color="#c0c0c0"><strong><font color="#000000">i.</font> Session["variable1"] = value;</strong></font></p>
<p><font color="#c0c0c0"><strong><font color="#000000">ii.</font> Session.Add(&#8220;variable1&#8243;,value);</strong></font></p>
<p>We can create an instance of HttpSessionState and assign the current  session to it.</p>
<p><font size="2" color="#999999">HttpSessionState currentState ;</font></p>
<p><font size="2"><font color="#999999">currentState = Session;</font> <font size="2" color="#008000">// or Page.Session;</font></font></p>
<p><strong>Cookieless Session</strong></p>
<p>SessionID from active session is stored in cookie, If cookie is disable on client browser, sessionID is lost on every request since HTTP is a stateless protocol.</p>
<p>With <font color="#3366ff">&lt;sessionState cookieless = &#8220;false&#8221;/&gt;</font> is set in web.config. We will keep the <strong>sessionID</strong> in the QueryString. You will expect the following url appearing in the browser.</p>
<p><a href="http://localhost/sessionState/(o2ikbu45ih4b0e2mftef3myl)/WebForm1.aspx">http://localhost/sessionState/(o2ikbu45ih4b0e2mftef3myl)/WebForm1.aspx</a> </p>
<p>In this case, it is not possible to use absolute URL to link the page.  </p>
<p> 3. <strong>Database Server/ State Server</strong></p>
<p><em>Maintain state information on database or state server which has fault tolerance but there is a performance trade-off.</em></p>
<p><em>These ways allow us to avoid get into<strong> in-process</strong> situation, where we could allow multiple server to access the state information instead of only one server storing and accessing the information.</em></p>
<p><em>We could either use <strong>stateServer</strong> or <strong>sqlServer</strong> database to store the state session data. With the following syntax in <strong>web.config</strong>.</em></p>
<p><em><font color="#ff6600"><strong>&lt; sessionState mode=&#8221;SQLServer&#8221; sqlConnectionString=&#8221;data source=SQLServerName Integrated security=true&#8221;/&gt;</strong></font></em></p>
<p><font color="#000000">The above syntax is using SQL Server to store session data in database. After inidicating SQLServer is used in web.config, we need to install the <font color="#ff0000"><strong>ASPState</strong></font> database into SQL Server. We can achieve that by executing the following line under the directory of <strong>C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322</strong>. <strong><u>InstallSqlState.sql</u></strong> is the script to create <strong>ASPState</strong> and <strong>tempdb</strong>. </font></p>
<p><font color="#000000"><font color="#ff0000"><strong><u>Ensure that ASPNET account has the access to the StoredProcedure in database ASPState.</u></strong></font> </font></p>
<p><strong><em><font color="#ff6600">C:\&gt; OSQL SQLServerName -E &lt;InstallSqlState.sql</font></em></strong></p>
<p><font color="#000000">You will expect ASPState and tempdb database are created in the sql server.</font></p>
<p><strong><u><font color="#008080">Client-state Management</font></u></strong></p>
<p>Store state information on client side which has lower security but much faster if compare to server state management. </p>
<p>1. <strong>Cookies</strong></p>
<p>There are 2 ways to store data into cookies.</p>
<p>1. using HttpCookieCollection</p>
<p><font size="2"><font size="2"><strong><font color="#999999">HttpCookie objCookie = </font></strong></font><font size="2" color="#999999"><strong>new</strong></font><font size="2"><strong><font color="#999999"> HttpCookie(&#8220;testWeb&#8221;);</font></strong></font></font><font size="2"><strong><font color="#999999">objCookie.Values.Add(&#8220;Name&#8221;,&#8221;John&#8221;);</font></strong></p>
<p><strong><font color="#999999">objCookie.Expires = DateTime.Now.AddDays(1);</font></strong></p>
<p><strong><font color="#999999">Response.Cookies.Add(objCookie);</font></strong></p>
<p></font>2. using Response directly </p>
<p><font size="2" color="#999999"><strong>Response.Cookies["testweb"]["Name"] = &#8220;Peter&#8221;;</strong></p>
<p></font>Regardless of which method you use, the result is the same. To retrieve the cookies value simply use the following syntax:</p>
<p><font size="2"><font color="#999999"><strong>HttpCookie obj = Request.Cookies["testWeb"];</strong></font></p>
<p><font color="#999999"><strong>Label1.Text = obj.Values["Name"];</strong></font></p>
<p></font><em><strong><font color="#3366ff">Temporary cookies</font></strong> (Default). This kind of cookies is removed when browser is shut down. </em></p>
<p><em><font color="#3366ff"><strong>Permanent cookies</strong>.</font> This kind of cookies is stored on hard dish with the file name of </em><a href="mailto:username@domainname.txt"><em>username@domainname.txt</em></a><em>. The max size is 4 KB only.</em></p>
<p>2. <strong>ViewState</strong></p>
<p><em>This state information is stored on hidden field on rendered html page. For good performance it is better to turn it off if it is not necessary.</em></p>
<p>3. <strong>QueryString</strong></p>
<p><em>Keep state information on the QueryString in URL. </em></p>
<p><strong><u>Global.asax</u></strong></p>
<p>This file is stored in virtual root of the web application, there is only one <strong>global.asax </strong>located in a web application.</p>
<p>There are three types of events in global.asax.</p>
<p>1. Request Event</p>
<p>Events are fired when a page is requested.</p>
<p>[<font color="#3366ff">Application_BeginRequest, Application_AuthenticateRequest</font>, ..... ]</p>
<p>2. Response Event</p>
<p>Events are fired when response is sent to the server</p>
<p>[<font color="#3366ff">Application_PostRequestHandlerExecute, Application_ReleaseRequestState, Application_UpdateRequestCache, Application_EndRequest</font>]</p>
<p>3. Conditional Event</p>
<p>Events may or may not be raised during the processing of a request.</p>
<p>[<font color="#3366ff">Application_Start, Application_End, Session_Start, Session_End, Application_Error</font>]</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/savagerider.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/savagerider.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/savagerider.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/savagerider.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/savagerider.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/savagerider.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/savagerider.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/savagerider.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/savagerider.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/savagerider.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/savagerider.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/savagerider.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=15&subd=savagerider&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://savagerider.wordpress.com/2007/09/09/managing-state/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d24ede27a698225ef6a4890f3d169ab8?s=96&#38;d=identicon" medium="image">
			<media:title type="html">savagerider</media:title>
		</media:content>
	</item>
		<item>
		<title>Collection</title>
		<link>http://savagerider.wordpress.com/2007/09/02/collection/</link>
		<comments>http://savagerider.wordpress.com/2007/09/02/collection/#comments</comments>
		<pubDate>Sun, 02 Sep 2007 09:32:20 +0000</pubDate>
		<dc:creator>savagerider</dc:creator>
				<category><![CDATA[C# concepts]]></category>

		<guid isPermaLink="false">http://savagerider.wordpress.com/2007/09/02/collection/</guid>
		<description><![CDATA[Default collection in .net platform include:
1. ArrayList
When we do not know the number of item in an array, it is good if we can use ArrayList which allows us to add item freely. With Add(), it will increase the array size according. ToArray() to copy item on the ArrayList to Array.
2. Queue
FIFO implementation, there are a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=14&subd=savagerider&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Default collection in .net platform include:</p>
<p>1. ArrayList</p>
<p>When we do not know the number of item in an array, it is good if we can use ArrayList which allows us to add item freely. With Add(), it will increase the array size according. ToArray() to copy item on the ArrayList to Array.</p>
<p>2. Queue</p>
<p>FIFO implementation, there are a list of methods for different purposes. E.g.</p>
<p><em><font color="#3366ff">Enqueue</font></em> : add object into the Queue</p>
<p><em><font color="#3366ff">Dequeue</font></em> : return and remove object from the Queue</p>
<p><em><font color="#3366ff">Peek</font></em> : Return the 1st object from the Queue</p>
<p>and many more.</p>
<p>3. Stack</p>
<p>FILO implementation, this is similar to Queue with a list of methods for different purposes. E.g.</p>
<p><em><font color="#3366ff">Push</font></em> : Add an object to top of the stack</p>
<p><em><font color="#3366ff">Pop</font></em> : Return and remove an object from the top of the stack</p>
<p>These three collections implement <em><strong>IEnumerable</strong></em> and <strong><em>IEnumerator</em></strong>. Meaning, we could use <font color="#3366ff">foreach</font> loop for these three collections</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/savagerider.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/savagerider.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/savagerider.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/savagerider.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/savagerider.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/savagerider.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/savagerider.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/savagerider.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/savagerider.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/savagerider.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/savagerider.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/savagerider.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=14&subd=savagerider&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://savagerider.wordpress.com/2007/09/02/collection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d24ede27a698225ef6a4890f3d169ab8?s=96&#38;d=identicon" medium="image">
			<media:title type="html">savagerider</media:title>
		</media:content>
	</item>
		<item>
		<title>indexer</title>
		<link>http://savagerider.wordpress.com/2007/09/02/indexer/</link>
		<comments>http://savagerider.wordpress.com/2007/09/02/indexer/#comments</comments>
		<pubDate>Sun, 02 Sep 2007 07:51:32 +0000</pubDate>
		<dc:creator>savagerider</dc:creator>
				<category><![CDATA[C# concepts]]></category>

		<guid isPermaLink="false">http://savagerider.wordpress.com/2007/09/02/indexer/</guid>
		<description><![CDATA[We can make use of indexer to group a collection of class or type together just like an array. First, we could make use of param keyword in the signature to cater for multiple input values. Then, we use indexer to access array like property item.

  static void Main(string[] args)
  {
  testIndexer test = new [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=13&subd=savagerider&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>We can make use of indexer to group a collection of class or type together just like an array. First, we could make use of param keyword in the signature to cater for multiple input values. Then, we use indexer to access array like property item.</p>
<p><code><br />
  static void Main(string[] args)<br />
  {<br />
  testIndexer test = new testIndexer("test", "test1", "test2", "test3", "test4");<br />
  for (int i=0; i &lt; test.getCollectionSize() ; i++)<br />
  {<br />
  Console.WriteLine("Value is {0}", test[i]);<br />
  }<br />
  Console.ReadKey();<br />
  }<br />
  }</code><code>public class testIndexer : testInter<br />
  {<br />
  string []testString = new string[255];<br />
  int ctr = 0;</code><code>public testIndexer(params Object[] values)<br />
  {<br />
  foreach (string s in values)<br />
  {<br />
  testString[ctr++] = s;<br />
  }<br />
  }</p>
<p>public string this[int index]<br />
  {<br />
  set<br />
  {<br />
  testString[index] = value;<br />
  }<br />
  get<br />
  {<br />
  return testString[index];<br />
  }<br />
  }</p>
<p>public int getCollectionSize()<br />
  {<br />
  return ctr;<br />
  }<br />
  }</p>
<p>interface testInter<br />
  {<br />
  int getCollectionSize();</p>
<p>}</p>
<p><em><font color="#3366ff">public string this[int index]</font></em> make the stored array can be accessed like property item. With the <strong><em><font color="#3366ff">param</font></em></strong> keyword in the constructor we could cater for multiple inputs. The format is like:</p>
<p></code> <font color="#3366ff">param</font> <em>Type</em>[] <em><font color="#339966">variableName</font></em></p>
<p><font color="#000000">Collection without implementing IEnumerable and IEnumerator cannot be used in foreach case. We use IEnumerable to implement GetEnumerator which returns the instance of Enumeration. </font></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/savagerider.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/savagerider.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/savagerider.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/savagerider.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/savagerider.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/savagerider.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/savagerider.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/savagerider.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/savagerider.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/savagerider.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/savagerider.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/savagerider.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=13&subd=savagerider&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://savagerider.wordpress.com/2007/09/02/indexer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d24ede27a698225ef6a4890f3d169ab8?s=96&#38;d=identicon" medium="image">
			<media:title type="html">savagerider</media:title>
		</media:content>
	</item>
		<item>
		<title>Reference type VS Value type</title>
		<link>http://savagerider.wordpress.com/2007/09/02/reference-type-vs-value-type/</link>
		<comments>http://savagerider.wordpress.com/2007/09/02/reference-type-vs-value-type/#comments</comments>
		<pubDate>Sun, 02 Sep 2007 05:46:08 +0000</pubDate>
		<dc:creator>savagerider</dc:creator>
				<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://savagerider.wordpress.com/2007/09/02/reference-type-vs-value-type/</guid>
		<description><![CDATA[The type values in c# is catogoried into reference type and value type. Value type is straight forward, it is just like normal variable value that we stored in the stack memory. However, compiler store reference type in the heap memory. When we create an instance of class, we have the following code:
Form f1;                        // [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=12&subd=savagerider&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The type values in c# is catogoried into <em>reference type</em> and <em>value type</em>. <em>Value type</em> is straight forward, it is just like normal variable value that we stored in the <font color="#3366ff"><strong>stack</strong></font> memory. However, compiler store <em>reference type</em> in the <font color="#3366ff"><strong>heap</strong></font> memory. When we create an instance of class, we have the following code:<code><br />
Form f1;<span>                        </span><span style="color:green;">// Allocate the reference</span><br />
f1 = <span style="color:blue;">new</span> Form();<span>                </span><span style="color:green;">// Allocate the object</span> <br />
f2 = f1; <br />
</code><br />
<em>f1</em> and <em>f2</em> are pointing to the same object which is Form. In this case, if we pass f1 into a method, a local of copy of <em>f1</em> is created. The changes made on the local copy will affect <em>f1</em>, but it is not true for null case. It is because if we set null to the local copy, only the local copy is destroyed but not <em>f1</em>.</p>
<p>As mentioned, <em>value type</em> is stored in stack, the stack is popped when the variable is not in use anymore. <em>Reference type</em> is like a room that filled with objects, which reference to an object is provided. This reference can be located in stack or it could be another heap-object. In the above example, f1 is stored in stack while Form object is stored in heap. For the below case, the reference is another heap-object.</p>
<p><code><br />
Font f = new Font("Arial",10);<br />
f1.font = f;<br />
</code></p>
<p>f is another reference in heap,which is pointing to Font class object.</p>
<p>For value type variable, it is not possible to modify them in the method. Let&#8217;s consider the following code:<br />
<code><br />
public void test(int x)<br />
{<br />
  x = 5 ;<br />
  return;<br />
}<br />
</code><br />
It is not possible for us to modify variable x in the method.  However, with keyword <font color="#3366ff">ref</font>, we are able to make the changes on variable x. It is because we pass the variable by reference.<code><br />
public void test(ref int x)<br />
{<br />
  x = 5 ;<br />
  return;<br />
}<br />
</code></p>
<p>It is possible to use keyword <font color="#3366ff">out</font> instead of <font color="#3366ff">ref</font>. The main difference between them is that ref must be initialized before it is passed into the method.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/savagerider.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/savagerider.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/savagerider.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/savagerider.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/savagerider.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/savagerider.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/savagerider.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/savagerider.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/savagerider.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/savagerider.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/savagerider.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/savagerider.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=12&subd=savagerider&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://savagerider.wordpress.com/2007/09/02/reference-type-vs-value-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d24ede27a698225ef6a4890f3d169ab8?s=96&#38;d=identicon" medium="image">
			<media:title type="html">savagerider</media:title>
		</media:content>
	</item>
		<item>
		<title>OOP.Keyword [ statc, readonly, const, sealed, abstract, virtual, base, this, new, interface]</title>
		<link>http://savagerider.wordpress.com/2007/09/02/oopkeyword-statc-readonly-const-sealed-abstract-virtual-base-this-new-interface/</link>
		<comments>http://savagerider.wordpress.com/2007/09/02/oopkeyword-statc-readonly-const-sealed-abstract-virtual-base-this-new-interface/#comments</comments>
		<pubDate>Sun, 02 Sep 2007 01:09:39 +0000</pubDate>
		<dc:creator>savagerider</dc:creator>
				<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://savagerider.wordpress.com/2007/09/02/oopkeyword-statc-readonly-const-sealed-abstract-virtual-base-this-new-interface/</guid>
		<description><![CDATA[Static Variable is shared across all objects in the same class.
Static Constructor will only be executed once, it takes no parameter and no access modifier (private/public). It will executed once and first before other constructor take place. e.g.
static ClassName()
{
//doSomething
}
Readonly: one time initialization, the value can only be initialized in constructor.
const : constant value that cannot be modified, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=11&subd=savagerider&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><em><strong>Static</strong></em> Variable is shared across all objects in the same class.</p>
<p><em><strong>Static</strong></em> Constructor will only be executed once, it takes no parameter and no access modifier (private/public). It will executed once and first before other constructor take place. e.g.</p>
<p><code>static ClassName()<br />
{<br />
//doSomething</code></p>
<p><code>}</code></p>
<p><strong><em>Readonly</em></strong>: one time initialization, the value can only be initialized in constructor.</p>
<p><strong><em>const</em></strong> : constant value that cannot be modified, implicitly static variable</p>
<p><strong><em>sealed </em></strong>: class that cannot be inherited.</p>
<p><strong><em>abstract</em></strong> : As the name implies, it only provide the overall view on the class. Meaning, there is no implementation for the method. It only defines the methodName and signature. This type of class cannot be <strong><u><font color="#ff0000">instantiated</font></u></strong>. The abstract method must belong to abstract class.</p>
<p>The derived class that inherited this abstract class <strong><u>must</u></strong> <strong><font color="#3366ff">override</font></strong> the <em><u>abstract</u></em> method and provide the implementation for it.</p>
<p><strong><em>virtual</em></strong>  : This is similar to abstract which provide the derived class flexibility to modify the implementation <font color="#339966">for the virtual method</font>. The only difference between virtual and abstract is that, for virtual case, <u>the base class has implementation for the method</u> whereas in abstract case, there is <strong><u>no</u></strong> implementation for the method provided. This is essential to implement polymorphism in C#, where we could have the different implementation for the same method name.</p>
<p><strong><em>base</em></strong> : This refers to the base class in derived class. Since C# does not support multiple inheritance, it is not necessary to specify the name for the base class.</p>
<p><strong><em>this</em></strong> : This keyword refers to the current object</p>
<p><strong><em>new</em></strong> : This create a new method in derived class when the method name in both base class and derived class are the same. The method with new is not polymorphised.</p>
<p><strong><em>interface</em></strong> : This provides the overall view on the method name and signature but no the detailed implementation for method. The syntax for interface does not contain access modifier (public / private), it is implicitly declared as public. <u>The class that implement this interface do not need to add keyword <font color="#3366ff"><strong><em>override</em></strong></font> to the method that defined in interface</u>.</p>
<p><code><br />
interface Itest {<br />
void test1();<br />
void test2(int x);<br />
}<br />
</code></p>
<p>The class that implement interface must provide implementation for <strong><u>all</u></strong> methods defined in the interface. It is possible to support more than one interface.</p>
<p>Interface cannot be instantiated. If A implements interface B, we could say A is B. Therefore, we could assign objA to objB. As a result, there are referring to the same reference type (A).</p>
<p><code></code><code>//interface B { ... }<br />
//public class A : B</code><code>A objA = new A();<br />
B objB = (B) objA;</code><code>//both objA and objB refer to reference type A.</p>
<p>If a class implements more than one interface and the method name is repeated in these interfaces. It is necessary to specify the interface name explicitly.</p>
<p></code><code></code><code>interface Istorage<br />
  {<br />
  void read();<br />
  void write();<br />
  }</code><code>interface Isave<br />
  {<br />
  void read();<br />
  void write();<br />
  }</p>
<p>public class Document : Istorage , Isave<br />
  {<br />
  public void read()<br />
  {<br />
  Console.WriteLine("Read method from istorage Document");<br />
  }</p>
<p>void Isave.read()<br />
  {<br />
  Console.WriteLine("Read method from isave Document");<br />
  }<br />
  }</p>
<p>We need to specify the interface name without access modifier (public/ private) to define the implementation for read(). The first read method in this class refers to Istorage because istorage has the preceding position. <font color="#00ff00">Class is allowed to have multiple interface but this is not true for inheritance.</font></p>
<p></code></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/savagerider.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/savagerider.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/savagerider.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/savagerider.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/savagerider.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/savagerider.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/savagerider.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/savagerider.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/savagerider.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/savagerider.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/savagerider.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/savagerider.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=11&subd=savagerider&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://savagerider.wordpress.com/2007/09/02/oopkeyword-statc-readonly-const-sealed-abstract-virtual-base-this-new-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d24ede27a698225ef6a4890f3d169ab8?s=96&#38;d=identicon" medium="image">
			<media:title type="html">savagerider</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating User Control</title>
		<link>http://savagerider.wordpress.com/2007/08/26/creating-user-control/</link>
		<comments>http://savagerider.wordpress.com/2007/08/26/creating-user-control/#comments</comments>
		<pubDate>Sun, 26 Aug 2007 14:58:12 +0000</pubDate>
		<dc:creator>savagerider</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://savagerider.wordpress.com/2007/08/26/creating-user-control/</guid>
		<description><![CDATA[To promote reusability of code and UI, we could create our own custom user control (.ascx).
User control can never request independently as asp.net page. It must use together with web form.
User control does not contain &#60;html&#62;, &#60;body&#62;, &#60;form&#62;. As these tags are needed for web form.
User control is neither custom server control nor web custom [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=10&subd=savagerider&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>To promote reusability of code and UI, we could create our own custom user control (.ascx).</p>
<p>User control can never request independently as asp.net page. It must use together with web form.</p>
<p>User control does not contain &lt;html&gt;, &lt;body&gt;, &lt;form&gt;. As these tags are needed for web form.</p>
<p>User control is <u><strong>neither</strong></u> custom server control <strong><u>nor</u></strong> web custom control.</p>
<p>Just like normal web form, which contains the code-behind page. In this case, user control makes use of &#8220;<font color="#99ccff"><strong><em>&lt;@ control &gt;</em></strong></font> &#8221; tag to indicate the properties of it. This is similar to @ page in web form. <font color="#ff0000"><strong><u>Control tag does not support TRACE and ASPCompat !!!</u></strong></font></p>
<p><em><strong><font color="#808080">&lt;%@ Control Language=&#8221;c#&#8221; AutoEventWireup=&#8221;false&#8221; Codebehind=&#8221;WebUserControl1.ascx.cs&#8221; Inherits=&#8221;WebApplication1.WebUserControl1&#8243;&gt;</font></strong></em> </p>
<p>User control normally used as <strong>headers</strong>, <strong>navigation bars</strong> and <strong>repeating blocks of code</strong>.</p>
<p>User control uses its own namespace, this ensures no conflict on the variables and methods. It has its own postBack and control component.</p>
<p>User control can be written in different language from the hosting page.</p>
<p>To use user control in hosting page. Firstly, we need the following code on the top of .aspx</p>
<h6><font color="#808080">&lt;%@ Register TagPrefix=&#8221;uc1&#8243; TagName=&#8221;WebUserControl1&#8243; Src=&#8221;WebUserControl1.ascx&#8221; %&gt;</font></h6>
<p><strong>TagPrefix</strong> is the unique namespace</p>
<p><strong>TagName</strong> is the unique name for the user control</p>
<p><strong>Src</strong> is the file name of the user control</p>
<p>We add the user control with the following code:</p>
<h6><font color="#808080">&lt;uc1:webusercontrol1 id=&#8221;WebUserControl11&#8243; runat=&#8221;server&#8221;&gt;</font> </h6>
<p> uc1 is the tagPrefix, webusercontrol1 is the tagName, id is used for behind-code.</p>
<p>To interact with the user control in behind-code, user control should expose control property on the user control page to hosting page. With this, the hosting page can access to the user control. Adding the following code to create a user control object [tagName].</p>
<p><font size="2" color="#0000ff">protected<font size="2"> WebUserControl1 WebUserControl11;</font></p>
<p></font>WebUserControl11.XXXX can access to the user control elements.</p>
<p>Two ways to create User Controls :</p>
<p>1. Create New User controls using visual studio .NET</p>
<p>2. Convert asp.net page to user controls (.ascx)</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/savagerider.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/savagerider.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/savagerider.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/savagerider.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/savagerider.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/savagerider.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/savagerider.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/savagerider.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/savagerider.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/savagerider.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/savagerider.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/savagerider.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=10&subd=savagerider&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://savagerider.wordpress.com/2007/08/26/creating-user-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d24ede27a698225ef6a4890f3d169ab8?s=96&#38;d=identicon" medium="image">
			<media:title type="html">savagerider</media:title>
		</media:content>
	</item>
		<item>
		<title>Debug Web Form</title>
		<link>http://savagerider.wordpress.com/2007/08/26/debug-web-form/</link>
		<comments>http://savagerider.wordpress.com/2007/08/26/debug-web-form/#comments</comments>
		<pubDate>Sun, 26 Aug 2007 13:07:22 +0000</pubDate>
		<dc:creator>savagerider</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://savagerider.wordpress.com/2007/08/26/debug-web-form/</guid>
		<description><![CDATA[There are two ways to debug web form on asp.net page.
1. Debug object
2. Trace object
For debug object, it requires to compile the code in debug mode with namespace System.Diagnostics. Debug object will not function if it is not compiled in debug mode.
For Trace object, you are able to disable it by configuring web.config file. This [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=9&subd=savagerider&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There are two ways to debug web form on asp.net page.</p>
<p>1. Debug object</p>
<p>2. Trace object</p>
<p>For debug object, it requires to compile the code in debug mode with namespace System.Diagnostics. Debug object will not function if it is not compiled in debug mode.</p>
<p>For Trace object, you are able to disable it by configuring web.config file. This can avoid the efforts to remove all trace objects on production server.</p>
<p>Trace object can be enabled in two levels:</p>
<p>1. Page level</p>
<p>2. Application level</p>
<p>For <strong>Page level</strong>, we could do it on Page attribute in .aspx with <font color="#99ccff"><strong><em>Trace=&#8221;true&#8221; </em></strong><font color="#000000">,the trace message can display on the page.</font></font></p>
<p>For <strong>Application level</strong>,  we could do it on web.config file. This will enable the trace on every page in the application. The trace message can be displayed on the page or memory. You will see the following code on web.config file.</p>
<h5><font color="#808080">&lt;configuration&gt;&lt;system.web&gt;</font></h5>
<h5><font color="#808080">    &lt;trace enabled =&#8221;true&#8221; pageOutput=&#8221;true&#8221; localOnly=&#8221;true&#8221;/&gt;</font></h5>
<h5><font color="#808080">&lt;/system.web&gt;&lt;/configuration&gt;</font></h5>
<p>attribute <font color="#808080"><strong>pageOutput</strong></font> indicates if there is any output shown on the page. If it is false, the trace is kept in the memory, it is required to use <u>http://servername / projName / trace.axd</u> to view the trace information in the memory.This will create a security risks as the trace information is very sensitive to an application. It is possible to turn off the trace in memory with the following code in <strong>machine.config</strong> in <u>WIN \ Microsoft.NET\Framework\version No.\Config </u></p>
<p> &lt;httpHandlers&gt; &lt;add verb=&#8221;*&#8221; path = &#8221; &#8221; type = &#8221; &#8230;&#8230;.. &gt; &lt;/httpHandlers&gt;</p>
<p>The default value for path is trace.axd.</p>
<p>attribute <font color="#808080"><strong>localOnly</strong></font> indicates if the trace is shown on the local computer instead of the all the client desktop.</p>
<p>For both cases, we can use Trace.Write and Trace.Warn to display trace information. Warn method will display message in red. These 2 methods have the following format:</p>
<h5><em>Trace.Write(&#8220;Category&#8221;,&#8221;Msg&#8221;);</em></h5>
<p>Trace result is shown at the bottom of the page, which consists of the following information:</p>
<h5>1. Request Details</h5>
<h5>2. Trace Information</h5>
<h5>3. Control Tree</h5>
<h5>4. Cookies Collection</h5>
<h5>5. Headers Collection</h5>
<h5>6. Form Collection</h5>
<h5>7. Server Variables</h5>
<p>The priority of enabling trace information is from page (high) to Application (low). If page-level trace is enabled, regarding of whether application-level trace is enabled, the trace information is shown.</p>
<p><strong><u>Trace into a Component</u></strong></p>
<p>It is possible to disable the trace on page level, but enable it on a desired component. With the following steps:</p>
<p>1. Use <strong><em><font color="#808080">System.Web</font></em></strong> namespace</p>
<p>2. Turn on the trace on a component. <font color="#808080"><em><strong>HttpContext.Current.Trace.IsEnabled = true</strong></em></font>,</p>
<p>3. Write something, <font color="#808080"><em><strong>HttpContext.Current.Trace.Write(&#8220;Category&#8221;,&#8221;msg&#8221;);</strong></em></font></p>
<p><font color="#ff0000">When trace is enabled on a component, trace is shown on any page that access to the components, even if trace is disabled for that page.</font></p>
<p> If trace on a component is ON,trace on page is OFF.</p>
<p>&#8211;&gt; Trace message on component is shown but on page is <strong><u>not</u></strong> shown</p>
<p>If trace on a component is OFF, trace on page is ON</p>
<p>&#8211;&gt; Trace message on component is <strong><u>NOT</u></strong> shown.</p>
<p>If trace on a component is not set, trace on page is ON</p>
<p>&#8211;&gt; Trace message on component and page is shown</p>
<p>trace listener and trace switches??</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/savagerider.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/savagerider.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/savagerider.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/savagerider.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/savagerider.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/savagerider.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/savagerider.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/savagerider.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/savagerider.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/savagerider.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/savagerider.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/savagerider.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=9&subd=savagerider&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://savagerider.wordpress.com/2007/08/26/debug-web-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d24ede27a698225ef6a4890f3d169ab8?s=96&#38;d=identicon" medium="image">
			<media:title type="html">savagerider</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding code to Web Form on ASP.NET</title>
		<link>http://savagerider.wordpress.com/2007/08/26/adding-code-to-web-form-on-aspnet/</link>
		<comments>http://savagerider.wordpress.com/2007/08/26/adding-code-to-web-form-on-aspnet/#comments</comments>
		<pubDate>Sun, 26 Aug 2007 07:08:01 +0000</pubDate>
		<dc:creator>savagerider</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://savagerider.wordpress.com/2007/08/26/adding-code-to-web-form-on-aspnet/</guid>
		<description><![CDATA[There are three ways to add codes to web form:
1. Mixed code
This is the least preferred method as the code is very messy and did not seperate business logic from interface.
2. Inline code
This method include a &#8220;script&#8221; section on html content. Business logic does not mix with html interface
3. Code-behind
This is the default method with Visual [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=8&subd=savagerider&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There are three ways to add codes to web form:</p>
<p>1. Mixed code</p>
<h5>This is the least preferred method as the code is very messy and did not seperate business logic from interface.</h5>
<p>2. Inline code</p>
<h5>This method include a &#8220;script&#8221; section on html content. Business logic does not mix with html interface</h5>
<p>3. Code-behind</p>
<h5>This is the default method with Visual Studio .net. The .cs normally will have the same name as the .aspx. Code-behind page need to be compiled before sending information to the client browser. It can be pre-compiled in visual studio .net if you foresee that there isn&#8217;t much changes on the code, or it is also possible to compile it during first time that user access the page. In this way, user can use the latest copy of code-behind page.</h5>
<p>Page attribute:</p>
<p>Codebehind: indicate the associating file [<font color="#ff0000">this attribute is no longer in use on asp.net 2.0</font>]</p>
<p>Src : indicate the code-behind page if the page is not pre-compiled. It is more for JIT compilation.</p>
<p>Inherits: .aspx inherit the class from the specificed code-behind page.</p>
<p><font color="#ff6600"><strong>Event Procedures</strong></font></p>
<p>This is the procedure to handle user interaction such as submit event, mouse click event.</p>
<p><font color="#ff6600"><strong>Server-side event VS client-side event</strong></font></p>
<p><strong>Client side event</strong> can only be processed with HTML controls. Normally, when the event is triggered, it makes use of javascript to process the actions. It has no interaction with the server, in this case it is not possible to access server resources like database. This is normally used as the validation on user input to save the network traffic.</p>
<p><strong>Server-side event</strong> is triggered with the component that has runat=&#8221;server&#8221;. It can handle event generated by server controls and html server controls.</p>
<p><font color="#ff0000">It is very important to know that there is only one &lt;form&gt; tag with runat=&#8221;server&#8221; allowed, and the component with this attribute <strong><u>must</u></strong> keep inside &lt;form&gt; tag.</font></p>
<p><strong><font color="#ff6600">Page Event</font></strong></p>
<p>Page event life cycle consists of a few events:</p>
<p>1. Page_init</p>
<h5>this happens when the page is initially created.</h5>
<p>2. Page_load</p>
<h5>this happens when the page is requested</h5>
<p>3. other control component event</p>
<p>4. Page_unload</p>
<h5>this happens when the page is closed.</h5>
<p><font color="#ff6600"><strong>PostBack</strong></font></p>
<p>This process post information back to  asp.net server for processing. It can be user clicking the submit button or with the <em><font color="#ff6600">AutoPostBack </font></em>property set to true.</p>
<p><em><font color="#ff6600">Page.IsPostBack</font></em> is to check if the request is a postback request. It will return false if the page is first created.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/savagerider.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/savagerider.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/savagerider.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/savagerider.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/savagerider.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/savagerider.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/savagerider.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/savagerider.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/savagerider.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/savagerider.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/savagerider.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/savagerider.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=savagerider.wordpress.com&blog=1573082&post=8&subd=savagerider&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://savagerider.wordpress.com/2007/08/26/adding-code-to-web-form-on-aspnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d24ede27a698225ef6a4890f3d169ab8?s=96&#38;d=identicon" medium="image">
			<media:title type="html">savagerider</media:title>
		</media:content>
	</item>
	</channel>
</rss>