<?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/"
	>

<channel>
	<title>Vistaloca Studios</title>
	<atom:link href="http://blog.vistalocastudios.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.vistalocastudios.com</link>
	<description>Blog covering web development with special focus on ASP.net</description>
	<lastBuildDate>Fri, 28 Aug 2009 16:22:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>HTML vs XHTML</title>
		<link>http://blog.vistalocastudios.com/?p=24</link>
		<comments>http://blog.vistalocastudios.com/?p=24#comments</comments>
		<pubDate>Mon, 17 Aug 2009 16:38:11 +0000</pubDate>
		<dc:creator>vistaloca</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.vistalocastudios.com/?p=24</guid>
		<description><![CDATA[One of the first steps in developing a web site is deciding whether to use HTML 4.01 or XHTML 1.0. HTML is a much looser language than XHTML creating a larger potential for bad coding practices and unpredictable markup. This can create issues when parsing or manipulating the HTML code, compared to XHTML, which is [...]]]></description>
			<content:encoded><![CDATA[<p>One of the first steps in developing a web site is deciding whether to use HTML 4.01 or XHTML 1.0. HTML is a much looser language than XHTML creating a larger potential for bad coding practices and unpredictable markup. This can create issues when parsing or manipulating the HTML code, compared to XHTML, which is an XML-ready language with very strict coding practices, and much more consistent coding rules and tags.</p>
<p>This doesn&#8217;t mean XHTML is better. Strict coding guidelines can be implemented for HTML, but browsers are much more forgiving of typos and missing tags with HTML. </p>
<p>The W3C has also <a href="http://www.w3.org/2009/06/xhtml-faq.html">stopped development on XHTML 2.0</a> and is directing it&#8217;s resources to HTML 5.0. This means XHTML will never grow beyond it&#8217;s current capabilities. HTML 5 will be the future language of the Internet, so using HTML now will provide better future compatability.</p>
<p>Another benefit of HTML is avoiding the MIME issue. All versions of IE, including 8, don&#8217;t support the XHTML specified MIME type <strong>application/xhtml+xml</strong>. Instead IE reads the page as <strong>text/html</strong> and will render the page if it follows the HTML compatibility recommendations. Web developers have been calling on the IE development team to implement the W3C specfications, but the team decided <a href="http://blogs.msdn.com/ie/archive/2005/09/15/467901.aspx">against it during the development of IE7</a>.</p>
<p>Once the language is decided, developers have to decide on implementing a &#8217;strict&#8217; or &#8216;transitional&#8217; version of the language. With either HTML or XHTML the strict version has deprecated elements and attributes, while the transitional version will allow those elements and a looser interpretation of the rendering rules. </p>
<p>All web pages must have a valid DTD (Document Type Definition) on the first line of the page in order to control the rendering mode of all modern browsers. The DTD or DOCTYPE describes the language used and the strict or transitional version. </p>
<p>All modern browsers have two basic rendering modes: <strong>quirks </strong>and <strong>standards</strong>. All modern browsers will render in standards-compliant mode if a valid DTD appears as the first line of code in a page. Obviously, standards provides the most predictable results and similar rendering amongst browsers. It should always be the benchmark designed for, unless you are dealing with legacy code that requires deprecated elements or attributes.</p>
<p>Both the strict and transitional versions of the DOCTYPE will cause the browser to use standards mode, but a typo in the DOCTYPE will cause quirks mode to be used. In IE6, the inclusion of an xml declaration will trigger quirks mode even if the DOCTYPE is correct. </p>
<p>Quirks mode in IE6 will cause the browser to revert to IE 5.5 rendering mode and IE7 quirks mode will do the same since it will render in IE6 quirks mode.</p>
<p>One easy way to tell if a browser is using quirks or standards mode is with a short JavaScript code:</p>
<p>function testRenderMode() {<br />
alert(document.compatMode);<br />
}<br />
You can also add the preceding code to a bookmark by <a href="javascript:m=(document.compatMode=='CSS1Compat')?'Standards':'Quirks';window.alert('You%20are%20in%20'%20+%20m%20+%20'%20mode.');">right clicking here</a> for easy access.</p>
<p>Thanks to <a href="http://www.satzansatz.de/cssd/quirksmode.html">Ingo Chao</a> for the link and information about quirks mode.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vistalocastudios.com/?feed=rss2&amp;p=24</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Themes and CSS</title>
		<link>http://blog.vistalocastudios.com/?p=14</link>
		<comments>http://blog.vistalocastudios.com/?p=14#comments</comments>
		<pubDate>Wed, 29 Jul 2009 07:44:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Accessibility]]></category>

		<guid isPermaLink="false">http://blog.vistalocastudios.com/?p=14</guid>
		<description><![CDATA[Folders inside the Theme folder in ASP.NET web sites can contain skin files, CSS files, images and text files. These folders are automatically compiled into classes so the names of folders should not conflict with class names already in use.
Here are several rules for the use of Themes:
Skin files should be replaced by CSS files, [...]]]></description>
			<content:encoded><![CDATA[<p>Folders inside the Theme folder in ASP.NET web sites can contain skin files, CSS files, images and text files. These folders are automatically compiled into classes so the names of folders should not conflict with class names already in use.</p>
<p>Here are several rules for the use of Themes:</p>
<p>Skin files should be replaced by CSS files, because CSS more closely follows web standards, maximizes caching of CSS files in browsers, reduces bloated web pages and the extra processing time used to add control properties to every control affected. You also loose the separation of content and presentation, because the properties of skin files are written in the page with the control itself.</p>
<p>Skin files are used to change the appearance only of ASP controls and not their behavior. They can have any naming convention, but it is recommended to name them after the control they affect, if one skin file is applied to a control. Multiple controls can have their appearances changed by one skin file.</p>
<p>The controls assigned in a skin file, must have a runat=&#8221;Sever&#8221; command and for granular control they can have a SkinID attribute to assign the appearance to only those controls that also have the SkinID attribute. The control must be a matching control of the skin file. If no SkinID is named, the skin is called a default skin and only one default skin is allowed to apply to a change.</p>
<p>The theme can be assigned at the page level with a Theme=&#8221;name of folder&#8221; in the page directive. To assign on a directory wide level, you can assign themes in the web.config file with  &lt;pages theme=&#8221;name of folder&#8221;/&gt;</p>
<p>You can also use StyleSheetTheme in the same fashion. StyleSheetTheme behaves more like CSS files, because the properties set in a Theme file will be overridden by any control properties set on the page itself. With a Theme, all local properties set on controls  will be ignored.</p>
<p>You can override themes on a page with the EnableTheming=&#8221;false&#8221; in the page directive.</p>
<p>Any CSS found in Theme folders will be automatically applied if the theme is called, and ASP controls can have classes applied with the CssClass property.</p>
<p>If you have CSS files in the theme folder, be sure to watch how they are named, because they are imported in the page alphabetically, which means any properties set in a file named zebra.css will overwrite properties in a file named apple.css.</p>
<p>It is possible to dynamically assign themes. If you assign a theme with page directives, you will have to use the Page_PreInit event of the page life cycle, but if you use CssClass, you can use the Page_Load event.</p>
<p>You can use a dropdown list with the CssClass method, because the control tree has been created after the PreInit event and before Load, so you can use the following code in the Page_Load:  control.CssClass = dropdownlist.SelectedItem.Text.</p>
<p>With the PreInit method you can use a hyperlink to send a querystring and then access it with: Profile.userTheme = Request["Theme name"]  and then use a switch case to move through the variables and finish with Theme = Profile.UserName.</p>
<p>Of course you will need to add the following to the web.config file:<br />
<code>&lt;profile&gt;<br />
&lt;properties&gt;<br />
&lt;add name="UserTheme"/&gt;<br />
&lt;/properties&gt;<br />
&lt;/profile&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vistalocastudios.com/?feed=rss2&amp;p=14</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Validation Controls</title>
		<link>http://blog.vistalocastudios.com/?p=13</link>
		<comments>http://blog.vistalocastudios.com/?p=13#comments</comments>
		<pubDate>Tue, 28 Jul 2009 07:13:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.vistalocastudios.com/?p=13</guid>
		<description><![CDATA[I listed a few tips below for the proper use of validation controls.
Validation controls can be use with any other control that has the ValidationProperty attribute.
Check the value of Page.IsValid in the Page_Load method to test the values of all the Validation controls on the page.
There are six Validation Controls:  RequiredFieldValidator, RangeValidator, CompareValidator, RegularExpressionValidator, [...]]]></description>
			<content:encoded><![CDATA[<p>I listed a few tips below for the proper use of validation controls.</p>
<p>Validation controls can be use with any other control that has the ValidationProperty attribute.</p>
<p>Check the value of Page.IsValid in the Page_Load method to test the values of all the Validation controls on the page.</p>
<p>There are six Validation Controls:  RequiredFieldValidator, RangeValidator, CompareValidator, RegularExpressionValidator, CustomValidator and ValidationSummary.</p>
<p>Validation is performed on both the client and server sides. Validation can be turned off on the client with the setting EnableClientScript=false</p>
<p>There are three Display properties for the Validation Controls:  Static (default), CSS Visibility property is set to hidden, space on web page taken up even if no message displayed; Dynamic, CSS Display property is set to None, space is used on the web page on if the message is displayed and None with the error displaying in the ValidationSummary.</p>
<p>The Text attribute will accept any HTML string, so it can be used to display an image. Ex: &lt;img src=&#8217;filename.gif&#8217; alt=&#8217;Name is required&#8217; /&gt;</p>
<p>The ValidationGroup attribute allows for more than one form entry on a page, but it needs to be added to all the Validation controls and the button controls. Especially critical with Web Parts.</p>
<p>Controls can have more than one Validation Control assigned to them, and controls are assigned with the Validation Control&#8217;s ControlToValidate attribute.</p>
<p>To ensure the proper usage of a Cancel button add the CausesValidation=&#8217;false&#8217; attribute so no validation will occur when the button is pressed.</p>
<p>With the RequiredFieldValidator use an InitialValue attribute when tied with a DropDownList to ensure user has selected a value other than the default value.</p>
<p>RangeValidator can use a DataType attribute to check the data type of the form field. Default setting is String.</p>
<p>There are three types of CompareValidator: Data Type, Fixed Value and Control comparison. The attributes are Type, ValueToCompare, ControlToCompare. Operator is a necessary value to determine how to compare. There are seven operator values: DataTypeCheck, Equal, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, NotEqual.</p>
<p>When working with Dates, the CompareValidator checks the Short Date format: MM/DD/YYYY, and for currency no symbol is used.</p>
<p>CompareValidator can be used in the Page_Load method. Ex: cmpDate.ValueToCompare = DateTime.Now.ToString(&#8221;d&#8221;). The control still needs an operator and Type.</p>
<p>RegularExpressionValidator uses the ValidationExpression to validate with a regular expression supplied by the programmer. Regular Expressions are available at <a href="http://www.regexlib.com/">regexlib.com</a> Visual Studio 2008 also has several regular expressions available when users open the ValidationExpression property.</p>
<p>The ValidationSummary shows the text set in the Validation control&#8217;s ErrorMessage property. If nothing has been set in the Text property, the ErrorMessage property will display in both the ValidationSummary and the Validation control section of the page. If Display=None than the message only appears in the summary.</p>
<p>There are three Display properties for the ValidationSummary: BulletList, List and SingleParagraph. There are three other properties for the summary: HeaderText, text above the summary display; ShowMessageBox, uses a popup alert box; and ShowSummary to control display of the summary.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vistalocastudios.com/?feed=rss2&amp;p=13</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cookie Basics</title>
		<link>http://blog.vistalocastudios.com/?p=10</link>
		<comments>http://blog.vistalocastudios.com/?p=10#comments</comments>
		<pubDate>Tue, 24 Feb 2009 06:31:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.vistalocastudios.com/?p=10</guid>
		<description><![CDATA[Cookies are a basic feature of ASP.NET, and are automatically implemented when Forms Authentication is configured for your web site. Cookies usage can be configured through the &#8216;Cookieless&#8217; setting of Forms Authentication in the web.config page. On a security note, you should never ask a user if they want their info persisted (&#8221;Remember me Next [...]]]></description>
			<content:encoded><![CDATA[<p>Cookies are a basic feature of ASP.NET, and are automatically implemented when Forms Authentication is configured for your web site. Cookies usage can be configured through the &#8216;Cookieless&#8217; setting of Forms Authentication in the web.config page. On a security note, you should never ask a user if they want their info persisted (&#8221;Remember me Next Time&#8221; checkbox), because they creates a huge opportunity for hackers to forge identities. Another security note is to always use <code>Server.HtmlEncode(Request.Cookies["name of cooke"].Value</code> when you are accessing cookies from the user. NEVER TRUST USER INPUT!</p>
<p>Their are four settings for cookieless: AutoDetect, UseCookies, UseUri and the default UseDeviceProfile. The default will only check the browser capabilities files in ASP.NET to see if the user&#8217;s browser supports cookies. AutoDetect will actually probe the user&#8217;s browser to see if the user has disabled cookies after checking the browser profiles. Either setting can send the authentication token as part of the URL, but AutoDetect is the only setting that will work with those users who have disabled cookies. The UseUri will automatically send the token through the Uniform Resource Identifier (the last section of the URL), but the token will be part of any bookmark of URL emailed by the user.</p>
<p>To set a custom cookie, developers must use the Response.Cookies method and access the Value property. Developers also have the Expires, Domain and Path properties to fine tune their cookie. Examples:</p>
<p><code>Response.Cookies["name of cookie"].Value = "5";  // all cookie values are stored as strings</code><br />
<code>Response.Cookies["name of cookie"].Expires =  DateTime.Now.AddDays(1);</code><br />
<code>Response.Cookies["name of cookie"].Path = "/myfolder";  //cookies will be sent to server only for pages located in myfolder</code><br />
<code>Response.Cookies["name of cookie"].Domain = "mysite.com" //cookies limited to domain or subdomains only</code><br />
<code> Response.Cookies["name of cookie"]["value name"].Value = "value" //for holding multiple values in one cookie</code></p>
<p>You can even limit the cookie to a single server by using the hostname of the server in the Domain property. If you don&#8217;t set an Expires property, the cookie will be automatically deleted when the user closes their browser. You cannot delete a cookie on a user&#8217;s computer, but you can overwrite it and then set a date in the past (DateTime.Now.AddDays(-1) to have the browser delete the cookie.</p>
<p>To check if the user already has a cookie and then access the cookie use the following:</p>
<p><code>if (Request.Cookies["name of cookie"] != null)<br />
label1.Text =  Server.HtmlEncode(Request.Cookies["name of  cookie"].Value);</code></p>
<p>Just remember, Request is from the user and Response is being sent to the user. Sessions are also dependent on cookies and can set the cookie encoding to be sent through the URI with sessionState cookieless = &#8220;true&#8221;</p>
<p>If you have tracing set up in your web.config file, you can use trace.axd to track and debug cookies.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vistalocastudios.com/?feed=rss2&amp;p=10</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ViewState Viewers</title>
		<link>http://blog.vistalocastudios.com/?p=8</link>
		<comments>http://blog.vistalocastudios.com/?p=8#comments</comments>
		<pubDate>Tue, 03 Feb 2009 11:37:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.vistalocastudios.com/?p=8</guid>
		<description><![CDATA[Developers have several methods to view the ViewState payload. The easiest route is to use the Trace settings supplied by ASP.NET either in the web.config file or inserting Trace="true" in the Page directive  of the page you want to examine.
Fritz Onion of PluralSight.com has a tool to decode the ViewState called appropriately ViewState Decoder. [...]]]></description>
			<content:encoded><![CDATA[<p>Developers have several methods to view the ViewState payload. The easiest route is to use the Trace settings supplied by ASP.NET either in the web.config file or inserting <code>Trace="true"</code> in the Page directive  of the page you want to examine.</p>
<p>Fritz Onion of PluralSight.com has a tool to decode the ViewState called appropriately ViewState Decoder. Version 2.2 works with ASP.NET 2.0 web pages. It is available on <a href="http://www.pluralsight.com/tools.aspx">Pluralsight&#8217;s Tool page</a>.</p>
<p>Another free tool built by Nikhil Kothari from the ASP.NET team is called the Web Development Helper. It&#8217;s capabilities go far beyond just viewing the ViewState payload. It&#8217;s also browser centric. The tool can be found at Nikhil&#8217;s web site.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vistalocastudios.com/?feed=rss2&amp;p=8</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error handling</title>
		<link>http://blog.vistalocastudios.com/?p=4</link>
		<comments>http://blog.vistalocastudios.com/?p=4#comments</comments>
		<pubDate>Wed, 05 Mar 2008 00:34:11 +0000</pubDate>
		<dc:creator>vistaloca</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.vistalocastudios.com/?p=4</guid>
		<description><![CDATA[Errors can be handled at three different levels of the ASP.NET web application &#8211; app, page or code (class). To handle errors at the application level, the developer has two files at their command: global.asax and web.config.
At the page level, the developer can use the Page_Error event handler, and at the code level, developers can [...]]]></description>
			<content:encoded><![CDATA[<p>Errors can be handled at three different levels of the ASP.NET web application &#8211; app, page or code (class). To handle errors at the application level, the developer has two files at their command: global.asax and web.config.</p>
<p>At the page level, the developer can use the Page_Error event handler, and at the code level, developers can insert <code>try... catch...finally</code> blocks. These blocks are resource intensive, so they should be used carefully on critical code only, like database connections. Incorrect user input is so common that you shouldn&#8217;t be handled with catch blocks, but with if statements.</p>
<p>The Page_Error handler isn&#8217;t recommend to handle exceptions, and developers should turn to the Application_Error handler. It should also be remembered that you cannot access controls with the Page_Error, because it is called before any controls have been created.</p>
<p>The developer can decide whether to add handling instructions in global.asax and/or web.config with the appropriate .aspx pages to handle the exceptions. If you go with the global.asax file you will use the Application_Error method and to redirect users the Server.Transfer method is considered best practice compared to Response.Redirect, because the Server.Transfer will not create as much traffic. The Response.Redirect makes a call to the client asking the browser to make the request for a new page, while the Server.Transfer will automatically call the new page.</p>
<p>The global.asax code will resemble the following:</p>
<p><code>void Application_Error(object sender EventsArgs e) {<br />
Server.Transfer("handleError.aspx");<br />
}</code></p>
<p>In the .aspx page, you will have a Page_Error method similar to the following:</p>
<p><code>private void Page_Error {<br />
Trace.Write("Error" + Server.GetLastError().Message);<br />
Server.ClearError();<br />
}</code></p>
<p>Trace.Write is the best option, because it will be seen only by the developer, as long as you are sure to have <code>localOnly="true"</code> in the web.config page.</p>
<p>HTTP errors directed at .aspx pages can also be handled with the web.config settings under &lt;custom Errors&gt;. Errors on web pages ending with .htm or text files will not benefit from this setting, because the IIS server will never turn over the handling of these pages to asp.net, so the customErrors settings will never be consulted.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vistalocastudios.com/?feed=rss2&amp;p=4</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accessibility tools</title>
		<link>http://blog.vistalocastudios.com/?p=9</link>
		<comments>http://blog.vistalocastudios.com/?p=9#comments</comments>
		<pubDate>Sat, 09 Feb 2008 19:17:19 +0000</pubDate>
		<dc:creator>vistaloca</dc:creator>
				<category><![CDATA[Accessibility]]></category>

		<guid isPermaLink="false">http://blog.vistalocastudios.com/?p=9</guid>
		<description><![CDATA[There are several free tools and even a Visual Studio internal tool available to check your web pages against the accessibility standards set by the Access Board Section 508 standards and the Web Content Accessibility Guidelines Priority 1 and 2.
The first places to go for HTML and CSS validation are both from the World Wide [...]]]></description>
			<content:encoded><![CDATA[<p>There are several free tools and even a Visual Studio internal tool available to check your web pages against the accessibility standards set by the Access Board Section 508 standards and the Web Content Accessibility Guidelines Priority 1 and 2.</p>
<p>The first places to go for HTML and CSS validation are both from the World Wide Web Consortium (W3) organization. The HTML validator is at <a href="http://validator.w3.org">validator.w3.org</a> and the CSS validation is available at <a href="http://jigsaw.w3.org">jigsaw.w3.org</a>.  W3 also has a web site dedicated to accessibility called the Web Accessibility Initiative</p>
<p>Developers at <a href="http://www.webaim.org">WebAim.org</a> (Web Asccessibility in Mind) have created WAVE,  a web accessibility evaluation tool that uses icons and indicators on your web page to show as close as possible how accessible your web content is. The tool has 28 new accessibility tests, including more detailed evaluation of those missing alt text issues. It works like the W3 tools. You can paste a URL into the web tool, upload a file or paste HTML directly into the tool.</p>
<p>For Visual Studio developers you can check accessibility without leaving your IDE. With an .aspx page or HTML page open, go to the tools menu, and the first option available is Check Accessibility. The tool will check your page against the standards set by the WCAG Priority 1 and 2 and the Access Board Section 508.</p>
<p>Several free tools are available at the <a href="http://www.wat-c.org/">Web Accessibility Tools Consortium</a> (WAT-C), including a <a href="http://www.paciellogroup.com/resources/wat-ie-about.html">browser plugin</a> for IE (including IE7 and Vista) that provides several different perspectives of your web page and also eases the use of 3rd party online applications. That latest version is 2.0 beta and in the latest version no functions use external scripts and most work with javascript disabled.<a href="http://www.w3.org/WAI/"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vistalocastudios.com/?feed=rss2&amp;p=9</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ViewState Persistance</title>
		<link>http://blog.vistalocastudios.com/?p=7</link>
		<comments>http://blog.vistalocastudios.com/?p=7#comments</comments>
		<pubDate>Sun, 03 Feb 2008 04:06:27 +0000</pubDate>
		<dc:creator>vistaloca</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[5]]></category>
		<category><![CDATA[6]]></category>
		<category><![CDATA[7]]></category>

		<guid isPermaLink="false">http://blog.vistalocastudios.com/?p=7</guid>
		<description><![CDATA[Using ViewState is an amazingly easy way to persist state, but it does quickly add weight to a page, especially when a developer is already using Gridview or has a number of server controls on the page. Of course, with more and more users moving to broadband connections, the weight issue falls away. ViewState appears [...]]]></description>
			<content:encoded><![CDATA[<p>Using ViewState is an amazingly easy way to persist state, but it does quickly add weight to a page, especially when a developer is already using Gridview or has a number of server controls on the page. Of course, with more and more users moving to broadband connections, the weight issue falls away. ViewState appears as a hidden form field  _VIEWSTATE on the client side.</p>
<p>Notes!</p>
<p>- ViewState is case sensitive so    ViewState["myKey"]  !=   ViewState["mykey"]</p>
<p>- ViewState can create a lot of encoded text at the top of your page, creating potential issues with search engine spiders and your page&#8217;s SEO.</p>
<p>- While the ViewState value appears as a long string of random ASCII characters on the client side. It is easy to decode on the client side by default. The Page directive can be used to encrypt the string, but it increases server load, so it is best practice to keep sensitive data out of the ViewState.</p>
<p>A web user control combined with ViewState can be an effective way to store user information over an entire web site. A class can be set up to read info from a database and then store the info inside the ViewState. The class must be made serializable to allow storage of information in the ViewState. This is simple to comply with, by inserting the C# code <code>[Serializable] </code> command at the top of the class after the using statements and before the namespace of the class.</p>
<p>T o use the class and insert the properties in the ViewState only take a couple lines of code using C#:</p>
<p><code>ClassName holder = new ClassName();</code><br />
<code><br />
this.ViewState["NameofClass"] = holder;</code></p>
<p>Pulling the data out of the ViewState is only a few more lines of code:<br />
<code><br />
ClassName holder2 = new ClassName();</code></p>
<p><code>holder2 = this.ViewState["NameofClass"] as NameofClass;</code></p>
<p>Then populate the web user control:</p>
<p><code>label1.Text = holder2.property</code> (add a .ToString if the value pulled out is not a string.</p>
<p>The web user control can be placed on any number of pages, and the ViewState will be utilized to provide a &#8217;stateful&#8217; option for web developers. The ViewState connection will need to be run on the Page_Load event of the user control, because the ViewState isn&#8217;t formed until after the _Init events.  You will also want to check the status of the ViewState in the user control to ensure the database isn&#8217;t called when the info is already stored in ViewState.</p>
<p>The code to check is even simpler:</p>
<p><code>if (this.ViewState["ItemName"] == null) </code> or  <code> if  !(this.ViewState["ItemName"])</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vistalocastudios.com/?feed=rss2&amp;p=7</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blog goals</title>
		<link>http://blog.vistalocastudios.com/?p=5</link>
		<comments>http://blog.vistalocastudios.com/?p=5#comments</comments>
		<pubDate>Sun, 27 Jan 2008 17:55:55 +0000</pubDate>
		<dc:creator>vistaloca</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.vistalocastudios.com/?p=5</guid>
		<description><![CDATA[With this blog, I want to offer my thoughts and reflections on the latest computer and web technologies, focusing on the platforms and tools available for web programmers and designers, and finally record and direct my efforts as I work towards a career in web programming and design. 
I will also use this blog as [...]]]></description>
			<content:encoded><![CDATA[<p>With this blog, I want to offer my thoughts and reflections on the latest computer and web technologies, focusing on the platforms and tools available for web programmers and designers, and finally record and direct my efforts as I work towards a career in web programming and design. <code></p>
<p></code>I will also use this blog as a learning resource to record the techniques and best practices I discover Â from the various sources I come across from books, magazines and the Internet. I will record those sources along with my notes to create an online knowledge base for future reference and study. <code></p>
<p></code>I am pursuing a career as an ASP.NET developer so the great majority of information on my blog will focus on the Microsoft technology. But my blog won&#8217;t be limited to ASP. Â I have experience with PHP and most of the Adobe (and former Macromedia) product line. I think Flex and AIR have great potential and I will continue to study those languages, products and technologies.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.vistalocastudios.com/?feed=rss2&amp;p=5</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
