<?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>ASP.NET 2.0 Plus Recipes</title>
	<atom:link href="http://aspnetgoodies.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://aspnetgoodies.wordpress.com</link>
	<description>A few tips and tricks for the beginner</description>
	<lastBuildDate>Wed, 19 Dec 2007 23:19:29 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='aspnetgoodies.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/4a781797b011668002ae9839d842fea8?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>ASP.NET 2.0 Plus Recipes</title>
		<link>http://aspnetgoodies.wordpress.com</link>
	</image>
			<item>
		<title>Display Email Link In GridView (mailto:)</title>
		<link>http://aspnetgoodies.wordpress.com/2007/12/18/display-email-link-in-gridview-mailto/</link>
		<comments>http://aspnetgoodies.wordpress.com/2007/12/18/display-email-link-in-gridview-mailto/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 23:59:19 +0000</pubDate>
		<dc:creator>aspnetgoodies</dc:creator>
				<category><![CDATA[Display Email Link In GridView (mailto:)]]></category>
		<category><![CDATA[Display Email Link GridView mailto:]]></category>

		<guid isPermaLink="false">http://aspnetgoodies.wordpress.com/2007/12/18/display-email-link-in-gridview-mailto/</guid>
		<description><![CDATA[This article describes how to do display clickable email links (mailto:) in a ASP.NET GridView. Often in our projects, it is a requirement to display clickable email links in a GridView perhapse along other information. Because of the initial and seemingly convoluted nature of ASP.NET, even a simple task as such can seem daunting. Well, fear not because this is really simple to do.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=118&subd=aspnetgoodies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><u><font color="#0080c0">Objective:</font></u> This article describes how to do display clickable email links (mailto:) in a ASP.NET GridView.</p>
<p><u><font color="#0080c0">Background:</font></u> Often in our projects, it is a requirement to display clickable email links in a GridView perhapse along other information. Because of the initial and seemingly convoluted nature of ASP.NET, even a simple task as such can seem daunting. Well, fear not because this is really simple to do.</p>
<p><u><font color="#0080c0">Procedure:</font></u> Follow instructions below to accomplish this task. This article uses Visual Web Developer Express 2008, SQL Server Express 2005.</p>
<ol>
<li>Create a new web form in your site and name it anything.
<li>Drag and drop a GridView onto the page.
<li>Configure your DataSource. Select a table that displays email addresses.
<li>Once you have configured your GridView and DataSource, click on the GridView&#8217;s smart tag and select &#8220;edit columns&#8221;.
<li>In the selected fields window click to highlight the field that contains the email addresses.
<li>On the right side, click on the &#8220;convert this field into a TemplateField link.
<li>Click OK to close this window and go into source view look at GridView&#8217;s ItemTemplate. It should look something like this:</p>
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;overflow:auto;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:70px;padding:4px;">
<pre><span style="color:blue;">&lt;</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;
    &lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label </span><span style="color:red;">ID</span><span style="color:blue;">="Label1" </span><span style="color:red;">runat</span><span style="color:blue;">="server" </span><span style="color:red;">Text</span><span style="color:blue;">='</span><span style="background:#ffee62;">&lt;%</span># Bind("Email") <span style="background:#ffee62;">%&gt;</span><span style="color:blue;">'&gt;&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label</span><span style="color:blue;">&gt;
&lt;/</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></div>
<p></p>
<li>Now let&#8217;s modify this code to create clickable mailto: email addresses. To do this, replace the above code with the one below.
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;overflow:auto;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:70px;padding:4px;">
<pre><span style="color:blue;">&lt;</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;
    &lt;</span><span style="color:#a31515;">a </span><span style="color:red;">href</span><span style="color:blue;">="Mailto:</span><span style="background:#ffee62;">&lt;%</span># Eval("email") <span style="background:#ffee62;">%&gt;</span><span style="color:blue;">"&gt;</span><span style="background:#ffee62;">&lt;%</span><span style="color:blue;">#</span>Eval(<span style="color:#a31515;">"email"</span>)<span style="background:#ffee62;">%&gt;</span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">a</span><span style="color:blue;">&gt;
&lt;/</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></div>
<p>This will result looking something like the image below:</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/mailto-with-email-address.jpg"><img style="border-width:0;" height="127" alt="mailto-with-email-address" src="http://aspnetgoodies.files.wordpress.com/2007/12/mailto-with-email-address-thumb.jpg?w=244&#038;h=127" width="244" border="0"></a> </p>
<li>If you don&#8217;t want to show the actual email addresses as the link maybe to have all the links a uniform look and size, you can do something like the following.
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;overflow:auto;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:70px;padding:4px;">
<pre><span style="color:blue;">&lt;</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;
    &lt;</span><span style="color:#a31515;">a </span><span style="color:red;">href</span><span style="color:blue;">="Mailto:</span><span style="background:#ffee62;">&lt;%</span># Eval("email") <span style="background:#ffee62;">%&gt;</span><span style="color:blue;">"&gt;</span>Click To Email<span style="color:blue;">&lt;/</span><span style="color:#a31515;">a</span><span style="color:blue;">&gt;
&lt;/</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></div>
<p>This will result in something like the image below.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/mailto-with-static-text.jpg"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;" height="73" alt="mailto-with-static-text" src="http://aspnetgoodies.files.wordpress.com/2007/12/mailto-with-static-text-thumb.jpg?w=244&#038;h=73" width="244" border="0"></a> </p>
<li>That&#8217;s it! Enjoy.</li>
</ol>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/aspnetgoodies.wordpress.com/118/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/aspnetgoodies.wordpress.com/118/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aspnetgoodies.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aspnetgoodies.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aspnetgoodies.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aspnetgoodies.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aspnetgoodies.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aspnetgoodies.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aspnetgoodies.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aspnetgoodies.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aspnetgoodies.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aspnetgoodies.wordpress.com/118/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=118&subd=aspnetgoodies&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://aspnetgoodies.wordpress.com/2007/12/18/display-email-link-in-gridview-mailto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2949e6f1224f8b5f410d410d7eeba3a1?s=96&#38;d=identicon" medium="image">
			<media:title type="html">aspnetgoodies</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/mailto-with-email-address-thumb.jpg" medium="image">
			<media:title type="html">mailto-with-email-address</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/mailto-with-static-text-thumb.jpg" medium="image">
			<media:title type="html">mailto-with-static-text</media:title>
		</media:content>
	</item>
		<item>
		<title>Maintain Scroll Position On Postback in ASP.NET</title>
		<link>http://aspnetgoodies.wordpress.com/2007/12/18/maintain-scroll-position-on-postback-in-aspnet/</link>
		<comments>http://aspnetgoodies.wordpress.com/2007/12/18/maintain-scroll-position-on-postback-in-aspnet/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 20:23:38 +0000</pubDate>
		<dc:creator>aspnetgoodies</dc:creator>
				<category><![CDATA[Maintain Scroll Position On Postback in ASP.NET]]></category>
		<category><![CDATA[Maintain Scroll Position Postback ASP.NET Directive Att]]></category>

		<guid isPermaLink="false">http://aspnetgoodies.wordpress.com/2007/12/18/maintain-scroll-position-on-postback-in-aspnet/</guid>
		<description><![CDATA[This article describes how to maintain scroll position on postback in ASP.NET. Gets or sets a value indicating whether to return the user to the same position in the client browser after postback. This property replaces the obsolete SmartNavigation property. This is a very simple procedure that takes but a second or two to achieve.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=113&subd=aspnetgoodies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><u><font color="#0080c0">Objective:</font></u> This article describes how to maintain scroll position on postback in ASP.NET.</p>
<p><u><font color="#0080c0">Background:</font></u> Gets or sets a value indicating whether to return the user to the same position in the client browser after postback. This property replaces the obsolete <a href="http://msdn2.microsoft.com/en-us/library/c4b8y7xk%28VS.90%29.aspx" target="_blank">SmartNavigation</a> property. This is a very simple procedure that takes but a second or two to achieve.</p>
<p><u><font color="#0080c0">Procedure:</font></u> Follow instructions below to accomplish this task. This article uses Visual Web Developer Express 2008.</p>
<ol>
<li>On the page you require this functionality, simply add the following attribute to your page directive on the very top of your page: </p>
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;overflow:auto;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:70px;padding:4px;">
<pre><span style="color:green;">&lt;!-- Adding the maintain scroll position attribute to page directive --&gt;
</span><span style="background:#ffee62;">&lt;%</span><span style="color:blue;">@ </span><span style="color:#a31515;">Page </span><span style="color:red;">Language</span><span style="color:blue;">="VB" </span><span style="color:red;">MaintainScrollPositionOnPostback</span><span style="color:blue;">="true" </span><span style="background:#ffee62;">%&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></div>
<p></p>
<li>To test out how this works, I use the NorthWind database.
<li>In design view, let&#8217;s drop a GridView on to the page and configure a DataSource for it.
<li>Select the Customers table because it has enough data to make it a long page without paging. For this example I selected the CustomerID, CompanyName and ContactName columns.
<li>Click on the Advanced button and check both checkboxes to create the Insert, Delete, Edit statements.
<li>When you are finished, open the smart tag on the GridView and select the Enable Editing and Enable Selection checkboxes.
<li>Save the page and load it into your browser.
<li>Scroll down half way and click on either the Select or Edit button. Although the page will post back due to a server side action, it will now not reposition you to the top of the page, instead it will maintain the same exact position. It is nice not having to manually scroll into position every time you click a button.
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/maintain-scroll-position.jpg"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;" height="234" alt="maintain-scroll-position" src="http://aspnetgoodies.files.wordpress.com/2007/12/maintain-scroll-position-thumb.jpg?w=244&#038;h=234" width="244" border="0"></a> </p>
<li>That&#8217;s it! Enjoy.</li>
</ol>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/aspnetgoodies.wordpress.com/113/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/aspnetgoodies.wordpress.com/113/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aspnetgoodies.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aspnetgoodies.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aspnetgoodies.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aspnetgoodies.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aspnetgoodies.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aspnetgoodies.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aspnetgoodies.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aspnetgoodies.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aspnetgoodies.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aspnetgoodies.wordpress.com/113/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=113&subd=aspnetgoodies&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://aspnetgoodies.wordpress.com/2007/12/18/maintain-scroll-position-on-postback-in-aspnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2949e6f1224f8b5f410d410d7eeba3a1?s=96&#38;d=identicon" medium="image">
			<media:title type="html">aspnetgoodies</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/maintain-scroll-position-thumb.jpg" medium="image">
			<media:title type="html">maintain-scroll-position</media:title>
		</media:content>
	</item>
		<item>
		<title>GridView Delete Confirmation Dialogue in ASP.NET</title>
		<link>http://aspnetgoodies.wordpress.com/2007/12/18/gridview-delete-confirmation-dialogue-in-aspnet/</link>
		<comments>http://aspnetgoodies.wordpress.com/2007/12/18/gridview-delete-confirmation-dialogue-in-aspnet/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 08:54:45 +0000</pubDate>
		<dc:creator>aspnetgoodies</dc:creator>
				<category><![CDATA[GridView Delete Confirmation in ASP.NET]]></category>
		<category><![CDATA[GridView Delete Confirmation Dialogue in ASP.NET]]></category>

		<guid isPermaLink="false">http://aspnetgoodies.wordpress.com/2007/12/18/gridview-delete-confirmation-dialogue-in-aspnet/</guid>
		<description><![CDATA[This article provides step by step instruction for how to add delete confirmation to a GridView in ASP.NET. In a previous article I have illustrated a simple way of adding a client side confirm popup action to any button on your page. In this article we will use the same technique for the GridView delete button. It is a very simple procedure with the only tricky part being for the beginner is to learn how to expose this part of the GridView so we can assign a few simple properties to it. To read my previous tutorial please click ** Here **.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=110&subd=aspnetgoodies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><u><font color="#0080c0">Objective:</font></u> This article provides step by step instruction for how to add delete confirmation to a GridView in ASP.NET.</p>
<p><u><font color="#0080c0">Background:</font></u> In a previous article I have illustrated a simple way of adding a client side confirm popup action to any button on your page. In this article we will use the same technique for the GridView delete button. It is a very simple procedure with the only tricky part being for the beginner is to learn how to expose this part of the GridView so we can assign a few simple properties to it. To read my previous tutorial please click <a href="http://aspnetgoodies.wordpress.com/category/client-side-onclick-confirm-popup-plus-mouse-over-action-in-aspnet/">** Here **.</a></p>
<p><u><font color="#0080c0">Procedure:</font></u> Follow instructions below to accomplish this task. This article uses Visual Web Developer Express 2008, SQL Server 2005 Express and the NorthWind database.</p>
<ol>
<li>Let&#8217;s start by adding a new web form to your site and name it anything you want.
<li>From the Data tab of your toolbox, drag and drop a a GridView onto the page.
<li>If its not already open, click to open the GridView&#8217;s Smart Tag and add a new DataSource.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/grid-view-smart-tag.jpg"><img style="border-width:0;" height="158" alt="grid-view-smart-tag" src="http://aspnetgoodies.files.wordpress.com/2007/12/grid-view-smart-tag-thumb.jpg?w=244&#038;h=158" width="244" border="0"></a> <br /> 
<li>For simplicity&#8217;s sake, let&#8217;s create a simple SqlDataSource of your choosing. For this article I&#8217;m using the NorthWind database from Microsoft.
<li>From the Employees table, I select the following columns: EmployeeID, LastName, and FirstName.
<li>Then I click on the &#8220;Advanced&#8221; button and check the &#8220;Generate Insert, Update and Delete Statements&#8221; checkbox and also the (Use optimistic concurrency&#8221; checkbox and click OK.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/generate-insert-update-delete.jpg"><img style="border-width:0;" height="180" alt="generate-insert-update-delete" src="http://aspnetgoodies.files.wordpress.com/2007/12/generate-insert-update-delete-thumb.jpg?w=244&#038;h=180" width="244" border="0"></a> <br /> 
<li>Then I click Next and Finish to finish creating my GridView.
<li>Now from the GridView&#8217;s Smart Tag I check the boxes for Enable Paging, Enable Editing, and Enable Deleting. Really, the Enable Deleting is the only one we need, I&#8217;m just playing along to make things a bit more realistic.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/grid-view-tasks.jpg"><img style="border-width:0;" height="172" alt="grid-view-tasks" src="http://aspnetgoodies.files.wordpress.com/2007/12/grid-view-tasks-thumb.jpg?w=244&#038;h=172" width="244" border="0"></a> <br /> 
<li>Now from the GridView&#8217;s Smart Tag and click on the Edit Column link.
<li>Then from the Selected Fields area I click to highlight the CommandField on top of the list to expose its CommandField properties on the right.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/command-field-properties.jpg"><img style="border-width:0;" height="187" alt="command-Field-Properties" src="http://aspnetgoodies.files.wordpress.com/2007/12/command-field-properties-thumb.jpg?w=244&#038;h=187" width="244" border="0"></a> <br /> 
<li>From the ButtonType property I then select the Button instead of the Link display type and click the &#8220;convert this field into a template field&#8221; link and finally click OK.
<li>Now that I have converted this field into a template field and exposed its properties, I can go into code view an add a couple of properties to it. So, let&#8217;s go into code view and find the Delete button. It should look like below. Showing both the Edit and Delete button between the ItemTemplate tags:</p>
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;overflow:auto;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:150px;padding:4px;">
<pre><span style="color:blue;">&lt;</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;
    &lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Button </span><span style="color:red;">ID</span><span style="color:blue;">="Button1" </span><span style="color:red;">runat</span><span style="color:blue;">="server" </span><span style="color:red;">CausesValidation</span><span style="color:blue;">="False"
        </span><span style="color:red;">CommandName</span><span style="color:blue;">="Edit" </span><span style="color:red;">Text</span><span style="color:blue;">="Edit" /&gt;
    </span><span style="color:red;">&amp;nbsp;</span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Button </span><span style="color:red;">ID</span><span style="color:blue;">="Button2" </span><span style="color:red;">runat</span><span style="color:blue;">="server" </span><span style="color:red;">CausesValidation</span><span style="color:blue;">="False"
        </span><span style="color:red;">CommandName</span><span style="color:blue;">="Delete" </span><span style="color:red;">Text</span><span style="color:blue;">="Delete" /&gt;
&lt;/</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></div>
<p></p>
<li>Finally, I add the following client side javascript property to my Delete button: OnClientClick=&#8221;return confirm(&#8216;Are you sure?&#8217;);&#8221;. The result should look like the code below:
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;overflow:auto;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:200px;padding:4px;">
<pre><span style="color:blue;">&lt;</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;
    &lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Button </span><span style="color:red;">ID</span><span style="color:blue;">="Button1" </span><span style="color:red;">runat</span><span style="color:blue;">="server" </span><span style="color:red;">CausesValidation</span><span style="color:blue;">="False"
        </span><span style="color:red;">CommandName</span><span style="color:blue;">="Edit" </span><span style="color:red;">Text</span><span style="color:blue;">="Edit" /&gt;
    </span><span style="color:red;">&amp;nbsp;</span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Button
            </span><span style="color:red;">ID</span><span style="color:blue;">="Button2" </span><span style="color:red;">runat</span><span style="color:blue;">="server"
            </span><span style="color:red;">CausesValidation</span><span style="color:blue;">="False"
            </span><span style="color:red;">CommandName</span><span style="color:blue;">="Delete"
            </span><span style="color:red;">Text</span><span style="color:blue;">="Delete"
            </span><span style="color:red;">OnClientClick</span><span style="color:blue;">="return confirm('Are you sure?');" /&gt;
&lt;/</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></div>
<p></p>
<li>Change the message for the popup dialogue as desired. Load the page into your browser to give it a spin.
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/gridview-delete-confirm.jpg"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;" height="244" alt="gridview-delete-confirm" src="http://aspnetgoodies.files.wordpress.com/2007/12/gridview-delete-confirm-thumb.jpg?w=224&#038;h=244" width="224" border="0"></a> </p>
<li>That&#8217;s it! Enjoy.</li>
</ol>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/aspnetgoodies.wordpress.com/110/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/aspnetgoodies.wordpress.com/110/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aspnetgoodies.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aspnetgoodies.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aspnetgoodies.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aspnetgoodies.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aspnetgoodies.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aspnetgoodies.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aspnetgoodies.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aspnetgoodies.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aspnetgoodies.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aspnetgoodies.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=110&subd=aspnetgoodies&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://aspnetgoodies.wordpress.com/2007/12/18/gridview-delete-confirmation-dialogue-in-aspnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2949e6f1224f8b5f410d410d7eeba3a1?s=96&#38;d=identicon" medium="image">
			<media:title type="html">aspnetgoodies</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/grid-view-smart-tag-thumb.jpg" medium="image">
			<media:title type="html">grid-view-smart-tag</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/generate-insert-update-delete-thumb.jpg" medium="image">
			<media:title type="html">generate-insert-update-delete</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/grid-view-tasks-thumb.jpg" medium="image">
			<media:title type="html">grid-view-tasks</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/command-field-properties-thumb.jpg" medium="image">
			<media:title type="html">command-Field-Properties</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/gridview-delete-confirm-thumb.jpg" medium="image">
			<media:title type="html">gridview-delete-confirm</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.NET Request Validation &#8211; Preventing Script Attacks</title>
		<link>http://aspnetgoodies.wordpress.com/2007/12/18/request-validation-preventing-script-attacks/</link>
		<comments>http://aspnetgoodies.wordpress.com/2007/12/18/request-validation-preventing-script-attacks/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 02:43:05 +0000</pubDate>
		<dc:creator>aspnetgoodies</dc:creator>
				<category><![CDATA[ASP.NET Request Validation - Preventing Script Attacks]]></category>

		<guid isPermaLink="false">http://aspnetgoodies.wordpress.com/2007/12/18/request-validation-preventing-script-attacks/</guid>
		<description><![CDATA[This article describes the request validation feature of ASP.NET which, by default, prevents the processing of unencoded HTML content submitted to the server. This request validation feature can be disabled when the application has been designed to safely process HTML data.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=101&subd=aspnetgoodies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><u><font color="#0080c0">Objective:</font></u> This article describes the request validation feature of ASP.NET which, by default, prevents the processing of unencoded HTML content submitted to the server. This request validation feature can be disabled when the application has been designed to safely process HTML data.</p>
<p><u><font color="#0080c0">Background:</font></u> More often than not, I use a rich text editor in my administrative forms to replace a multi-line text box for its obvious advantages. Rich text box editors are useful because they allow us to create layouts of text and images just like a word processor would providing a layer of aesthetics and convenience. This rich functionality is made possible by rapping the content with HTML/XHTML markup. This is all good and well with exception that ASP.NET 1.1 and above by <u><strong>default</strong></u> stops the submission of forms with such content for reasons of security &#8211; preventing the execution of malicious code. To allow such functionality to take place, we can simply add a directive at the top of our page to turn off request validation.</p>
<p><u><font color="#0080c0">Procedure:</font></u> </p>
<ol>
<li>Open the web form where HTML markup is going to be submitted in your form. Below is an example:</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/html-in-form.jpg"><img style="border-width:0;" height="234" alt="html-in-form" src="http://aspnetgoodies.files.wordpress.com/2007/12/html-in-form-thumb.jpg?w=244&#038;h=234" width="244" border="0"></a> <br /> 
<li>Add the following to the page directive on top of the page like shown below. ValidateRequest=&#8221;False&#8221;.</p>
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;overflow:auto;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:50px;padding:4px;">
<pre><span style="background:#ffee62;">&lt;%</span><span style="color:blue;">@ </span><span style="color:#a31515;">Page </span><span style="color:red;">Language</span><span style="color:blue;">="VB" </span><span style="color:red;">ValidateRequest</span><span style="color:blue;">="False" </span><span style="background:#ffee62;">%&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></div>
<p></p>
<li>That&#8217;s it! Enjoy.</li>
</ol>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/aspnetgoodies.wordpress.com/101/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/aspnetgoodies.wordpress.com/101/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aspnetgoodies.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aspnetgoodies.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aspnetgoodies.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aspnetgoodies.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aspnetgoodies.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aspnetgoodies.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aspnetgoodies.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aspnetgoodies.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aspnetgoodies.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aspnetgoodies.wordpress.com/101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=101&subd=aspnetgoodies&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://aspnetgoodies.wordpress.com/2007/12/18/request-validation-preventing-script-attacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2949e6f1224f8b5f410d410d7eeba3a1?s=96&#38;d=identicon" medium="image">
			<media:title type="html">aspnetgoodies</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/html-in-form-thumb.jpg" medium="image">
			<media:title type="html">html-in-form</media:title>
		</media:content>
	</item>
		<item>
		<title>Data types ntext and nvarchar incompatible with Equal to operator Fix.</title>
		<link>http://aspnetgoodies.wordpress.com/2007/12/17/data-types-ntext-and-nvarchar-incompatible-with-equal-to-operator-fix/</link>
		<comments>http://aspnetgoodies.wordpress.com/2007/12/17/data-types-ntext-and-nvarchar-incompatible-with-equal-to-operator-fix/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 22:50:05 +0000</pubDate>
		<dc:creator>aspnetgoodies</dc:creator>
				<category><![CDATA[Data types ntext and nvarchar incompatible with Equal t]]></category>
		<category><![CDATA[Data types ntext  nvarchar incompatible Equal to Operat]]></category>

		<guid isPermaLink="false">http://aspnetgoodies.wordpress.com/2007/12/17/data-types-ntext-and-nvarchar-incompatible-with-equal-to-operator-fix/</guid>
		<description><![CDATA[This article provides a quick solution to the Unhandled Exception message when the generated SQL update command by default assigns the equal (=) operator to the @Original parameter for the ntext and nvarchar data types.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=98&subd=aspnetgoodies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><u><font color="#0080c0">Objective:</font></u> This article provides a quick solution to the Unhandled Exception message when the generated SQL update command by default assigns the equal (=) operator to the @Original parameter for the ntext and nvarchar data types. </p>
<p><u><font color="#0080c0">Background:</font></u> The generated error message would look something similar to the following: <u><font color="#ff0000">System.Data.SqlClient.SqlException: The data types ntext and nvarchar are incompatible in the equal to operator.</font></u> This is a common problem seen in ASP.NET when working with an existing database that worked just fine with classic ASP using good old Dreamweaver. Although it can be attributed to incorrect or faulty database design that should be taken into consideration at design time, it seems rather rigid and very annoying at the least especially if you have already spent a considerable amount of time constructing dozens of dynamic data driven pages in your site relying on the very same tables in your database. If you change the data column types in your database to remedy the problem, you will end up having to fix all of your already constructed pages to reflect the changes taking precious time out of your schedule. </p>
<p>So, my quick solution is to simply change all the <u>equal (=) operators</u> in the <u>@Original parameter</u> to the <u>LIKE</u> operator. This had worked fine for me on many occasion when I had to deal with this particular problem and I hope it saves you some time as well. Refer to the example below to get a better idea of how this is done.</p>
<p><u><font color="#0080c0">Procedure:</font></u> Follow instructions below to accomplish this task. This article uses Visual Web Developer Express 2008 and SQL Server Express 2005 .</p>
<p><strong>Option A. Generating correct SqlDataSource at design time.</strong></p>
<ol>
<li>When you create your SqlDataSource and Auto generate the Update, Insert and Delete statements make sure you actually take a look at query being generated and make corrections before clicking the finish button. <u><strong><font color="#ff0000">Note:</font></strong> in case you don&#8217;t know, when selecting the table columns in the query designer, if you forget to select the ID (primary key) column, you won&#8217;t be able to automatically generate the Update, Insert and Delete statements. So, make sure you remember to do that.<br /></u><br /><a href="http://aspnetgoodies.files.wordpress.com/2007/12/sql-data-source-update.jpg"><img style="border-width:0;" height="181" alt="sql-data-source-update" src="http://aspnetgoodies.files.wordpress.com/2007/12/sql-data-source-update-thumb.jpg?w=244&#038;h=181" width="244" border="0"></a> <br /> 
<li>You can also do this visually by clicking the Query Builder button and make corrections to the filter options like shown below to change the = @Original.. to LIKE @Original <u>at each instance of a nvarchar or ntext column</u>.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/sql-filter-options.jpg"><img style="border-width:0;" height="226" alt="sql-filter-options" src="http://aspnetgoodies.files.wordpress.com/2007/12/sql-filter-options-thumb.jpg?w=244&#038;h=226" width="244" border="0"></a> </li>
</ol>
<p><strong>Option B. Editing the query statement in code view.</strong></p>
<p>If you have already created your SqlDataSource and spent lots of time designing your GridView or your choice of data view, you may want to consider to make your corrections in code view instead. The reason for this is that when you modify an already existing data source, Visual Web Developer will regenerate your data view overriding all your precious customization that you spent your whole afternoon on getting it just right.</p>
<ol>
<li>Switch to code view in your page.
<li>Locate the SqlDataSource in question.
<li>Locate the UpdateCommand.
<li>In the UpdateCommand find the WHERE clause and comb through everything that comes after it. Identify all the columns that are nvarchar or ntext data type and change the equal signs to LIKE. You may have to refer to your database to refresh your memory. An example is provided below:</p>
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;overflow:auto;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:50px;padding:4px;">
<pre><span style="color:red;">UpdateCommand</span><span style="color:blue;">="UPDATE [agents] SET [FirstName] = @FirstName, [LastName] = @LastName, [Designations] = @Designations, [Address] = @Address, [City] = @City, [State] = @State, [Zip] = @Zip, [HomePhone] = @HomePhone, [HomePhoneExt] = @HomePhoneExt, [CellPhone] = @CellPhone, [WorkPhone] = @WorkPhone, [WorkPhoneExt] = @WorkPhoneExt, [HomeFax] = @HomeFax, [WorkFax] = @WorkFax, [Email] = @Email, [Website] = @Website, [AgentBio] = @AgentBio, [AgentPhoto] = @AgentPhoto, [mlsURL] = @mlsURL, [mlsURL2] = @mlsURL2, [UserName] = @UserName, [Password] = @Password, [Approved] = @Approved, [AccountActive] = @AccountActive WHERE [Agent_ID] = @original_Agent_ID AND [FirstName] LIKE @original_FirstName AND [LastName] LIKE @original_LastName AND [Designations] LIKE @original_Designations AND [Address] LIKE @original_Address AND [City] LIKE @original_City AND [State] LIKE @original_State AND [Zip] LIKE @original_Zip AND [HomePhone] LIKE @original_HomePhone AND [HomePhoneExt] LIKE @original_HomePhoneExt AND [CellPhone] LIKE @original_CellPhone AND [WorkPhone] LIKE @original_WorkPhone AND [WorkPhoneExt] LIKE @original_WorkPhoneExt AND [HomeFax] = @original_HomeFax AND [WorkFax] LIKE @original_WorkFax AND [Email] LIKE @original_Email AND [Website] LIKE @original_Website AND [AgentBio] LIKE @original_AgentBio AND [AgentPhoto] LIKE @original_AgentPhoto AND [mlsURL] = @original_mlsURL AND [mlsURL2] LIKE @original_mlsURL2 AND [UserName] LIKE @original_UserName AND [Password] LIKE @original_Password AND [Approved] LIKE @original_Approved AND [AccountActive] LIKE @original_AccountActive"&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></div>
</li>
</ol>
<p><strong>Option C. Data Access Layer instead of SqlDataSource.</strong></p>
<ol>
<li>It really does not matter what kind of data access method you are using. Your task is to change your update query. If you are for instance using Data Access Layer with a DataSet, go to your App_code folder, open the DatSet in question and make your change there.</li>
</ol>
<p>That&#8217;s it! Enjoy.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/aspnetgoodies.wordpress.com/98/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/aspnetgoodies.wordpress.com/98/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aspnetgoodies.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aspnetgoodies.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aspnetgoodies.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aspnetgoodies.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aspnetgoodies.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aspnetgoodies.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aspnetgoodies.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aspnetgoodies.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aspnetgoodies.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aspnetgoodies.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=98&subd=aspnetgoodies&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://aspnetgoodies.wordpress.com/2007/12/17/data-types-ntext-and-nvarchar-incompatible-with-equal-to-operator-fix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2949e6f1224f8b5f410d410d7eeba3a1?s=96&#38;d=identicon" medium="image">
			<media:title type="html">aspnetgoodies</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/sql-data-source-update-thumb.jpg" medium="image">
			<media:title type="html">sql-data-source-update</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/sql-filter-options-thumb.jpg" medium="image">
			<media:title type="html">sql-filter-options</media:title>
		</media:content>
	</item>
		<item>
		<title>Multi Line Text Field Validation For Number of Allowed Characters</title>
		<link>http://aspnetgoodies.wordpress.com/2007/12/16/multi-line-text-field-validation-for-number-of-allowed-characters/</link>
		<comments>http://aspnetgoodies.wordpress.com/2007/12/16/multi-line-text-field-validation-for-number-of-allowed-characters/#comments</comments>
		<pubDate>Sun, 16 Dec 2007 04:16:08 +0000</pubDate>
		<dc:creator>aspnetgoodies</dc:creator>
				<category><![CDATA[Multi Line Text Field Validation For Number of Allowed]]></category>
		<category><![CDATA[multi line text field validation server client side num]]></category>

		<guid isPermaLink="false">http://aspnetgoodies.wordpress.com/2007/12/16/multi-line-text-field-validation-for-number-of-allowed-characters/</guid>
		<description><![CDATA[This article describes how to achieve server and client side validation for a multi line text field in asp.net.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=91&subd=aspnetgoodies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><u><font color="#0080c0">Objective:</font></u> This article describes how to achieve server and client side validation for a multi line text field.</p>
<p><u><font color="#0080c0">Background:</font></u> Multi line text field validation is a very common procedure. It allows us to make sure that no more than the allowed number of characters are input or entered into a particular text field on our form. In this example the validation is done both on client and server side to assure accurateness and only a single text field is used to avoid too much confusing code on the page. I boiled the chicken fat away for you so you can study just what&#8217;s important.</p>
<p><u><font color="#0080c0">Procedure:</font></u> Follow instructions below to accomplish this task. This article uses Visual Web Developer Express 2008.</p>
<ol>
<li>Start by creating a new web form for your site and name it anything you want.
<li>Go into code view and replace the entire code with the following.</p>
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;overflow:auto;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:600px;padding:4px;">
<pre><span style="background:#ffee62;">&lt;%</span><span style="color:blue;">@ </span><span style="color:#a31515;">Page </span><span style="color:red;">Language</span><span style="color:blue;">="VB" </span><span style="background:#ffee62;">%&gt;

</span><span style="color:blue;">&lt;!</span><span style="color:#a31515;">DOCTYPE </span><span style="color:red;">html PUBLIC </span><span style="color:blue;">"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;</span><span style="color:#a31515;">script </span><span style="color:red;">runat</span><span style="color:blue;">="server"&gt;

    </span><span style="color:green;">'.......................Serverside Textfield Validation Start....................
    'create protected subprocedure for textfield validation
    'if the length of text is longer than max characters allowed then
    'show error message
    'else allow to proceed
    'end if statement
    'end subprocedure
    </span><span style="color:blue;">Protected Sub </span>CustomValidator1_ServerValidate(<span style="color:blue;">ByVal </span>source <span style="color:blue;">As Object</span>, <span style="color:blue;">ByVal </span>args <span style="color:blue;">As </span>System.Web.UI.WebControls.ServerValidateEventArgs)

        <span style="color:blue;">If </span>tbxTextField.Text.Length &gt; 10 <span style="color:blue;">Then
            </span>args.IsValid = <span style="color:blue;">False
        Else
            </span>args.IsValid = <span style="color:blue;">True
        End If

    End Sub
    </span><span style="color:green;">'.......................Serverside Textfield Validation End....................

    '............................Submit Button Click Start.........................
    'when clicking the submit button
    'set the entered text of the textfield equal to the text of label1
    'end subprocedure
    </span><span style="color:blue;">Protected Sub </span>btnSubmit_Click(<span style="color:blue;">ByVal </span>sender <span style="color:blue;">As Object</span>, <span style="color:blue;">ByVal </span>e <span style="color:blue;">As </span>System.EventArgs)
        Label1.Text = <span style="color:#a31515;">"You typed: " </span>&amp; tbxTextField.Text
    <span style="color:blue;">End Sub
    </span><span style="color:green;">'.............................Submit Button Click End..........................

</span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">script</span><span style="color:blue;">&gt;

&lt;</span><span style="color:#a31515;">html </span><span style="color:red;">xmlns</span><span style="color:blue;">="http://www.w3.org/1999/xhtml"&gt;
&lt;</span><span style="color:#a31515;">head </span><span style="color:red;">runat</span><span style="color:blue;">="server"&gt;
    &lt;</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span>Untitled Page<span style="color:blue;">&lt;/</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;
&lt;/</span><span style="color:#a31515;">head</span><span style="color:blue;">&gt;
&lt;</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;
    &lt;</span><span style="color:#a31515;">form </span><span style="color:red;">id</span><span style="color:blue;">="form1" </span><span style="color:red;">runat</span><span style="color:blue;">="server"&gt;
    &lt;</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;
        &lt;</span><span style="color:#a31515;">table </span><span style="color:red;">cellpadding</span><span style="color:blue;">="2" </span><span style="color:red;">cellspacing</span><span style="color:blue;">="0" </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">width</span>: <span style="color:blue;">37%"&gt;
            &lt;</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;
                &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">width</span>: <span style="color:blue;">138px"&gt;

                    </span><span style="color:green;">&lt;!-- The label for the TextBox --&gt;
                    </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label
                    </span><span style="color:red;">ID</span><span style="color:blue;">="lblTextField"
                    </span><span style="color:red;">runat</span><span style="color:blue;">="server"
                    </span><span style="color:red;">Text</span><span style="color:blue;">="Multiline Textfield:"&gt;
                    &lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label</span><span style="color:blue;">&gt;

                &lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
                &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">width</span>: <span style="color:blue;">262px"&gt;

                    </span><span style="color:green;">&lt;!-- The multiline TextBox --&gt;
                    </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TextBox
                    </span><span style="color:red;">ID</span><span style="color:blue;">="tbxTextField"
                    </span><span style="color:red;">runat</span><span style="color:blue;">="server"
                    </span><span style="color:red;">Height</span><span style="color:blue;">="76px"
                    </span><span style="color:red;">TextMode</span><span style="color:blue;">="MultiLine"
                    </span><span style="color:red;">Width</span><span style="color:blue;">="258px"
                    </span><span style="color:red;">EnableViewState</span><span style="color:blue;">="False"&gt;
                    &lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">TextBox</span><span style="color:blue;">&gt;

                &lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
                &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">width</span>: <span style="color:blue;">11px"&gt;

                    </span><span style="color:green;">&lt;!-- The front end of the server side validation --&gt;
                    </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">CustomValidator
                    </span><span style="color:red;">ID</span><span style="color:blue;">="CustomValidator1"
                    </span><span style="color:red;">runat</span><span style="color:blue;">="server"
                    </span><span style="color:red;">ControlToValidate</span><span style="color:blue;">="tbxTextField"
                    </span><span style="color:red;">ErrorMessage</span><span style="color:blue;">="Exceeded max. 10 char."
                    </span><span style="color:red;">OnServerValidate</span><span style="color:blue;">="CustomValidator1_ServerValidate"&gt;
                    </span>*
                    <span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">CustomValidator</span><span style="color:blue;">&gt;

                    </span><span style="color:green;">&lt;!-- Make sure the form is not submitted empty --&gt;
                    </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">RequiredFieldValidator
                    </span><span style="color:red;">ID</span><span style="color:blue;">="RequiredFieldValidator1"
                    </span><span style="color:red;">runat</span><span style="color:blue;">="server"
                    </span><span style="color:red;">ControlToValidate</span><span style="color:blue;">="tbxTextField"
                    </span><span style="color:red;">ErrorMessage</span><span style="color:blue;">="Please type a message!"&gt;
                    </span>*
                    <span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">RequiredFieldValidator</span><span style="color:blue;">&gt;

                    </span><span style="color:green;">&lt;!-- Makes sure the max. allowed chars. are not exceeded --&gt;
                    &lt;!-- Notice that it allows only 10 characters --&gt;
                    </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">RegularExpressionValidator
                    </span><span style="color:red;">ID</span><span style="color:blue;">="RegularExpressionValidator1"
                    </span><span style="color:red;">runat</span><span style="color:blue;">="server"
                    </span><span style="color:red;">ControlToValidate</span><span style="color:blue;">="tbxTextField"
                    </span><span style="color:red;">ErrorMessage</span><span style="color:blue;">="Exceeded max. 10 char."
                    </span><span style="color:red;">ValidationExpression</span><span style="color:blue;">="^[\s\S]{1,10}$"&gt;
                    </span>*
                    <span style="color:blue;">&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">RegularExpressionValidator</span><span style="color:blue;">&gt;

                &lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
            &lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;
            &lt;</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;
                &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">width</span>: <span style="color:blue;">138px"&gt;
                    </span><span style="color:red;">&amp;nbsp;
                </span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
                &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">width</span>: <span style="color:blue;">262px"&gt;

                    </span><span style="color:green;">&lt;!-- The Submit Button --&gt;
                    </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Button </span><span style="color:red;">ID</span><span style="color:blue;">="btnSubmit"
                    </span><span style="color:red;">runat</span><span style="color:blue;">="server"
                    </span><span style="color:red;">Text</span><span style="color:blue;">="Submit For Validation"
                    </span><span style="color:red;">Width</span><span style="color:blue;">="258px"
                    </span><span style="color:red;">onclick</span><span style="color:blue;">="btnSubmit_Click" /&gt;

                &lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
                &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">width</span>: <span style="color:blue;">11px"&gt;
                &lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
            &lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;
            &lt;</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;
                &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">width</span>: <span style="color:blue;">138px"&gt;
                &lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
                &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">colspan</span><span style="color:blue;">="2"&gt;

                    </span><span style="color:green;">&lt;!-- The validation summary displayed at bottom --&gt;
                    </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">ValidationSummary
                    </span><span style="color:red;">ID</span><span style="color:blue;">="ValidationSummary1"
                    </span><span style="color:red;">runat</span><span style="color:blue;">="server" /&gt;

                &lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
            &lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;
            &lt;</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;
                &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">width</span>: <span style="color:blue;">138px"&gt;
                &lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
                &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">colspan</span><span style="color:blue;">="2"&gt;

                    </span><span style="color:green;">&lt;!-- The label that displays the submitted text --&gt;
                    </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label </span><span style="color:red;">ID</span><span style="color:blue;">="Label1"
                    </span><span style="color:red;">runat</span><span style="color:blue;">="server"
                    </span><span style="color:red;">EnableViewState</span><span style="color:blue;">="False"
                    </span><span style="color:red;">Visible</span><span style="color:blue;">="True"&gt;
                    &lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label</span><span style="color:blue;">&gt;

                &lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
            &lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;
        &lt;/</span><span style="color:#a31515;">table</span><span style="color:blue;">&gt;
    &lt;/</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;
    &lt;/</span><span style="color:#a31515;">form</span><span style="color:blue;">&gt;
&lt;/</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;
&lt;/</span><span style="color:#a31515;">html</span><span style="color:blue;">&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></div>
<p></p>
<li>Save the page and give it a spin in your browser.
<li>That&#8217;s it! Enjoy.</li>
</ol>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/aspnetgoodies.wordpress.com/91/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/aspnetgoodies.wordpress.com/91/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aspnetgoodies.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aspnetgoodies.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aspnetgoodies.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aspnetgoodies.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aspnetgoodies.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aspnetgoodies.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aspnetgoodies.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aspnetgoodies.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aspnetgoodies.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aspnetgoodies.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=91&subd=aspnetgoodies&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://aspnetgoodies.wordpress.com/2007/12/16/multi-line-text-field-validation-for-number-of-allowed-characters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2949e6f1224f8b5f410d410d7eeba3a1?s=96&#38;d=identicon" medium="image">
			<media:title type="html">aspnetgoodies</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding an Ajax Splitter Bar To Your ASP.NET Page</title>
		<link>http://aspnetgoodies.wordpress.com/2007/12/16/adding-an-ajax-splitter-bar-to-your-aspnet-page/</link>
		<comments>http://aspnetgoodies.wordpress.com/2007/12/16/adding-an-ajax-splitter-bar-to-your-aspnet-page/#comments</comments>
		<pubDate>Sun, 16 Dec 2007 01:09:58 +0000</pubDate>
		<dc:creator>aspnetgoodies</dc:creator>
				<category><![CDATA[Adding an Ajax Splitter Bar To Your ASP.NET Page]]></category>
		<category><![CDATA[ajax splitter bar horizontal free server component how]]></category>

		<guid isPermaLink="false">http://aspnetgoodies.wordpress.com/2007/12/16/adding-an-ajax-splitter-bar-to-your-aspnet-page/</guid>
		<description><![CDATA[This article describes how to add a horizontal VwdCms.SplitterBar to your asp.net page or pages.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=90&subd=aspnetgoodies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><u><font color="#0080c0">Objective:</font></u> This article describes how to add a <u><strong>horizontal</strong></u> VwdCms.SplitterBar to your asp.net page or pages. You can download this free server component from <a title="http://www.codeproject.com/KB/aspnet/VwdCmsSplitterBar.aspx" href="http://www.codeproject.com/KB/aspnet/VwdCmsSplitterBar.aspx">http://www.codeproject.com/KB/aspnet/VwdCmsSplitterBar.aspx</a>. You&#8217;ll have to register and login to get access to the downloads.</p>
<p><u><font color="#0080c0">Background:</font></u> VwdCms.SplitterBar is a free server control that allows you to easily add resizing to your web page layout. Use the splitter bar to resize a panel, div, table cell, or just about any control. It is ideal replacement of frames for pages that have a tree or a list of data items that vary in width. I recently was building a mass email application and needed to be able to resize the upper or lower portion to make more room for one or the other. The splitter bar was a quick and stylish choice that worked exactly the way I envisioned it.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/vwdcmssplitterbar.jpg"><img style="border-width:0;" height="148" alt="VwdCmsSplitterBar" src="http://aspnetgoodies.files.wordpress.com/2007/12/vwdcmssplitterbar-thumb.jpg?w=244&#038;h=148" width="244" border="0"></a> </p>
<p><u><font color="#0080c0">Procedure:</font></u> </p>
<ol>
<li>Download the free sever component and related files and extract them to a place of your choice.
<li>Create new site if you haven&#8217;t already.
<li>Create a new folder in your site and name it AjaxSplitter.
<li>Right click on the site name on top in your solution explorer, scroll to Add ASP_Net Folder and select App-Code folder. This is a special ASP.NET folder that will hold our SplitterBar server control.
<li>From the extracted files, open the App_Code folder and drag the SplitterBar.cs file into our newly created App_Code folder like shown in the picture below. Although the file is written C#, you can use it just fine in your VB.Net applications.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/splitterbarcs.jpg"><img style="border-width:0;" height="166" alt="SplitterBarCs" src="http://aspnetgoodies.files.wordpress.com/2007/12/splitterbarcs-thumb.jpg?w=244&#038;h=166" width="244" border="0"></a> <br /> 
<li>Drag and drop the hsplitter.gif file into the root of your site. (that&#8217;s where the script files are looking for it)
<li>Drag and drop the following files into the AjaxSplitter folder we created earlier.
<li>hsplitter.gif, License.txt, vsplitter.gif, and VwdCmsSplitterBar.js
<li>Now if you haven&#8217;t already, add a web.config file to your site and open it.
<li>Find the &lt;pages&gt;&lt;controls&gt; tags and paste inside the following code: &lt;add tagPrefix=&#8221;VwdCms&#8221; namespace=&#8221;VwdCms&#8221;/&gt;. This is to register the SplittBar server component with our site. It should look something like below:</p>
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;overflow:auto;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:100px;padding:4px;">
<pre><span style="color:blue;">&lt;</span><span style="color:#a31515;">pages</span><span style="color:blue;">&gt;
    &lt;</span><span style="color:#a31515;">controls</span><span style="color:blue;">&gt;
        &lt;</span><span style="color:#a31515;">add </span><span style="color:red;">tagPrefix</span><span style="color:blue;">=</span>"<span style="color:blue;">VwdCms</span>" <span style="color:red;">namespace</span><span style="color:blue;">=</span>"<span style="color:blue;">VwdCms</span>"<span style="color:blue;">/&gt;
    &lt;/</span><span style="color:#a31515;">controls</span><span style="color:blue;">&gt;
&lt;/</span><span style="color:#a31515;">pages</span><span style="color:blue;">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></div>
<p></p>
<li>Now that we have all the files in place, let&#8217;s create a new web form and replace all of the code with the following. There is no server side code here but make sure you go over it line by line to understand how the application comes together.
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;overflow:auto;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:600px;padding:4px;">
<pre><span style="background:#ffee62;">&lt;%</span><span style="color:blue;">@ </span><span style="color:#a31515;">Page </span><span style="color:red;">Language</span><span style="color:blue;">="VB" </span><span style="background:#ffee62;">%&gt;

</span><span style="color:blue;">&lt;!</span><span style="color:#a31515;">DOCTYPE </span><span style="color:red;">html PUBLIC </span><span style="color:blue;">"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;</span><span style="color:#a31515;">script </span><span style="color:red;">runat</span><span style="color:blue;">="server"&gt;

&lt;/</span><span style="color:#a31515;">script</span><span style="color:blue;">&gt;

&lt;</span><span style="color:#a31515;">html </span><span style="color:red;">xmlns</span><span style="color:blue;">="http://www.w3.org/1999/xhtml"&gt;
&lt;</span><span style="color:#a31515;">head </span><span style="color:red;">id</span><span style="color:blue;">="Head1" </span><span style="color:red;">runat</span><span style="color:blue;">="server"&gt;
    &lt;</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span>Untitled Page<span style="color:blue;">&lt;/</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;
    </span><span style="color:green;">&lt;!-- ...........................Splitter Bar Javascript..................... --&gt;
    &lt;!-- Add a reference to the Javascript file --&gt;

    </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">script </span><span style="color:red;">src</span><span style="color:blue;">="AjaxSplitter/VwdCmsSplitterBar.js" </span><span style="color:red;">type</span><span style="color:blue;">="text/javascript"&gt;&lt;/</span><span style="color:#a31515;">script</span><span style="color:blue;">&gt;

    </span><span style="color:green;">&lt;!-- Create resize function for the Splitter Bar --&gt;

    </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">script </span><span style="color:red;">language</span><span style="color:blue;">="javascript" </span><span style="color:red;">type</span><span style="color:blue;">="text/javascript"&gt;
    function </span>splitterOnResize(width)
    {
        <span style="color:blue;">if </span>(<span style="color:blue;">typeof </span>width == <span style="color:#a31515;">"string"</span>)
        {
            width = <span style="color:blue;">new </span>Number(width.replace(<span style="color:#a31515;">"px"</span>,<span style="color:#a31515;">""</span>));
        }
    }
    <span style="color:blue;">&lt;/</span><span style="color:#a31515;">script</span><span style="color:blue;">&gt;
    </span><span style="color:green;">&lt;!-- ...........................Splitter Bar Javascript..................... --&gt;
    </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">link </span><span style="color:red;">href</span><span style="color:blue;">="default.css" </span><span style="color:red;">rel</span><span style="color:blue;">="stylesheet" </span><span style="color:red;">type</span><span style="color:blue;">="text/css" /&gt;
&lt;/</span><span style="color:#a31515;">head</span><span style="color:blue;">&gt;
&lt;</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;
    &lt;</span><span style="color:#a31515;">form </span><span style="color:red;">id</span><span style="color:blue;">="form1" </span><span style="color:red;">runat</span><span style="color:blue;">="server"&gt;
    &lt;</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;
        </span><span style="color:green;">&lt;!-- Table for Splitter Bar  --&gt;
        </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">table </span><span style="color:red;">border</span><span style="color:blue;">="0" </span><span style="color:red;">cellpadding</span><span style="color:blue;">="0" </span><span style="color:red;">cellspacing</span><span style="color:blue;">="0" </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">width</span>: <span style="color:blue;">100%</span>; <span style="color:red;">height</span>: <span style="color:blue;">406px</span>;
            <span style="color:red;">border</span>: <span style="color:blue;">solid 0px #6699CC</span>; <span style="color:red;">overflow</span>: <span style="color:blue;">hidden</span>;<span style="color:blue;">"&gt;
            &lt;</span><span style="color:#a31515;">tr </span><span style="color:red;">id</span><span style="color:blue;">="trTop"&gt;
                &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">runat</span><span style="color:blue;">="server" </span><span style="color:red;">id</span><span style="color:blue;">="tdTop" </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">height</span>: <span style="color:blue;">200px</span>;<span style="color:blue;">" </span><span style="color:red;">align</span><span style="color:blue;">="left" </span><span style="color:red;">valign</span><span style="color:blue;">="top"&gt;
                    &lt;</span><span style="color:#a31515;">div </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">height</span>: <span style="color:blue;">100%</span>; <span style="color:red;">overflow</span>: <span style="color:blue;">auto</span>;<span style="color:blue;">"&gt;
                        &lt;/</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;
                &lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
            &lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;
            &lt;</span><span style="color:#a31515;">tr </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">height</span>: <span style="color:blue;">6px</span>;<span style="color:blue;">"&gt;
                &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">height</span>: <span style="color:blue;">6px</span>; <span style="color:red;">font-size</span>: <span style="color:blue;">0pt</span>;<span style="color:blue;">"&gt;
                    </span><span style="color:red;">&amp;nbsp;
                </span><span style="color:blue;">&lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
            &lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;
            &lt;</span><span style="color:#a31515;">tr </span><span style="color:red;">id</span><span style="color:blue;">="trBottom"&gt;
                &lt;</span><span style="color:#a31515;">td </span><span style="color:red;">runat</span><span style="color:blue;">="server" </span><span style="color:red;">id</span><span style="color:blue;">="tdBottom" </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">height</span>: <span style="color:blue;">200px</span>;<span style="color:blue;">" </span><span style="color:red;">align</span><span style="color:blue;">="left" </span><span style="color:red;">valign</span><span style="color:blue;">="top"&gt;
                    &lt;</span><span style="color:#a31515;">div </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">height</span>: <span style="color:blue;">100%</span>; <span style="color:red;">overflow</span>: <span style="color:blue;">auto</span>;<span style="color:blue;">"&gt;
                        &lt;/</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;
                &lt;/</span><span style="color:#a31515;">td</span><span style="color:blue;">&gt;
            &lt;/</span><span style="color:#a31515;">tr</span><span style="color:blue;">&gt;
        &lt;/</span><span style="color:#a31515;">table</span><span style="color:blue;">&gt;
        </span><span style="color:green;">&lt;!-- Splitter Bar Server Control --&gt;
        </span><span style="color:blue;">&lt;</span><span style="color:#a31515;">VwdCms</span><span style="color:blue;">:</span><span style="color:#a31515;">SplitterBar </span><span style="color:red;">runat</span><span style="color:blue;">="server" </span><span style="color:red;">ID</span><span style="color:blue;">="hsbSplitter"
        </span><span style="color:red;">Orientation</span><span style="color:blue;">="horizontal"
        </span><span style="color:red;">TopResizeTargets</span><span style="color:blue;">="tdTop"
        </span><span style="color:red;">BottomResizeTargets</span><span style="color:blue;">="tdBottom"
        </span><span style="color:red;">MinHeight</span><span style="color:blue;">="30"
        </span><span style="color:red;">MaxHeight</span><span style="color:blue;">="370"
        </span><span style="color:red;">TotalHeight</span><span style="color:blue;">="406"
        </span><span style="color:red;">BackgroundColor</span><span style="color:blue;">="lightsteelblue"
        </span><span style="color:red;">BackgroundColorLimit</span><span style="color:blue;">="firebrick"
        </span><span style="color:red;">BackgroundColorHilite</span><span style="color:blue;">="steelblue"
        </span><span style="color:red;">BackgroundColorResizing</span><span style="color:blue;">="purple"
        </span><span style="color:red;">SaveHeightToElement</span><span style="color:blue;">="txtHeight"
        </span><span style="color:red;">Style</span><span style="color:blue;">="</span><span style="color:red;">background-image</span>: <span style="color:blue;">url(hsplitter.gif)</span>;
        <span style="color:red;">background-position</span>: <span style="color:blue;">center center</span>; <span style="color:red;">background-repeat</span>: <span style="color:blue;">no-repeat</span>;<span style="color:blue;">" /&gt;
    &lt;/</span><span style="color:#a31515;">div</span><span style="color:blue;">&gt;
    &lt;/</span><span style="color:#a31515;">form</span><span style="color:blue;">&gt;
&lt;/</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;
&lt;/</span><span style="color:#a31515;">html</span><span style="color:blue;">&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></div>
<p></p>
<li>Load it up into your browser and give it a spin.
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/splittbar-results.jpg"><img style="border-width:0;" height="206" alt="splittBar-results" src="http://aspnetgoodies.files.wordpress.com/2007/12/splittbar-results-thumb.jpg?w=244&#038;h=206" width="244" border="0"></a> </p>
<li>That&#8217;s it! Enjoy.</li>
</ol>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/aspnetgoodies.wordpress.com/90/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/aspnetgoodies.wordpress.com/90/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aspnetgoodies.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aspnetgoodies.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aspnetgoodies.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aspnetgoodies.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aspnetgoodies.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aspnetgoodies.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aspnetgoodies.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aspnetgoodies.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aspnetgoodies.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aspnetgoodies.wordpress.com/90/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=90&subd=aspnetgoodies&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://aspnetgoodies.wordpress.com/2007/12/16/adding-an-ajax-splitter-bar-to-your-aspnet-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2949e6f1224f8b5f410d410d7eeba3a1?s=96&#38;d=identicon" medium="image">
			<media:title type="html">aspnetgoodies</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/vwdcmssplitterbar-thumb.jpg" medium="image">
			<media:title type="html">VwdCmsSplitterBar</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/splitterbarcs-thumb.jpg" medium="image">
			<media:title type="html">SplitterBarCs</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/splittbar-results-thumb.jpg" medium="image">
			<media:title type="html">splittBar-results</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.NET Image Upload With Unique File Name, File Size, And File Type Validation</title>
		<link>http://aspnetgoodies.wordpress.com/2007/12/13/aspnet-image-upload-with-unique-file-name-file-size-and-file-type-validation/</link>
		<comments>http://aspnetgoodies.wordpress.com/2007/12/13/aspnet-image-upload-with-unique-file-name-file-size-and-file-type-validation/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 21:15:26 +0000</pubDate>
		<dc:creator>aspnetgoodies</dc:creator>
				<category><![CDATA[ASP.NET Image Upload With Unique File Name, File Size,]]></category>
		<category><![CDATA[asp.net image upload unique file name size type validat]]></category>

		<guid isPermaLink="false">http://aspnetgoodies.wordpress.com/2007/12/13/aspnet-image-upload-with-unique-file-name-file-size-and-file-type-validation/</guid>
		<description><![CDATA[This article gives step by step instructions how to create a flexible and sophisticated image upload application that prefixes the file name with a unique ID, it enforces file size and file type restrictions, checks for upload problems, displays success and or error message, displays the uploaded file type, file size, and file location, displays all uploaded images present in the upload folder and shows their truncated file names. Uses pure asp.net server side code for the upload function with additional client side validation to stop execution of the form if no file is present.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=75&subd=aspnetgoodies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><u><font color="#0080c0">Objective:</font></u> This article gives step by step instructions how to create a flexible and sophisticated image upload application that prefixes the file name with a unique ID, it enforces file size and file type restrictions, checks for upload problems, displays success and or error message, displays the uploaded file type, file size, and file location, displays all uploaded images present in the upload folder and shows their truncated file names. Uses pure asp.net server side code for the upload function with additional client side validation to stop execution of the form if no file is present.</p>
<p><u><font color="#0080c0">Background:</font></u> It is safe to say that almost all sophisticated web applications with backend functionality require image or file upload capabilities. To write such an application is not too difficult once you understand its mechanism, but for the beginning asp.net developer it can be one of those hair pulling, eye poking and other types of chain yanking experiences that drains the life force (Chi) and leaves a person old before his or her time. I have searched for weeks online for an example of how this is done and to this date I have not found one that would feel like a complete, well rounded application. After much self inflicted injury as mentioned above, I whipped up something that I know you are going to love.</p>
<p><u><font color="#0080c0">Procedure:</font></u> Follow instructions below to accomplish this task. This article uses Visual Web Developer Express 2008.</p>
<ol>
<li>Let&#8217;s start by creating a new empty web site in VB and name it MyImageUpload.
<li>Create a new web form in your site and name it FileUpload.aspx. Don&#8217;t use code behind so you can better see how the puzzle fits together without having tab back and forth between pages.
<li>Now let&#8217;s go into code view and add an important name space that allows our upload to work. Copy and paste the following under the page directive at the top of the page:</p>
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:20px;padding:4px;"><span class="code"><span style="background:#ffee62;">&lt;%</span><span style="color:blue;">@ </span><span style="color:#a31515;">Import </span><span style="color:red;">Namespace</span><span style="color:blue;">=&#8221;System.IO&#8221; </span><span style="background:#ffee62;">%&gt;</span></span></div>
<p> 
<li>Now let&#8217;s create a new folder in our site and name it UploadFolder. This is where our uploaded images will be stored.
<li>Let&#8217;s go into code view and copy and paste the following code between the Form tags of your page. These are the visual elements on the page. Go over it line by line to get an idea what&#8217;s going on. It won&#8217;t make complete sense until we have our &#8220;code behind&#8221; code in place which will be our next step.</p>
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;overflow:auto;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:800px;padding:4px;">
<pre><span style="color:green;">&lt;!-- File upload server control --&gt;
</span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span></font><span style="color:#a31515;">FileUpload
</span><span style="color:red;">ID</span><span style="color:blue;">="upImage"
</span><span style="color:red;">runat</span><span style="color:blue;">="server"/&gt;
&lt;</span><span style="color:#a31515;">br </span><span style="color:blue;">/&gt;

</span><span style="color:green;">&lt;!-- Client Side Required Field Validator for the File Upload server control --&gt;
&lt;!-- Making sure the form is not submitted unless a file has been selected --&gt;
</span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">RequiredFieldValidator
</span><span style="color:red;">ID</span><span style="color:blue;">="RequiredFieldValidator1"
</span><span style="color:red;">runat</span><span style="color:blue;">="server"
</span><span style="color:red;">ControlToValidate</span><span style="color:blue;">="upImage"
</span><span style="color:red;">ErrorMessage</span><span style="color:blue;">="Please select a file first!"
</span><span style="color:red;">SetFocusOnError</span><span style="color:blue;">="True"
</span><span style="color:red;">Display</span><span style="color:blue;">="Static" </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">font-size</span>: <span style="color:blue;">small" &gt;
&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">RequiredFieldValidator</span><span style="color:blue;">&gt;

&lt;</span><span style="color:#a31515;">br </span><span style="color:blue;">/&gt;

</span><span style="color:green;">&lt;!-- This is the Upload Submit Button to initiate the upload process --&gt;
</span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Button
</span><span style="color:red;">ID</span><span style="color:blue;">="btnAdd"
</span><span style="color:red;">Text</span><span style="color:blue;">="Upload Image"
</span><span style="color:red;">OnClick</span><span style="color:blue;">="btnAdd_Click"
</span><span style="color:red;">runat</span><span style="color:blue;">="server" /&gt;

</span><span style="color:green;">&lt;!-- This Label displays the upload success or error message --&gt;
</span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label
</span><span style="color:red;">ID</span><span style="color:blue;">="lblMsg"
</span><span style="color:red;">runat</span><span style="color:blue;">="server"
</span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">color</span>: <span style="color:blue;">#FF0000</span>; <span style="color:red;">font-size</span>: <span style="color:blue;">small</span>;<span style="color:blue;">" /&gt;
&lt;</span><span style="color:#a31515;">br </span><span style="color:blue;">/&gt;

</span><span style="color:green;">&lt;!-- This Label displays the uploaded file's type i.e. JPG, PNG etc. --&gt;
</span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label
</span><span style="color:red;">id</span><span style="color:blue;">="lblFileContentType"
</span><span style="color:red;">runat</span><span style="color:blue;">="server"
</span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">color</span>: <span style="color:blue;">#808080</span>;<span style="color:red;">font-size</span>: <span style="color:blue;">small</span>;<span style="color:blue;">" /&gt;
&lt;</span><span style="color:#a31515;">br </span><span style="color:blue;">/&gt;

</span><span style="color:green;">&lt;!-- This Label displays the uploaded file's size in KB --&gt;
</span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label
</span><span style="color:red;">id</span><span style="color:blue;">="lblFileSize" 

</span><span style="color:red;">runat</span><span style="color:blue;">="server"
</span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">color</span>: <span style="color:blue;">#808080</span>;<span style="color:red;">font-size</span>: <span style="color:blue;">small</span>;<span style="color:blue;">" /&gt;
&lt;</span><span style="color:#a31515;">br </span><span style="color:blue;">/&gt;

</span><span style="color:green;">&lt;!-- This label displays the uploaded file's location on the server relative to the root --&gt;
</span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label
</span><span style="color:red;">id</span><span style="color:blue;">="lblFileLocation"
</span><span style="color:red;">runat</span><span style="color:blue;">="server"
</span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">color</span>: <span style="color:blue;">#808080</span>;<span style="color:red;">font-size</span>: <span style="color:blue;">small</span>;<span style="color:blue;">" /&gt;
&lt;</span><span style="color:#a31515;">br </span><span style="color:blue;">/&gt;

</span><span style="color:green;">&lt;!-- This is the DataList that displays all uploaded images present in the UploadImages folder --&gt;
&lt;!-- Take a look at the subprocedure on top "display uploaded images" to understand how it works --&gt;
&lt;!-- Notice below how the Substring property is used to truncate the image names --&gt;
</span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">DataList
</span><span style="color:red;">ID</span><span style="color:blue;">="dlstImages"
</span><span style="color:red;">RepeatColumns</span><span style="color:blue;">="6"
</span><span style="color:red;">runat</span><span style="color:blue;">="server"&gt;
    &lt;</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;
        &lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Image
        </span><span style="color:red;">ID</span><span style="color:blue;">="Image1"
        </span><span style="color:red;">ImageUrl</span><span style="color:blue;">='</span><span style="background:#ffee62;">&lt;%</span># Eval("Name", "~/UploadImages/{0}") <span style="background:#ffee62;">%&gt;</span><span style="color:blue;">'
        </span><span style="color:red;">Style</span><span style="color:blue;">="</span><span style="color:red;">width</span>: <span style="color:blue;">100px</span>; <span style="color:red;">margin</span>:<span style="color:blue;">5px</span>;<span style="color:blue;">"
        </span><span style="color:red;">runat</span><span style="color:blue;">="server" /&gt;
        &lt;</span><span style="color:#a31515;">br </span><span style="color:blue;">/&gt;
        &lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label
        </span><span style="color:red;">ID</span><span style="color:blue;">="Label1"
        </span><span style="color:red;">runat</span><span style="color:blue;">="server"
        </span><span style="color:red;">Text</span><span style="color:blue;">='</span><span style="background:#ffee62;">&lt;%</span>#Eval("Name").Substring(0, 15) &amp; " ..."<span style="background:#ffee62;">%&gt;</span><span style="color:blue;">'
        </span><span style="color:red;">ToolTip</span><span style="color:blue;">='</span><span style="background:#ffee62;">&lt;%</span>#Eval("Name")<span style="background:#ffee62;">%&gt;</span><span style="color:blue;">'
        </span><span style="color:red;">style</span><span style="color:blue;">="</span><span style="color:red;">color</span>: <span style="color:blue;">#808080</span>;<span style="color:red;">font-size</span>: <span style="color:blue;">x-small"
        &gt;
        &lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Label</span><span style="color:blue;">&gt;
    &lt;/</span><span style="color:#a31515;">ItemTemplate</span><span style="color:blue;">&gt;
&lt;/</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">DataList</span><span style="color:blue;">&gt;</span></pre>
</div>
<p></p>
<li>OK, now copy and paste the following code between the script blocks on top. These are all the procedures and functions that creates our application. I put it inside text box because the code is too wide to display properly in a table. Go over the code line by line and read all the comments until everything makes sense. Try to change or modify the code based on your assumptions and test it in your browser to see what happens.
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;overflow:auto;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:800px;padding:4px;">
<pre><span style="color:green;">'.......................File Upload Button Click Event Start.......................
'create subprocedure for upload button click event
'if the file upload field is not empty then
'declare the maximum allowable file size as whatever bytes
'declare a variable fileSize and set it equal to the file size of the uploading image
'if the file exceeds the maximum allowable size then
'end the upload and display the warning message
'else
'declare the GUID and set it equal to GUID function created below
'if the file extension complies with CheckFileType function then
'declare the upload file path and set it equal to the name of the folder &amp; GUID &amp; file name
'save the image to the file path
'display upload success message
'display file type extension
'display file size
'display the location of the saved file
'else
'display upload aborted message
'display a zero for all other labels
'end all if statements
'end subprocedures </span><span style="color:blue;">Sub </span>btnAdd_Click(<span style="color:blue;">ByVal </span>sender <span style="color:blue;">As Object</span>, <span style="color:blue;">ByVal </span>e <span style="color:blue;">As </span>EventArgs)

    <span style="color:blue;">If </span>(upImage.HasFile) <span style="color:blue;">Then
        Dim </span>maxFileSize <span style="color:blue;">As Integer </span>= 1024000 <span style="color:green;">'adjust max. file size as needed
        </span><span style="color:blue;">Dim </span>fileSize <span style="color:blue;">As Integer </span>= upImage.PostedFile.ContentLength
        <span style="color:blue;">If </span>fileSize &gt; maxFileSize <span style="color:blue;">Then
            </span>lblMsg.Text = <span style="color:#a31515;">"File size exceeded the maximum limit of " </span>&amp; maxFileSize / 1024 &amp; <span style="color:#a31515;">" Kb."
        </span><span style="color:blue;">Else
            Dim </span>strGuid = fnGuid()
            <span style="color:blue;">If </span>(CheckFileType(upImage.FileName)) <span style="color:blue;">Then
                Dim </span>filePath <span style="color:blue;">As String </span>= <span style="color:#a31515;">"~/UploadImages/" </span>&amp; strGuid &amp; upImage.FileName
                upImage.SaveAs(MapPath(filePath))
                lblMsg.Text = <span style="color:#a31515;">"File Upload Success!"
                </span>lblFileContentType.Text = <span style="color:#a31515;">"File type: " </span>&amp; upImage.PostedFile.ContentType
                lblFileSize.Text = <span style="color:#a31515;">"File size: " </span>&amp; <span style="color:blue;">CStr</span>(upImage.PostedFile.ContentLength / 1024) &amp; <span style="color:#a31515;">" Kb"
                </span>lblFileLocation.Text = <span style="color:#a31515;">"File Location: /UploadImages/" </span>&amp; strGuid &amp; upImage.FileName <span style="color:blue;">Else
                </span>lblMsg.Text = <span style="color:#a31515;">"Wrong file type! Upload Aborted."
                </span>lblFileContentType.Text = <span style="color:#a31515;">"File type: 0"
                </span>lblFileSize.Text = <span style="color:#a31515;">"File size: 0"
                </span>lblFileLocation.Text = <span style="color:#a31515;">"File Location: 0"
            </span><span style="color:blue;">End If
        End If
    End If
End Sub
</span><span style="color:green;">'.......................File Upload Button Click Event End.......................

'................Function To Check For Valid File Extension Start................
'declare a function as true or false boolean to check for file type extension to be allowed
'declare a variable named "ext" as a string and set it equal to the extention of the file to be uploaded
'if this file extension matches .gif .png .jpg or .jpeg then set the boolean to True (allow it)
'otherwise set the boolean to False (do not allow it)
'end the conditional statement
'end the function </span><span style="color:blue;">Function </span>CheckFileType(<span style="color:blue;">ByVal </span>fileName <span style="color:blue;">As String</span>) <span style="color:blue;">As Boolean
    Dim </span>ext <span style="color:blue;">As String </span>= Path.GetExtension(fileName)
    <span style="color:blue;">Select Case </span>ext.ToLower()
        <span style="color:blue;">Case </span><span style="color:#a31515;">".gif" </span><span style="color:green;">' add or remove file types as needed
            </span><span style="color:blue;">Return True
        Case </span><span style="color:#a31515;">".png"
            </span><span style="color:blue;">Return True
        Case </span><span style="color:#a31515;">".jpg"
            </span><span style="color:blue;">Return True
        Case </span><span style="color:#a31515;">".jpeg"
            </span><span style="color:blue;">Return True
        Case Else
            Return False
    End Select
End Function
</span><span style="color:green;">'................Function To Check For Valid File Extension End................

'..................Function To Create GUID For File Name Start.................
'declare a function to create a GUID based on the current date and time to be added to the _
'file extension of the uploaded file so as to make it unique.
'declare a variable named strGuid and set it equal to nothing for now
'using the try exception handling, set the strGuid variable equal to current date and time
'if there is a problem creating the GUID, throw an exception
'end try
'return the generated GUID
'end the function
</span><span style="color:blue;">Function </span>fnGuid() <span style="color:blue;">As String
    Dim </span>strGuid <span style="color:blue;">As String </span>= <span style="color:#a31515;">""
    </span><span style="color:blue;">Try
        With </span>Today
            strGuid = .Year &amp; .Month &amp; .Day &amp; Now.Hour &amp; Now.Minute &amp; Now.Second <span style="color:blue;">End With
    Catch </span>ex <span style="color:blue;">As </span>Exception
        <span style="color:blue;">Throw </span>ex
    <span style="color:blue;">End Try
    Return </span>strGuid<span style="color:blue;">End Function
</span><span style="color:green;">'..................Function To Create GUID For File Name End.................

'................Subprocedure To Display Uploaded Images Start...............
'create a sub procedure to display uploaded images
'declare a variable named upfolder and set it equal to the path of the uploaded images folder
'declare a variable named dir as the directory info of the uploaded images folder
'create a datasource from the contents of this directory/folder
'and bind to each image in the folder
</span><span style="color:blue;">Sub </span>Page_PreRender()
    <span style="color:blue;">Dim </span>upFolder <span style="color:blue;">As String </span>= MapPath(<span style="color:#a31515;">"~/UploadImages/"</span>)
    <span style="color:blue;">Dim </span>dir <span style="color:blue;">As New </span>DirectoryInfo(upFolder)
    dlstImages.DataSource = dir.GetFiles()
    dlstImages.DataBind()
<span style="color:blue;">End Sub</span><span style="color:green;">'................Subprocedure To Display Uploaded Images End...............</span>
</pre>
</div>
<p></p>
<li>That&#8217;s it! Enjoy.
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/upload-complete.jpg"><img style="border-width:0;" height="214" alt="upload-complete" src="http://aspnetgoodies.files.wordpress.com/2007/12/upload-complete-thumb.jpg?w=244&#038;h=214" width="244" border="0"></a> </li>
</ol>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/aspnetgoodies.wordpress.com/75/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/aspnetgoodies.wordpress.com/75/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aspnetgoodies.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aspnetgoodies.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aspnetgoodies.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aspnetgoodies.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aspnetgoodies.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aspnetgoodies.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aspnetgoodies.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aspnetgoodies.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aspnetgoodies.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aspnetgoodies.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=75&subd=aspnetgoodies&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://aspnetgoodies.wordpress.com/2007/12/13/aspnet-image-upload-with-unique-file-name-file-size-and-file-type-validation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2949e6f1224f8b5f410d410d7eeba3a1?s=96&#38;d=identicon" medium="image">
			<media:title type="html">aspnetgoodies</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/upload-complete-thumb.jpg" medium="image">
			<media:title type="html">upload-complete</media:title>
		</media:content>
	</item>
		<item>
		<title>Client Side OnClick Confirm Popup Plus Mouse Over Action in ASP.NET</title>
		<link>http://aspnetgoodies.wordpress.com/2007/12/13/client-side-onclick-confirm-popup-plus-mouse-over-action-in-aspnet/</link>
		<comments>http://aspnetgoodies.wordpress.com/2007/12/13/client-side-onclick-confirm-popup-plus-mouse-over-action-in-aspnet/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 18:31:17 +0000</pubDate>
		<dc:creator>aspnetgoodies</dc:creator>
				<category><![CDATA[Client Side OnClick Confirm Popup Plus Mouse Over Actio]]></category>
		<category><![CDATA[client side validation confirm popup asp.net button mou]]></category>

		<guid isPermaLink="false">http://aspnetgoodies.wordpress.com/2007/12/13/client-side-onclick-confirm-popup-plus-mouse-over-action-in-aspnet/</guid>
		<description><![CDATA[The confirm window is an essential element often required on submission forms. It provides a last warning to the user before executing a particular code. When the submit button is pressed by the user, a warning window pops up with the option to go ahead (OK) or to cancel. It is a very simple client side Javascript that can be use in many different ways and in many different situations.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=74&subd=aspnetgoodies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><u><font color="#0080c0">Objective:</font></u> This article describes how to add a client side confirm popup window to your buttons.</p>
<p><u><font color="#0080c0">Background:</font></u> The confirm window is an essential element often required on submission forms. It provides a last warning to the user before executing a particular code. When the submit button is pressed by the user, a warning window pops up with the option to go ahead (OK) or to cancel. It is a very simple client side Javascript that can be use in many different ways and in many different situations.</p>
<p><u><font color="#0080c0">Procedure:</font></u> Follow instructions below to accomplish this task. This article uses Visual Web Developer Express 2008.</p>
<ol>
<li>Drag and drop an asp:button onto your page from the Standard tab of your toolbox.
<li>In the properties manager window find the the OnClientClick property under the Behaviors section.
<li>Copy and paste the following short Javascript in there:</p>
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:20px;padding:4px;"><font color="#008080">return confirm(&#8216;Are you sure?&#8217;);</font></div>
<p> 
<li>As you can see, the message above will be &#8220;Are you sure?&#8221; You can change this to whatever you want your message to be.
<li>Now let&#8217;s go into code view and set a couple of other properties for this button to create a mouse over action as well. Add the following code to your button:</p>
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:40px;padding:4px;"><font color="#008080">onmouseover=&#8221;this.value=&#8217;Click Here!&#8217;&#8221;<br />onmouseout=&#8221;this.value=&#8217;Submit&#8217;&#8221;</font></div>
<p> 
<li>Your final code for the button should look like the following:</p>
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:150px;padding:4px;">
<pre><span style="color:green;">&lt;!-- Button with clientside confirm --&gt;
</span><span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">Button </span><span style="color:red;">ID</span><span style="color:blue;">="Button1" </span><span style="color:red;">runat</span><span style="color:blue;">="server"
 </span><span style="color:red;">OnClientClick</span><span style="color:blue;">="return confirm('Are you sure?');"
 </span><span style="color:red;">onmouseover</span><span style="color:blue;">="this.value='Click Here!'"
 </span><span style="color:red;">onmouseout</span><span style="color:blue;">="this.value='Submit'"
 </span><span style="color:red;">Text</span><span style="color:blue;">="Submit"/&gt;</span></pre>
</div>
<p></p>
<li>That&#8217;s it! Enjoy.
<li>and the final result&#8230;
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/client-onclick-confirm.jpg"><img style="border-width:0;" height="161" alt="client-onclick-confirm" src="http://aspnetgoodies.files.wordpress.com/2007/12/client-onclick-confirm-thumb.jpg?w=244&#038;h=161" width="244" border="0"></a> </li>
</ol>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/aspnetgoodies.wordpress.com/74/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/aspnetgoodies.wordpress.com/74/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aspnetgoodies.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aspnetgoodies.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aspnetgoodies.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aspnetgoodies.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aspnetgoodies.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aspnetgoodies.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aspnetgoodies.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aspnetgoodies.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aspnetgoodies.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aspnetgoodies.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=74&subd=aspnetgoodies&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://aspnetgoodies.wordpress.com/2007/12/13/client-side-onclick-confirm-popup-plus-mouse-over-action-in-aspnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2949e6f1224f8b5f410d410d7eeba3a1?s=96&#38;d=identicon" medium="image">
			<media:title type="html">aspnetgoodies</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/client-onclick-confirm-thumb.jpg" medium="image">
			<media:title type="html">client-onclick-confirm</media:title>
		</media:content>
	</item>
		<item>
		<title>Multiple Columns In Data Bound Drop Down List</title>
		<link>http://aspnetgoodies.wordpress.com/2007/12/13/multiple-columns-in-data-bound-drop-down-list/</link>
		<comments>http://aspnetgoodies.wordpress.com/2007/12/13/multiple-columns-in-data-bound-drop-down-list/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 07:22:52 +0000</pubDate>
		<dc:creator>aspnetgoodies</dc:creator>
				<category><![CDATA[Multiple Columns In Data Bound Drop Down List]]></category>
		<category><![CDATA[Multiple Columns Concatenate In Data Bound Drop Down Li]]></category>

		<guid isPermaLink="false">http://aspnetgoodies.wordpress.com/2007/12/13/multiple-columns-in-data-bound-drop-down-list/</guid>
		<description><![CDATA[Almost always when I use a data bound drop down list, I find it necessary to display data from more than one column of my database table. In classic ASP this used to be a no brainer but as you may have noticed in asp.net things are a little different which sometimes leads to quite a bit of hair pulling, eye poking and other types of chain yanking. So, to avoid injury, my quick solution for this is to concatenate or combine the data columns in my query string. Surely, there are other ways of doing this, but this is quick and requires no extra strenuous code writing and it does the job very well.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=73&subd=aspnetgoodies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><u><font color="#0080c0">Objective:</font></u> This article describes how you can add two columns bound data to a DropDownList.</p>
<p><u><font color="#0080c0">Background:</font></u> Almost always when I use a data bound drop down list, I find it necessary to display data from more than one column of my database table. In classic ASP this used to be a no brainer but as you may have noticed in asp.net things are a little different which sometimes leads to quite a bit of hair pulling, eye poking and other types of chain yanking. So, to avoid injury, my quick solution for this is to concatenate or combine the data columns in my query string. Surely, there are other ways of doing this, but this is quick and requires no extra strenuous code writing and it does the job very well.</p>
<p><u><font color="#0080c0">Procedure:</font></u> Follow instructions below to accomplish this task. This article uses Visual Web Developer Express 2008 and SQL Server Express 2005 with the NorthWind database as an example.</p>
<ol>
<li>Create a new web form in your site and name it anything you want.
<li>In design view, drag and drop a DropDownList control onto your page from the standard tab of your toolbox.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/drop-down-list.jpg"><img style="border-width:0;" height="177" alt="drop-down-list" src="http://aspnetgoodies.files.wordpress.com/2007/12/drop-down-list-thumb.jpg?w=244&#038;h=177" width="244" border="0"></a> <br /> 
<li>Click on the smart tag if its not already open and click on Choose Data Source. (image above)</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/choose-data-source.jpg"><img style="border-width:0;" height="191" alt="choose-data-source" src="http://aspnetgoodies.files.wordpress.com/2007/12/choose-data-source-thumb.jpg?w=244&#038;h=191" width="244" border="0"></a> <br /> 
<li>In the Data Source Configuration Wizard select New Data Source. (image above)</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/database.jpg"><img style="border-width:0;" height="181" alt="database" src="http://aspnetgoodies.files.wordpress.com/2007/12/database-thumb.jpg?w=244&#038;h=181" width="244" border="0"></a> <br /> 
<li>Select &#8220;Database&#8221; and click OK. (image above)
<li>In the next window I choose the NorthWind connection string that I already added earlier to my site as shown in the image below. If you don&#8217;t have a connection string configured yet for your database, click the &#8220;New Connection&#8221; button to configure one.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/choose-data-connection.jpg"><img style="border-width:0;" height="180" alt="choose-data-connection" src="http://aspnetgoodies.files.wordpress.com/2007/12/choose-data-connection-thumb.jpg?w=244&#038;h=180" width="244" border="0"></a> <br /> 
<li>On the next window, select the first option to specify a custom SQL statement as shown below and click Next.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/custom-sql.jpg"><img style="border-width:0;" height="180" alt="custom-sql" src="http://aspnetgoodies.files.wordpress.com/2007/12/custom-sql-thumb.jpg?w=244&#038;h=180" width="244" border="0"></a> <br /> 
<li>In the next window click the Query Builder button and then add the Employees table to the query builder as shown below and close the add table window.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/add-table.jpg"><img style="border-width:0;" height="208" alt="add-table" src="http://aspnetgoodies.files.wordpress.com/2007/12/add-table-thumb.jpg?w=244&#038;h=208" width="244" border="0"></a> <br /> 
<li>I Use the following SQL statement to combine the employees First and Last Name. I also selected the EmployeeID column to use as the postback value for our drop down list control.</p>
<div style="border-right:#999999 1px solid;border-top:#999999 1px solid;border-left:#999999 1px solid;width:95%;border-bottom:#999999 1px solid;height:20px;padding:4px;"><font color="#008080">SELECT EmployeeID, FirstName + &#8216; &#8216; + LastName AS EmployeeName FROM Employees</font></div>
<p> 
<li>Now click Next, then click Finish to close that window.
<li>In the remaining window configure the fields as show in the picture below.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/drop-down-list-config.jpg"><img style="border-width:0;" height="182" alt="drop-down-list-config" src="http://aspnetgoodies.files.wordpress.com/2007/12/drop-down-list-config-thumb.jpg?w=244&#038;h=182" width="244" border="0"></a> <br /> 
<li>Click OK and you are done. Load the page into your browser. You should see something like the image below.</p>
<p><a href="http://aspnetgoodies.files.wordpress.com/2007/12/dropdownlist-results.jpg"><img style="border-width:0;" height="174" alt="dropdownlist-results" src="http://aspnetgoodies.files.wordpress.com/2007/12/dropdownlist-results-thumb.jpg?w=244&#038;h=174" width="244" border="0"></a> <br /> 
<li>That&#8217;s it! Enjoy. </li>
</ol>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/aspnetgoodies.wordpress.com/73/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/aspnetgoodies.wordpress.com/73/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/aspnetgoodies.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/aspnetgoodies.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/aspnetgoodies.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/aspnetgoodies.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/aspnetgoodies.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/aspnetgoodies.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/aspnetgoodies.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/aspnetgoodies.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/aspnetgoodies.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/aspnetgoodies.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=aspnetgoodies.wordpress.com&blog=2278114&post=73&subd=aspnetgoodies&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://aspnetgoodies.wordpress.com/2007/12/13/multiple-columns-in-data-bound-drop-down-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2949e6f1224f8b5f410d410d7eeba3a1?s=96&#38;d=identicon" medium="image">
			<media:title type="html">aspnetgoodies</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/drop-down-list-thumb.jpg" medium="image">
			<media:title type="html">drop-down-list</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/choose-data-source-thumb.jpg" medium="image">
			<media:title type="html">choose-data-source</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/database-thumb.jpg" medium="image">
			<media:title type="html">database</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/choose-data-connection-thumb.jpg" medium="image">
			<media:title type="html">choose-data-connection</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/custom-sql-thumb.jpg" medium="image">
			<media:title type="html">custom-sql</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/add-table-thumb.jpg" medium="image">
			<media:title type="html">add-table</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/drop-down-list-config-thumb.jpg" medium="image">
			<media:title type="html">drop-down-list-config</media:title>
		</media:content>

		<media:content url="http://aspnetgoodies.files.wordpress.com/2007/12/dropdownlist-results-thumb.jpg" medium="image">
			<media:title type="html">dropdownlist-results</media:title>
		</media:content>
	</item>
	</channel>
</rss>