<?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>Quinterox &#187; ASP.NET</title>
	<atom:link href="http://www.quinterox.com/content/category/code/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.quinterox.com/content</link>
	<description>Cesar Quinteros</description>
	<lastBuildDate>Sun, 20 Jun 2010 04:51:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Adding expire tags to your CSS and JavaScript files</title>
		<link>http://www.quinterox.com/content/blog/expire-tags-adding-them-to-your-css-javascript/</link>
		<comments>http://www.quinterox.com/content/blog/expire-tags-adding-them-to-your-css-javascript/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 08:02:33 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[set expire]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=451</guid>
		<description><![CDATA[Adding expiration headers to PHP/ASP files.]]></description>
			<content:encoded><![CDATA[<p>Though we live in an age where a lot of people have fast internet connections. The focus (at least for developers) has shifted to technologies that relieve the server of heavy workloads and increase processing speeds such as AJAX, using server-side and client-side caching, as well as gzipping. In this post I will lightly touch upon client-side caching of dynamically generated CSS and JavaScript files.</p>
<p>I recently installed YSlow, a handy web development tool for Firefox. In it there is an option that tells you whether your CSS or JavaScript files are cached on the client&#8217;s computer allowing for a quicker page load. I noticed my files were not cached so I looked a little into how to go about caching them so the browser won&#8217;t download the same file over and over when going from page to page. So I went about conducting my own tests to see how to make this happen. The only way of making it happen other than setting an expire date/time on the WHOLE page (or on the .htaccess file in Linux servers) was to create a server-side file that would output the expiration, content type headers as well as the actual styles/code in your web application. Below is a clearer picture of how I made it happen.</p>
<h3>PHP- Step 1.</h3>
<p>Make a dynamically generated CSS file that includes expiration and content headers (code below). Save it as &#8216;dynamic_css.php&#8217;. The actual CSS styling can be typed in the same way you would do in a regular stylesheet, we are only after getting those expiration and content type headers sent out.</p>
<pre>&lt;?php
header("Expires: Thu, 31 Dec 2020 20:00:00 GMT");
header('Content-type: text/css');
?&gt;
h1 { color: Red; }</pre>
<p><br class="clear" /></p>
<h3>PHP- Step 2.</h3>
<p>Add &#8216;dynamic_css.php&#8217; as the CSS href of you document. This should make YSlow happy and increase the speed at which the user navigates through pages that use the same CSS file. Use the same method to add expiration tags to JavaScript.</p>
<pre>&lt;link rel="stylesheet" type="text/css" <strong><span style="color: #ff0000;">href="dynamic_css.php"</span></strong>/&gt;</pre>
<p><br class="clear" /></p>
<h3>ASP- Step 1.</h3>
<p>The way I added expire tags to my CSS code in ASP is very similar to PHP&#8217;s. First you make a server-side CSS file and save it as &#8216;dynamic_css.aspx&#8217;. Since it is important the headers hit the server first we use server-side code  to send those out first. We type in the actual CSS code like we would in a regular CSS file after that. Besides would you really want to Response.Write() all of your CSS code? I think not.</p>
<pre>&lt;%
    Response.Expires = 3600
    Response.ContentType = "text/css"
%&gt;
    h1 { color: Blue; }</pre>
<p><br class="clear" /></p>
<h3>ASP- Step 2.</h3>
<p>Add &#8216;dynamic_css.aspx&#8217; as the CSS source of you document. This should make YSlow happy since the expiration headers are now being sent increasing the speed at which the user navigates through the pages that share the same CSS file. Use this same header method to add expiration tags to JavaScript files.</p>
<pre>&lt;link rel="stylesheet" type="text/css" <strong><span style="color: #ff0000;">href="dynamic_css.aspx"</span></strong>/&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/blog/expire-tags-adding-them-to-your-css-javascript/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>If, else, elseif, statements</title>
		<link>http://www.quinterox.com/content/code/if-else-elseif-statements/</link>
		<comments>http://www.quinterox.com/content/code/if-else-elseif-statements/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 04:15:32 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[conditional statement]]></category>

		<guid isPermaLink="false">http://quinterox.com/code/?p=33</guid>
		<description><![CDATA[Simple use of conditional statements.]]></description>
			<content:encoded><![CDATA[<p>Conditional statements are probably the easiest-to-use most useful statements within a programming language. Below I give a brief example of how to use it.</p>
<pre>if strVariable1 = “John”
Response.Write(”Welcome John!”)
elseif strVariable1 = “Bob”
Response.Write(”Welcome Bob!”)
else
Response.Write(”Welcome…you.”)</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/if-else-elseif-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Request.Querystring()</title>
		<link>http://www.quinterox.com/content/code/requestquerystring/</link>
		<comments>http://www.quinterox.com/content/code/requestquerystring/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 04:14:22 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[request.querystring]]></category>

		<guid isPermaLink="false">http://quinterox.com/code/?p=32</guid>
		<description><![CDATA[Simple use of Request.Querystring]]></description>
			<content:encoded><![CDATA[<p>The Request.QueryString() function is useful when you need to pass information to your application based on user interaction. For example if you have a GridView control full of names and you want to pass either the value of a datakey or the selection the user made itself to your application to return more detailed data you can use the Request.QueryString() function to do so.</p>
<pre>Label1.Text.Request.QueryString(”qtext”)</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/requestquerystring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OleDb &#8211; Simple Database Databinding</title>
		<link>http://www.quinterox.com/content/code/oledb-simple-database-databinding/</link>
		<comments>http://www.quinterox.com/content/code/oledb-simple-database-databinding/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 04:12:24 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[access 2007]]></category>
		<category><![CDATA[databind]]></category>
		<category><![CDATA[oledb]]></category>

		<guid isPermaLink="false">http://quinterox.com/code/?p=31</guid>
		<description><![CDATA[Binding database data to a gridview using a datareader.]]></description>
			<content:encoded><![CDATA[<p>If you do not have MS SQL installed (Why not? The Express version is free!) or prefer the portability MS Access provides then you might want to learn how to create an OleDbConnection, part of the System.Data.OleDb namespace, as opposed to SqlConnection which is part of the System.Data.SqlClient namespace. Here is a quick example of how an OleDbConnection string is used.</p>
<pre>Dim objConn As OleDbConnection
Dim objRDR As OleDbDataReader
Dim objCmd As OleDbCommand
objConn = New OleDbConnection( _
“Provider=Microsoft.ACE.OLEDB.12.0;Data Source=” &amp; _
“E:Documentsdatabasestest.accdb”)
objCmd = New OleDbCommand(”SELECT [first], [last] FROM [names]“, objConn)
objConn.Open()
objRdr = objCmd.ExecuteReader()
GridView1.DataSource = objRdr
GridView1.DataBind()</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/oledb-simple-database-databinding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using configSource</title>
		<link>http://www.quinterox.com/content/code/using-configsource/</link>
		<comments>http://www.quinterox.com/content/code/using-configsource/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 02:39:03 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[configsource]]></category>
		<category><![CDATA[web.config]]></category>

		<guid isPermaLink="false">http://quinterox.com/code/?p=25</guid>
		<description><![CDATA[Example of how to allocate an external config file with connection string information to your main config file allowing you to harness the power of a more intricate way to manage user permissions.]]></description>
			<content:encoded><![CDATA[<p>In order to change configuration settings within an application without restarting and to harness the power of a more intricate ability to manage user permissions, it is ideal to store connection strings and other data in an external file. Below I demonstrate how to make the web.config file call to an external file for a connection string. This can also be done for connection strings stored as keys in the appSettings tag.</p>
<pre>&lt;configuration&gt;
&lt;appSettings/&gt;
&lt;connectionStrings configSource=”conns.config”&gt;&lt;/connectionStrings&gt;
&lt;system.web&gt;
&lt;/system.web&gt;
&lt;/configuration&gt;</pre>
<p>The conns.config file will then only contain a single section element and nothing else. Yes it is that simple.</p>
<pre>&lt;connectionStrings&gt;
&lt;add name=”myConnectionString”
connectionString=”Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=C:My Database Foldermydatabase.mdb;
Jet OLEDB:Database Password=mypassword” providerName=”SQLOLEDB”/&gt;
&lt;/connectionStrings&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/using-configsource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>String vs. String()</title>
		<link>http://www.quinterox.com/content/code/string-vs-string/</link>
		<comments>http://www.quinterox.com/content/code/string-vs-string/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 05:25:16 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[directories]]></category>
		<category><![CDATA[for each]]></category>

		<guid isPermaLink="false">http://quinterox.com/code/?p=24</guid>
		<description><![CDATA[Something great I noticed about the difference of dimming as String and as String().]]></description>
			<content:encoded><![CDATA[<p>I noticed something today, when you add the () to the end of the word String it actually instantiates an array as opposed to just the word String. Here is an example that depicts that:</p>
<pre>Dim strThemesFolder As String = Server.MapPath("~contentthemes")
<span style="color: #00ff00;"><span><span style="color: #008000;">'Notice the Array below, a regular string wouldn't be able to hold all those values</span></span>
</span>
Dim strThemeFolders As String() = Directory.GetDirectories(strThemesFolder)
Dim strFolderName As String
For Each strFolderName In strThemeFolders
      Response.Write(strFolderName)
Next</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/string-vs-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing MasterPageFile</title>
		<link>http://www.quinterox.com/content/code/changing-masterpagefile/</link>
		<comments>http://www.quinterox.com/content/code/changing-masterpagefile/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 06:05:22 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[masterpage]]></category>
		<category><![CDATA[masterpagefile]]></category>

		<guid isPermaLink="false">http://quinterox.com/code/?p=23</guid>
		<description><![CDATA[This snippet is from a web app I was developing in ASP.NET that had to have the ability to switch skins upon the administrator's command.]]></description>
			<content:encoded><![CDATA[<h2>Snippet-Admin/Default.aspx</h2>
<p>I added this code to my admin files to enable me to change masterfilepages on the fly. I tried with global variables and with properties but my masterpagefile would always default back the hardcoded file somehow.</p>
<pre>
Private Function changeTheme(ByVal strNewThemePath As String) As String
        If File.Exists(Server.MapPath(strNewThemePath)) Then
            Application.Set("theme", strNewThemePath)
            Return String.Format("Theme changed successfully to: ""{0}""", strNewThemePath)
        Else
            Return String.Format("The file: ""{0}"" does not exist. Theme not changed.", strNewThemePath)
        End If
End Function
</pre>
<h2>Snippet-Global.asax</h2>
<p>I also added this to the global.asax file since the code above did not specify a default theme.</p>
<pre>    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        'If no other theme is chosen then load the default
        If Application("theme") Is Nothing Then
            Dim Config As New Config
            Application("theme") = Config.strDefaultTheme
        End If
    End Sub</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/changing-masterpagefile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading an html file</title>
		<link>http://www.quinterox.com/content/code/reading-an-html-file/</link>
		<comments>http://www.quinterox.com/content/code/reading-an-html-file/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 03:52:10 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[streamreader]]></category>

		<guid isPermaLink="false">http://quinterox.com/code/?p=22</guid>
		<description><![CDATA[A sweet and simple way to load a file's text into a textarea control.]]></description>
			<content:encoded><![CDATA[<p>This is how to read an html file, it could be used for text files too. The extension doesn&#8217;t seem to matter.</p>
<pre>
Sub readFile()
        Dim rdr As StreamReader = New StreamReader(Server.MapPath("test.htm"))
        Me.textAreaControl.InnerText = rdr.ReadToEnd
End Sub
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/reading-an-html-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting And Getting Public Properties</title>
		<link>http://www.quinterox.com/content/code/setting-and-getting-public-properties/</link>
		<comments>http://www.quinterox.com/content/code/setting-and-getting-public-properties/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 04:31:53 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[set]]></category>

		<guid isPermaLink="false">http://quinterox.com/code/?p=21</guid>
		<description><![CDATA[A simple example of setting and getting public properties.]]></description>
			<content:encoded><![CDATA[<p>I am not 100% sure how public properties are supposed to be used but I intend to use it to store the current user&#8217;s name and email. It could also be used to store blog information momentarily.</p>
<pre>
Private mstrName As String
Public Property Name() As String
        Get
            Name = mstrName
           ' Returns default value if nothing has changed it
        End Get
        Set(ByVal pstrName As String)
            mstrName  = pstrName
           'Sets the name to be the newly entered value
        End Set
 End Property
</pre>
<p>The information can then be retrieved or set as follows:</p>
<pre>
Dim settingsClass As New 'yourClassName'

Response.Write(settingsClass.Name)
'Returns Cesar
settingsClass.Name = "John"
'Assigns 'John' to the name property
Response.Write(settingsClass.Name)
'Returns John
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/setting-and-getting-public-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
