<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-7622642958068848741</atom:id><lastBuildDate>Thu, 05 Sep 2024 19:01:45 +0000</lastBuildDate><category>ASP.NET</category><category>AJAX</category><category>Activiation Email</category><category>Code Snippets</category><category>CollapsiblePanel</category><category>Android</category><category>Connection  Strings</category><category>Control Toolkit</category><category>Email</category><category>Embedding Image</category><category>File Upload</category><category>Foreign Characters</category><category>IIS</category><category>Linux</category><category>Locked Users</category><category>Master Page</category><category>Microsoft Charting Control</category><category>Pop Up</category><category>Remote Registry</category><category>Root Password Reset</category><category>SQL</category><category>Shrink</category><category>Special Characters</category><category>Symbols</category><category>Ubuntu</category><category>VMware</category><category>Virtual Disk Image</category><category>Visual Studio</category><category>WMI</category><category>Web Service</category><title>Lance Spence</title><description>Knowledge is power...Share the knowledge and increase the power for everyone.</description><link>http://lspence.blogspot.com/</link><managingEditor>noreply@blogger.com (Lance Spence)</managingEditor><generator>Blogger</generator><openSearch:totalResults>28</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-3794730041312762791</guid><pubDate>Sat, 14 Jun 2014 14:32:00 +0000</pubDate><atom:updated>2014-06-14T10:32:22.656-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Root Password Reset</category><category domain="http://www.blogger.com/atom/ns#">Ubuntu</category><title>Resetting Root Password in Ubuntu</title><description>There are a number of references for how to reset your root password in Ubuntu, if you&#39;ve forgotten it that reference booting into recovery mode. I&#39;ve found a simple way to do it that only requires a couple of steps.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Enter the following command: &lt;b&gt;sudo passwd root&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;You will be prompted to enter your new password twice&lt;/li&gt;
&lt;li&gt;Enter su root and your new password&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
DONE! Very short and to the point!</description><link>http://lspence.blogspot.com/2014/06/resetting-root-password-in-ubuntu.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-2991051351418715964</guid><pubDate>Fri, 11 May 2012 02:52:00 +0000</pubDate><atom:updated>2012-05-10T22:52:26.718-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android</category><title>Stock Purchase Calculator</title><description>&lt;p&gt;Today I released Stock Purchase Calculator v1.0.0 to Google Play. The application provides a way to quickly get an idea of how many stocks you can buy with a certain amount of money and how much you could make if you sold the stock at a certain price? &lt;/p&gt;  &lt;p&gt;The application provides the total purchase and total sell amounts for a given number of stock shares minus broker commissions. In addition both net profit and loss, net change, and the stock symbol for a given company are reported. &lt;/p&gt;  &lt;p&gt;The following is a direct link to the application on Google Play:&lt;/p&gt;  &lt;p&gt;&lt;a title=&quot;https://play.google.com/store/apps/details?id=com.lancespence.spc&amp;amp;feature=search_result#?t=W251bGwsMSwyLDEsImNvbS5sYW5jZXNwZW5jZS5zcGMiXQ..&quot; href=&quot;https://play.google.com/store/apps/details?id=com.lancespence.spc&amp;amp;feature=search_result#?t=W251bGwsMSwyLDEsImNvbS5sYW5jZXNwZW5jZS5zcGMiXQ..&quot;&gt;https://play.google.com/store/apps/details?id=com.lancespence.spc&amp;amp;feature=search_result#?t=W251bGwsMSwyLDEsImNvbS5sYW5jZXNwZW5jZS5zcGMiXQ..&lt;/a&gt;&lt;/p&gt;  </description><link>http://lspence.blogspot.com/2012/05/stock-purchase-calculator.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-3980359844833652421</guid><pubDate>Tue, 25 Oct 2011 22:42:00 +0000</pubDate><atom:updated>2011-10-25T18:48:10.877-04:00</atom:updated><title>Displaying User Associated Membership Image</title><description>I recently came across a post in the ASP.NET forums where a user had a need to allow users of his web site to upload an image during account creation. The user’s image was then redisplayed upon successful login into the website. I decided to put a little sample together detailing how this could be accomplished.&lt;br /&gt;
&lt;h4&gt;Database Setup&lt;/h4&gt;Let’s start first with the database setup. I’m using SQL Server 2008, but SQL Server 2008 Express, SQL Server 2005, and SQL Server 2005 Express should work equally as well.&lt;br /&gt;
Using SQL Server Management Studio I created a new database called &lt;b&gt;TestDB&lt;/b&gt;. I then added the ASP.NET Membership, Roles, and Profile providers to the database with the following command:&lt;br /&gt;
&lt;i&gt;aspnet_regsql –S . –E –A mrp –d TestDB&lt;/i&gt;&lt;br /&gt;
You can enter &lt;i&gt;aspnet_regsql /?&lt;/i&gt; for a list of available options.&lt;br /&gt;
Once I had all of the appropriate tables, stored procedures, views, etc. added to my database I created a table called &lt;b&gt;aspnet_UserImages&lt;/b&gt;. This table contains the following columns:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;UserId &lt;/li&gt;
&lt;li&gt;ImageId &lt;/li&gt;
&lt;li&gt;Image &lt;/li&gt;
&lt;/ul&gt;I created a foreign key linking the &lt;b&gt;UserId&lt;/b&gt; column from the aspnet_Users table to the &lt;b&gt;UserId&lt;/b&gt; of the aspnet_UserImages table. In addition the &lt;b&gt;Delete Rule&lt;/b&gt; within the aspnet_UserImages table was set to &lt;b&gt;Cascade&lt;/b&gt;. Doing this allows the user’s image associated with the UserId to be deleted from the aspnet_UserImages table when the user’s account is removed via the &lt;b&gt;Web Site Administration Tool&lt;/b&gt; or via &lt;b&gt;SQL Server Management Studio&lt;/b&gt; directly. &lt;br /&gt;
&lt;a href=&quot;http://lh5.ggpht.com/-Ja6VsSB6GXg/Tqc7Va6I1aI/AAAAAAAAAIQ/NN6TZEihjZI/s1600-h/image8.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;244&quot; src=&quot;http://lh6.ggpht.com/-K6vTkeAHJLs/Tqc7VvmcGEI/AAAAAAAAAIY/rgwx_VZoUDQ/image_thumb2.png?imgmax=800&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;233&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
I’ve included two stored procedures along with the sample that insert and retrieve the uploaded image associated with the user’s account. I’ve also included a script that will create the aspnet_UserImages table along with the foreign key constraint mentioned earlier.&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;New User Registration&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
I’ve converted the CreateUserWizard to a template and added a FileUpload control to it, so that users can upload an image of their choice at the time they create their account.&lt;br /&gt;
The code is pretty straightforward a few things to note though. First I save the user’s entered username into a session variable and later retrieve it when the user logs in, so that it can be used in retrieving the image that is associated with the user’s account. Another thing I’ve done is incorporated code to resize the uploaded image, so that you can control to a degree the amount of space the images will consume within your database. Finally I check the file extension, so that only the types defined are accepted, if a non-supported file type is uploaded the user account is not created.&lt;br /&gt;
&lt;a href=&quot;http://lh6.ggpht.com/-yjGziwOT0KI/Tqc7VxrXsfI/AAAAAAAAAIg/in3je3y4yjk/s1600-h/image%25255B2%25255D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;159&quot; src=&quot;http://lh3.ggpht.com/-Vz-vwG6dV64/Tqc7WGNXzBI/AAAAAAAAAIo/ZTB45uZCD3w/image_thumb.png?imgmax=800&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;244&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://lh4.ggpht.com/-dd20DFEROgQ/Tqc7WXBXUaI/AAAAAAAAAIw/3XKC7zM-zJk/s1600-h/image%25255B5%25255D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;166&quot; src=&quot;http://lh5.ggpht.com/-ca7JLN8lA3Y/Tqc7WVfwhtI/AAAAAAAAAI4/Zbdeg5MS-wQ/image_thumb%25255B1%25255D.png?imgmax=800&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;244&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; NewUserWizard_CreatingUser(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, LoginCancelEventArgs e)
{
Label invalidFile = (Label)CreateUserWizardStep1.ContentTemplateContainer.FindControl(&lt;span class=&quot;str&quot;&gt;&quot;ErrorLabel&quot;&lt;/span&gt;);
FileUpload userImage = (FileUpload)CreateUserWizardStep1.ContentTemplateContainer.FindControl(&lt;span class=&quot;str&quot;&gt;&quot;UserImageFileUpload&quot;&lt;/span&gt;);

&lt;span class=&quot;rem&quot;&gt;// Check whether we have a file to save or not.&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (userImage.HasFile)
{
&lt;span class=&quot;rem&quot;&gt;// Check that the file type is supported.&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; fileExtension = Path.GetExtension(userImage.PostedFile.FileName);

&lt;span class=&quot;kwrd&quot;&gt;switch&lt;/span&gt; (fileExtension)
{
&lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;.gif&quot;&lt;/span&gt;:
&lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
&lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;.jpg&quot;&lt;/span&gt;:
&lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;.jpeg&quot;&lt;/span&gt;:
&lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
&lt;span class=&quot;kwrd&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;str&quot;&gt;&quot;.png&quot;&lt;/span&gt;:
&lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
&lt;span class=&quot;kwrd&quot;&gt;default&lt;/span&gt;:
invalidFile.Visible = &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;;
invalidFile.Text = &lt;span class=&quot;str&quot;&gt;&quot;Supported file types are GIF, JPG, PNG.&quot;&lt;/span&gt;;
e.Cancel = &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;;
&lt;span class=&quot;kwrd&quot;&gt;break&lt;/span&gt;;
}
}
}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, &quot;Courier New&quot;, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;User login&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I have a default.aspx page that the user is redirected to upon successful authentication. This page contains the code that gets the user’s Guid and then passes it to a Generic Handler via querystring, which in turn gets the image associated with the user’s account and displays it.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lh6.ggpht.com/-42RHxZEmjac/Tqc7WulIdXI/AAAAAAAAAJA/xAdzczGxkrQ/s1600-h/image%25255B8%25255D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;103&quot; src=&quot;http://lh5.ggpht.com/-l1kO8L8rUTE/Tqc7W7OurtI/AAAAAAAAAJI/d4sKIHRPsuI/image_thumb%25255B2%25255D.png?imgmax=800&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;244&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lh3.ggpht.com/-WUL-6kb18G4/Tqc7XNDzbwI/AAAAAAAAAJQ/xmdK2oPlwfU/s1600-h/image%25255B11%25255D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;85&quot; src=&quot;http://lh5.ggpht.com/-Vpp4Ve8xoPQ/Tqc7XdjkV5I/AAAAAAAAAJY/I3yoGzI2JBI/image_thumb%25255B3%25255D.png?imgmax=800&quot; style=&quot;background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; margin: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;image&quot; width=&quot;244&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; DisplayUserImage()
{
&lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (Session[&lt;span class=&quot;str&quot;&gt;&quot;UserName&quot;&lt;/span&gt;] != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
{
MembershipUser user = Membership.GetUser(Session[&lt;span class=&quot;str&quot;&gt;&quot;UserName&quot;&lt;/span&gt;].ToString());
Guid userGuid = (Guid)user.ProviderUserKey;
UserImage.ImageUrl = &lt;span class=&quot;str&quot;&gt;&quot;Image.ashx?userGuid=&quot;&lt;/span&gt; + userGuid;
}
}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, &quot;Courier New&quot;, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;The handler that retrieves the user’s image associated with their account.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; ProcessRequest (HttpContext context)
{
&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; userGuid = &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Empty;

&lt;span class=&quot;rem&quot;&gt;// Check that the querystring value is not null.&lt;/span&gt;
&lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (context.Request.QueryString[&lt;span class=&quot;str&quot;&gt;&quot;userGuid&quot;&lt;/span&gt;] != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)
{
userGuid = context.Request.QueryString[&lt;span class=&quot;str&quot;&gt;&quot;userGuid&quot;&lt;/span&gt;];
}
&lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt;
{
&lt;span class=&quot;kwrd&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; ArgumentException(&lt;span class=&quot;str&quot;&gt;&quot;Missing user id.&quot;&lt;/span&gt;);
}

context.Response.ContentType = &lt;span class=&quot;str&quot;&gt;&quot;image/jpeg&quot;&lt;/span&gt;;

&lt;span class=&quot;rem&quot;&gt;// Pass the user&#39;s guid in, so that we can get the image associated with the logged in user.&lt;/span&gt;
Stream strm = GetImage(userGuid);
&lt;span class=&quot;kwrd&quot;&gt;byte&lt;/span&gt;[] buffer = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;byte&lt;/span&gt;[2048];
&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; byteSeq = strm.Read(buffer, 0, 2048);

&lt;span class=&quot;kwrd&quot;&gt;while&lt;/span&gt; (byteSeq &amp;gt; 0)
{
context.Response.OutputStream.Write(buffer, 0, byteSeq);
byteSeq = strm.Read(buffer, 0, 2048);
}
}

&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; Stream GetImage(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; id)
{
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; (SqlConnection conn = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SqlConnection(ConfigurationManager.ConnectionStrings[&lt;span class=&quot;str&quot;&gt;&quot;MyConnection&quot;&lt;/span&gt;].ConnectionString))
{
&lt;span class=&quot;kwrd&quot;&gt;try&lt;/span&gt;
{
&lt;span class=&quot;kwrd&quot;&gt;using&lt;/span&gt; (SqlCommand cmd = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; SqlCommand(&lt;span class=&quot;str&quot;&gt;&quot;GetUserImage&quot;&lt;/span&gt;, conn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(&lt;span class=&quot;str&quot;&gt;&quot;@UserId&quot;&lt;/span&gt;, id);

conn.Open();
&lt;span class=&quot;kwrd&quot;&gt;byte&lt;/span&gt;[] img = (&lt;span class=&quot;kwrd&quot;&gt;byte&lt;/span&gt;[])cmd.ExecuteScalar();

&lt;span class=&quot;kwrd&quot;&gt;try&lt;/span&gt;
{
&lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; MemoryStream(img);
}
&lt;span class=&quot;kwrd&quot;&gt;catch&lt;/span&gt;
{
&lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;;
}
&lt;span class=&quot;kwrd&quot;&gt;finally&lt;/span&gt;
{
conn.Close();
}
}
}
&lt;span class=&quot;kwrd&quot;&gt;catch&lt;/span&gt; (SqlException sqlEx)
{
&lt;span class=&quot;kwrd&quot;&gt;throw&lt;/span&gt; sqlEx;
}
}
}

&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;bool&lt;/span&gt; IsReusable 
{
get
{
&lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;;
}
}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, &quot;Courier New&quot;, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://sites.google.com/site/dotnetsnippets/Web-Controls/MembershipWithImage.zip?attredirects=0&amp;amp;d=1&quot;&gt;MembershipWithImage&lt;/a&gt;</description><link>http://lspence.blogspot.com/2011/10/displaying-user-associated-membership.html</link><author>noreply@blogger.com (Lance Spence)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-K6vTkeAHJLs/Tqc7VvmcGEI/AAAAAAAAAIY/rgwx_VZoUDQ/s72-c/image_thumb2.png?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-5485953470696489344</guid><pubDate>Fri, 10 Jun 2011 02:39:00 +0000</pubDate><atom:updated>2012-03-19T16:02:25.056-04:00</atom:updated><title>Useful .Net Tools</title><description>I thought I’d share a small list of free and open source .Net tools that you might find useful during your development efforts. I’ll continue to add to this list as I learn of new tools.&lt;br /&gt;
&lt;b&gt;Profiling Tools&lt;/b&gt;&lt;br /&gt;
Slimetune - &lt;a href=&quot;http://code.google.com/p/slimtune/&quot; title=&quot;http://code.google.com/p/slimtune/&quot;&gt;http://code.google.com/p/slimtune/&lt;/a&gt;&lt;br /&gt;
xteprofiler - &lt;a href=&quot;http://www.xteprofiler.com/&quot; title=&quot;http://www.xteprofiler.com/&quot;&gt;http://www.xteprofiler.com/&lt;/a&gt;&lt;br /&gt;
Prof-It for C# - &lt;a href=&quot;http://dotnet.jku.at/projects/Prof-It/Default.aspx&quot; title=&quot;http://dotnet.jku.at/projects/Prof-It/Default.aspx&quot;&gt;http://dotnet.jku.at/projects/Prof-It/Default.aspx&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Decompilers&lt;/b&gt;&lt;br /&gt;
JustDecompile - &lt;a href=&quot;http://www.telerik.com/products/decompiling.aspx&quot; title=&quot;http://www.telerik.com/products/decompiling.aspx&quot;&gt;http://www.telerik.com/products/decompiling.aspx&lt;/a&gt;&lt;br /&gt;
dotPeek EAP - &lt;a href=&quot;http://www.jetbrains.com/decompiler/&quot; title=&quot;http://www.jetbrains.com/decompiler/&quot;&gt;http://www.jetbrains.com/decompiler/&lt;/a&gt;&lt;br /&gt;
ILSpy - &lt;a href=&quot;http://wiki.sharpdevelop.net/ilspy.ashx&quot; title=&quot;http://wiki.sharpdevelop.net/ilspy.ashx&quot;&gt;http://wiki.sharpdevelop.net/ilspy.ashx&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Load Testing Tools&lt;/b&gt;&lt;br /&gt;
loadUI - &lt;a href=&quot;http://www.eviware.com/loadUI/whats-new-in-loadui-15.html&quot; title=&quot;http://www.eviware.com/loadUI/whats-new-in-loadui-15.html&quot;&gt;http://www.eviware.com/loadUI/whats-new-in-loadui-15.html&lt;/a&gt;&lt;br /&gt;
openSTA - &lt;a href=&quot;http://opensta.org/&quot; title=&quot;http://opensta.org/&quot;&gt;http://opensta.org/&lt;/a&gt;&lt;br /&gt;
storm - &lt;a href=&quot;http://storm.codeplex.com/&quot;&gt;http://storm.codeplex.com/ &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Functional Testing Tools&lt;/b&gt;&lt;br /&gt;
soapUI - &lt;a href=&quot;http://www.eviware.com/soapUI/what-is-soapui.html&quot; title=&quot;http://www.eviware.com/soapUI/what-is-soapui.html&quot;&gt;http://www.eviware.com/soapUI/what-is-soapui.html&lt;/a&gt;&lt;br /&gt;
WebAii Testing Framework - &lt;a href=&quot;http://www.telerik.com/automated-testing-tools/webaii-framework-features.aspx&quot; title=&quot;http://www.telerik.com/automated-testing-tools/webaii-framework-features.aspx&quot;&gt;http://www.telerik.com/automated-testing-tools/webaii-framework-features.aspx&lt;/a&gt;</description><link>http://lspence.blogspot.com/2011/06/useful-net-tools.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-4512638403072400781</guid><pubDate>Sun, 23 May 2010 14:22:00 +0000</pubDate><atom:updated>2010-05-23T10:26:28.991-04:00</atom:updated><title>Pre-populating the Login Control’s Username and Password</title><description>&lt;p&gt;We’ve all visited websites that provide a test or demo site and allow you to login for the purpose of testing features out using specific user accounts with assigned roles. If you have a website or web application that needs to provide this type of functionality, I’m going to show you how you can save the user a few keystrokes by filling in the Username and Password for them, so that all they have to do is click the Login button.&lt;/p&gt;  &lt;p&gt;What I have done is created three accounts: Admin, User, and Guest along with a Default.aspx page which resides under the respective folder. The folder structure is as follows for these accounts:&lt;/p&gt;  &lt;p&gt;Admin/Default.aspx&lt;/p&gt;  &lt;p&gt;User/Default.aspx&lt;/p&gt;  &lt;p&gt;Guest/Default.aspx&lt;/p&gt;  &lt;p&gt;I’ve created a login page (Login.aspx) and dropped a Login Control on it. The Login Control has been converted to a template and I’ve added a label and dropdown list to it. The dropdown list contains the user accounts that will be selected for logging in. &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/_Vypa7VcJWIU/S_k6McVQV0I/AAAAAAAAAG8/kA3ZmDwu8mc/s1600-h/image%5B5%5D.png&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/_Vypa7VcJWIU/S_k6MpUYkJI/AAAAAAAAAHA/lix8w50aCmw/image_thumb%5B1%5D.png?imgmax=800&quot; width=&quot;212&quot; height=&quot;155&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Within the Load event of the Login Control I get a reference to the dropdown list and password textbox controls, so that they can be used in selecting the proper user and populating the password textbox. I add an attribute to the password textbox, which sets the password, so that the user does not have to type it in. &lt;strong&gt;Something to be mindful of is that the password is viewable in plain text&lt;/strong&gt; if you view the pages source. Because these accounts are being used to save the user a few of keystrokes for a test or demo site login this isn’t much of an issue.&lt;/p&gt;  &lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 415px; padding-right: 5px; height: 637px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;DropDownList userLogin = (DropDownList)DemoLogin.FindControl(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;UserDropDownList&lt;/span&gt;&amp;quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;TextBox passwd = (TextBox)DemoLogin.FindControl(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;Password&lt;/span&gt;&amp;quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;switch&lt;/span&gt; (userLogin.SelectedValue)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;{&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;   &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; &amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;Admin&lt;/span&gt;&amp;quot;:&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;       DemoLogin.UserName = userLogin.SelectedValue;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;       passwd.Attributes.Add(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;value&lt;/span&gt;&amp;quot;, &amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;Adm!n123&lt;/span&gt;&amp;quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;       &lt;span style=&quot;color: #0000ff&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;   &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; &amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;User&lt;/span&gt;&amp;quot;:&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;       DemoLogin.UserName = userLogin.SelectedValue;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;       passwd.Attributes.Add(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;value&lt;/span&gt;&amp;quot;, &amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;U$er123&lt;/span&gt;&amp;quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;       &lt;span style=&quot;color: #0000ff&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;   &lt;span style=&quot;color: #0000ff&quot;&gt;case&lt;/span&gt; &amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;Guest&lt;/span&gt;&amp;quot;:&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;       DemoLogin.UserName = userLogin.SelectedValue;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;       passwd.Attributes.Add(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;value&lt;/span&gt;&amp;quot;, &amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;Gue$t123&lt;/span&gt;&amp;quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;       &lt;span style=&quot;color: #0000ff&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;   &lt;span style=&quot;color: #0000ff&quot;&gt;default&lt;/span&gt;:&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;       DemoLogin.UserName = &lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt;.Empty;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;       passwd.Attributes.Add(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;value&lt;/span&gt;&amp;quot;, &amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;&lt;/span&gt;&amp;quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;       &lt;span style=&quot;color: #0000ff&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;}&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The only other thing needed is within the Login Control’s LoggedIn event to check the role of the user and then redirect them to the appropriate Default.aspx page.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style=&quot;border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 418px; padding-right: 5px; height: 482px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (Roles.IsUserInRole(DemoLogin.UserName, &amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;Admin&lt;/span&gt;&amp;quot;))&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;{&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;   Response.Redirect(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;~/Admin/Default.aspx&lt;/span&gt;&amp;quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (Roles.IsUserInRole(DemoLogin.UserName, &amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;User&lt;/span&gt;&amp;quot;))&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;{&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;   Response.Redirect(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;~/User/Default.aspx&lt;/span&gt;&amp;quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt; (Roles.IsUserInRole(DemoLogin.UserName, &amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;Guest&lt;/span&gt;&amp;quot;))&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;{&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;   Response.Redirect(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;~/Guest/Default.aspx&lt;/span&gt;&amp;quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;{&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;   Response.Redirect(&amp;quot;&lt;span style=&quot;color: #8b0000&quot;&gt;~/Login.aspx&lt;/span&gt;&amp;quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 9px&quot;&gt;}&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/_Vypa7VcJWIU/S_k6Nm6_LxI/AAAAAAAAAHE/TbFRku63llI/s1600-h/image%5B8%5D.png&quot;&gt;&lt;img style=&quot;border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/_Vypa7VcJWIU/S_k6N0ZB-9I/AAAAAAAAAHI/uqrslM7uy7k/image_thumb%5B2%5D.png?imgmax=800&quot; width=&quot;156&quot; height=&quot;56&quot; /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;While this is pretty trivial, it does save a few keystrokes by allowing the user to just select the user account they wish to login as and then all they have to do is click the login button.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://sites.google.com/site/dotnetsnippets/security/PopluateLoginSample.zip?attredirects=0&amp;amp;d=1&quot;&gt;PopulateLoginSample.zip&lt;/a&gt;&lt;/p&gt;  </description><link>http://lspence.blogspot.com/2010/05/pre-populating-login-controls-username.html</link><author>noreply@blogger.com (Lance Spence)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/_Vypa7VcJWIU/S_k6MpUYkJI/AAAAAAAAAHA/lix8w50aCmw/s72-c/image_thumb%5B1%5D.png?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-7275759161293276598</guid><pubDate>Fri, 07 May 2010 02:48:00 +0000</pubDate><atom:updated>2012-05-08T08:38:45.493-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><category domain="http://www.blogger.com/atom/ns#">Locked Users</category><title>Display a list of locked users</title><description>I’ve created a simple example that both shows how you can display to the user the number of failed login attempts and disable their login after the specified max number of attempts you define. I’ve also created a simplified admin screen that displays all users that currently are locked out and allows you to select and unlock them after logging in as a user with the admin role.&lt;br /&gt;
This example uses a Master Page and within the code-behind is where you keep track of the number of failed login attempts. I’ve set the &lt;i&gt;maxInvalidPasswordAttempts = 3&lt;/i&gt; within the &lt;b&gt;web.config&lt;/b&gt; as this is where the hard limit is defined.&lt;br /&gt;
&lt;pre style=&quot;background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); height: 258px; min-height: 40px; overflow: auto; padding: 5px; width: 418px;&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;add&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: blue;&quot;&gt;&quot;AspNetSqlMembershipProvider&quot;&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;connectionStringName&lt;/span&gt;=&lt;span style=&quot;color: blue;&quot;&gt;&quot;MyAspNetDB&quot;&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;applicationName&lt;/span&gt;=&lt;span style=&quot;color: blue;&quot;&gt;&quot;/&quot;&lt;/span&gt; 
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;passwordFormat&lt;/span&gt;=&lt;span style=&quot;color: blue;&quot;&gt;&quot;Hashed&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;passwordAttemptWindow&lt;/span&gt;=&lt;span style=&quot;color: blue;&quot;&gt;&quot;30&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;minRequiredNonalphanumericCharacters&lt;/span&gt;=&lt;span style=&quot;color: blue;&quot;&gt;&quot;1&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;minRequiredPasswordLength&lt;/span&gt;=&lt;span style=&quot;color: blue;&quot;&gt;&quot;7&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;maxInvalidPasswordAttempts&lt;/span&gt;=&lt;span style=&quot;color: blue;&quot;&gt;&quot;3&quot;&lt;/span&gt; 
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: blue;&quot;&gt;&quot;System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Back in the Master Page’s code-behind I’ve defined a member variable called &lt;i&gt;failedLoginCount&lt;/i&gt; that will contain the number of failed logins. In addition I’ve added a Page_Init that stores the &lt;i&gt;failedLoginCount&lt;/i&gt; in ViewState. I choose to use ViewState because this is a very small amount of information that will be stored, so it won’t inflate the ViewState tremendously.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); height: 353px; min-height: 40px; overflow: auto; padding: 5px; width: 416px;&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;public int failedLoginCount;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;protected void Page_Init(object sender, EventArgs e)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;ViewState.Add(&quot;FailedLoginCount&quot;, failedLoginCount + 1);
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;protected void Page_Load(object sender, EventArgs e)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;failedLoginCount = (int) ViewState[&quot;FailedLoginCount&quot;];
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}&lt;/pre&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Now within the Login Control’s &lt;i&gt;LoggedIn&lt;/i&gt; event the role the user is a member of is checked and if they are in the Administrator role they are redirected to the Admin page; otherwise they are assumed to be a standard user and directed to the Standard users page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); height: 399px; min-height: 40px; overflow: auto; padding: 5px; width: 417px;&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;protected void Login1_LoggedIn(object sender, EventArgs e)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;Login logIn = (Login) LoginView1.FindControl(&quot;Login1&quot;);
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;if (Roles.IsUserInRole(logIn.UserName, &quot;Administrators&quot;))
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;Response.Redirect(&quot;~/Admin/Admin.aspx&quot;);
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;else
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;Response.Redirect(&quot;~/Standard/Standard.aspx&quot;);
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}&lt;/pre&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
It is within the Login Control’s LoginError event that &lt;i&gt;failedLoginCount&lt;/i&gt; is checked to see if it equals the &lt;i&gt;maxInvalidPasswordAttempts&lt;/i&gt; value that is defined within the &lt;b&gt;web.config&lt;/b&gt; file. I get a reference to the Login control that is contained within a LoginView Control and then set the FailureText letting the user know that their account has been disabled and they need to contact the administrator once their &lt;i&gt;failedLoginCount&lt;/i&gt; equals 3. This is followed by locking the user’s account, more formally setting IsApproved to false, which indicates that the user cannot be authenticated. If the &lt;i&gt;failedLoginCount&lt;/i&gt; is not equal to 3 the failedLoginCount gets incremented and added to the ViewState key defined as well as the current count is displayed to the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); height: 719px; min-height: 40px; overflow: auto; padding: 5px; width: 416px;&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;protected void Login1_LoginError(object sender, EventArgs e)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;string emailLink = &quot;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: blue;&quot;&gt;mailto:admin@somesite.com&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&quot;;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;emailLink += &quot;Site Administrator&quot;;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;emailLink += &quot;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&quot;;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;Login logIn = (Login)LoginView1.FindControl(&quot;Login1&quot;);
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;if (failedLoginCount == 3)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;logIn.FailureText = &quot;Your account has been disabled. Please contact the site administrator: &quot; + emailLink;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;MembershipUser user = Membership.GetUser(logIn.UserName);
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;user.IsApproved = false;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;else
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;logIn.FailureText = &quot;Failed login attempt [&quot; + ViewState[&quot;FailedLoginCount&quot;].ToString() + &quot;]&quot;;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;failedLoginCount++;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;ViewState.Add(&quot;FailedLoginCount&quot;, failedLoginCount);
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}&lt;/pre&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lh6.ggpht.com/_Vypa7VcJWIU/S-N_g15vO-I/AAAAAAAAAF0/FCbOp_EUSuU/s1600-h/image%5B2%5D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;80&quot; src=&quot;http://lh6.ggpht.com/_Vypa7VcJWIU/S-N_hNrCdBI/AAAAAAAAAF4/qmafSWKc_sk/image_thumb.png?imgmax=800&quot; style=&quot;border-width: 0px; display: inline;&quot; title=&quot;image&quot; width=&quot;244&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lh5.ggpht.com/_Vypa7VcJWIU/S-N_hqbjGcI/AAAAAAAAAF8/1ngzvJ4H_YY/s1600-h/image%5B5%5D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;78&quot; src=&quot;http://lh4.ggpht.com/_Vypa7VcJWIU/S-N_h5SRgzI/AAAAAAAAAGA/NW4i2rJaLQY/image_thumb%5B1%5D.png?imgmax=800&quot; style=&quot;border-width: 0px; display: inline;&quot; title=&quot;image&quot; width=&quot;244&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lh3.ggpht.com/_Vypa7VcJWIU/S-N_iLXHVnI/AAAAAAAAAGE/_en46Rx_UMM/s1600-h/image%5B8%5D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;85&quot; src=&quot;http://lh4.ggpht.com/_Vypa7VcJWIU/S-N_iadrl1I/AAAAAAAAAGI/dfjV-Z8PVAI/image_thumb%5B2%5D.png?imgmax=800&quot; style=&quot;border-width: 0px; display: inline;&quot; title=&quot;image&quot; width=&quot;244&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now for the Admin portion I simply have a GridView Control that displays the list of users on the site whose accounts are currently locked out. A simple SQL query provides the list of users. I’ve coded this in-line, but in a real application I highly suggest that you put this into a Stored Procedure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); height: 147px; min-height: 40px; overflow: auto; padding: 5px; width: 415px;&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;a href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=SELECT&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot; style=&quot;color: blue;&quot;&gt;SELECT&lt;/a&gt; UserName, Email, LastLockoutDate, IsLockedOut 
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;a href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=FROM&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot; style=&quot;color: blue;&quot;&gt;FROM&lt;/a&gt; vw_aspnet_MembershipUsers 
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;a href=&quot;http://search.microsoft.com/default.asp?so=RECCNT&amp;amp;siteid=us%2Fdev&amp;amp;p=1&amp;amp;nq=NEW&amp;amp;qu=WHERE&amp;amp;IntlSearch=&amp;amp;boolean=PHRASE&amp;amp;ig=01&amp;amp;i=09&amp;amp;i=99&quot; style=&quot;color: blue;&quot;&gt;WHERE&lt;/a&gt; IsLockedOut = 1&lt;/pre&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
The unlocking of users takes place within the &lt;b&gt;RowUpdating&lt;/b&gt; event of the &lt;b&gt;GridView&lt;/b&gt; by calling &lt;i&gt;UnlockUser()&lt;/i&gt; on the reference to &lt;b&gt;MembershipUser&lt;/b&gt;. The following is the code for the admin section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); height: 2613px; min-height: 40px; overflow: auto; padding: 5px; width: 416px;&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, EventArgs e)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (!Page.IsPostBack)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.DataSource = GetLockedUsers();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.DataBind();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; DataTable GetLockedUsers()
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;DataTable dt = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; DataTable();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;SqlDataAdapter da = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; SqlDataAdapter();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; (SqlConnection conn = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; SqlConnection(ConfigurationManager.ConnectionStrings[&quot;&lt;span style=&quot;color: darkred;&quot;&gt;MyAspNetDB&lt;/span&gt;&quot;].ConnectionString))
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; (SqlCommand cmd = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; SqlCommand(&quot;&lt;span style=&quot;color: darkred;&quot;&gt;SELECT UserName, Email, LastLockoutDate, IsLockedOut FROM vw_aspnet_MembershipUsers WHERE IsLockedOut = 1&lt;/span&gt;&quot;, conn))
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;cmd.CommandType = CommandType.Text;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;try&lt;/span&gt;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;conn.Open();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;da.SelectCommand = cmd;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;da.Fill(dt);
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (dt.Rows == &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt; || dt.Rows.Count &amp;lt; 1)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersLabel.Text = &lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;.Empty;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; dt;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;cmd.ExecuteNonQuery();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;catch&lt;/span&gt; (SqlException sqlEx)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.Rows[0].Cells[0].Text = sqlEx.ToString();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; dt;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; LockedUsersGridView_SelectedIndexChanging(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, GridViewSelectEventArgs e)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.PageIndex = e.NewSelectedIndex;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.DataSource = GetLockedUsers();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.DataBind();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; LockedUsersGridView_RowEditing(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, GridViewEditEventArgs e)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.EditIndex = e.NewEditIndex;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.DataSource = GetLockedUsers();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.DataBind();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; LockedUsersGridView_RowCancelingEdit(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, GridViewCancelEditEventArgs e)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.EditIndex = -1;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.DataSource = GetLockedUsers();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.DataBind();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; LockedUsersGridView_RowUpdating(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, GridViewUpdateEventArgs e)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;TextBox userName = LockedUsersGridView.Rows[e.RowIndex].FindControl(&quot;&lt;span style=&quot;color: darkred;&quot;&gt;UserNameTextBox&lt;/span&gt;&quot;) &lt;span style=&quot;color: blue;&quot;&gt;as&lt;/span&gt; TextBox;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (userName != &lt;span style=&quot;color: blue;&quot;&gt;null&lt;/span&gt;)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;MembershipUser user = Membership.GetUser(userName.Text.Trim());
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;user.UnlockUser();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;Membership.UpdateUser(user);
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.EditIndex = -1;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.DataSource = GetLockedUsers();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.DataBind();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; LockedUsersGridView_PageIndexChanging(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, GridViewPageEventArgs e)
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;{
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.PageIndex = e.NewPageIndex;
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.DataSource = GetLockedUsers();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;LockedUsersGridView.DataBind();
&lt;/pre&gt;
&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 11px; margin: 0em; width: 100%;&quot;&gt;}&lt;/pre&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Hopefully you’ll find this useful as a basis for creating a more advanced admin screen for user management.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lh6.ggpht.com/_Vypa7VcJWIU/S-N_inSA--I/AAAAAAAAAGM/PD0Pp5A-QM8/s1600-h/image%5B11%5D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;66&quot; src=&quot;http://lh6.ggpht.com/_Vypa7VcJWIU/S-N_i-jzrgI/AAAAAAAAAGQ/T6lj2x1vT5M/image_thumb%5B3%5D.png?imgmax=800&quot; style=&quot;border-width: 0px; display: inline;&quot; title=&quot;image&quot; width=&quot;244&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lh6.ggpht.com/_Vypa7VcJWIU/S-N_jPROW1I/AAAAAAAAAGU/PvtYDybVmbI/s1600-h/image%5B14%5D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;101&quot; src=&quot;http://lh3.ggpht.com/_Vypa7VcJWIU/S-N_jpldm4I/AAAAAAAAAGY/7wk2ZlfeKrs/image_thumb%5B4%5D.png?imgmax=800&quot; style=&quot;border-width: 0px; display: inline;&quot; title=&quot;image&quot; width=&quot;244&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lh3.ggpht.com/_Vypa7VcJWIU/S-N_j2iE6MI/AAAAAAAAAGc/ZiN5-g7qMak/s1600-h/image%5B17%5D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;97&quot; src=&quot;http://lh4.ggpht.com/_Vypa7VcJWIU/S-N_kORQ7RI/AAAAAAAAAGg/QkIF2KNRNfQ/image_thumb%5B5%5D.png?imgmax=800&quot; style=&quot;border-width: 0px; display: inline;&quot; title=&quot;image&quot; width=&quot;244&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lh5.ggpht.com/_Vypa7VcJWIU/S-N_kb_wR6I/AAAAAAAAAGk/Ectx3_DgFbU/s1600-h/image%5B20%5D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;94&quot; src=&quot;http://lh3.ggpht.com/_Vypa7VcJWIU/S-N_lAZPJ3I/AAAAAAAAAGo/1OGPPFUy4IE/image_thumb%5B6%5D.png?imgmax=800&quot; style=&quot;border-width: 0px; display: inline;&quot; title=&quot;image&quot; width=&quot;244&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lh5.ggpht.com/_Vypa7VcJWIU/S-N_leVoJ5I/AAAAAAAAAGs/y5fXUfUFNqU/s1600-h/image%5B23%5D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;68&quot; src=&quot;http://lh4.ggpht.com/_Vypa7VcJWIU/S-N_lvuySzI/AAAAAAAAAGw/Oc-jkX6OSKQ/image_thumb%5B7%5D.png?imgmax=800&quot; style=&quot;border-width: 0px; display: inline;&quot; title=&quot;image&quot; width=&quot;244&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://lh3.ggpht.com/_Vypa7VcJWIU/S-N_mDM_TEI/AAAAAAAAAG0/hPfJ-_elv8o/s1600-h/image%5B26%5D.png&quot;&gt;&lt;img alt=&quot;image&quot; border=&quot;0&quot; height=&quot;102&quot; src=&quot;http://lh6.ggpht.com/_Vypa7VcJWIU/S-N_mYPVm_I/AAAAAAAAAG4/DHO3FXoczKE/image_thumb%5B8%5D.png?imgmax=800&quot; style=&quot;border-width: 0px; display: inline;&quot; title=&quot;image&quot; width=&quot;244&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://sites.google.com/site/dotnetsnippets/Web-Controls/DisplayLockedUsers.zip?attredirects=0&amp;amp;d=1&quot;&gt;DisplayLockedUsers.zip&lt;/a&gt;</description><link>http://lspence.blogspot.com/2010/05/display-list-of-locked-users.html</link><author>noreply@blogger.com (Lance Spence)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/_Vypa7VcJWIU/S-N_hNrCdBI/AAAAAAAAAF4/qmafSWKc_sk/s72-c/image_thumb.png?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-4555194366391963286</guid><pubDate>Tue, 22 Dec 2009 02:11:00 +0000</pubDate><atom:updated>2009-12-31T13:52:08.335-05:00</atom:updated><title>Optimized Cable Experience</title><description>&lt;p&gt;I just thought I’d take a moment and share the experience I had with Optimized Cable Company. I was searching for a set of HDMI-DVI and DVI-DVI cables for two monitors and decided to try the products of Optimized Cable Company. I found their selection of cables to be of high quality and their prices to be competitive. What prompted me; however, to write about this was the excellent customer service they provided. So often we are quick to post and talk about our bad experiences and rarely do we share the positive experiences we have with companies. &lt;/p&gt;  &lt;p&gt;The positive experience I had with Optimized Cable Company is one of those great experiences you rarely hear about. When I ordered my set of cables, which were delivered very quickly (I might add), I realized I had not paid close enough attention to the connectors. One of my monitors had an HDMI connector, while the other had DVI; however, both of my video cards had DVI connectors. When I realized my ordering error I promptly called them and explained my mistake and they said to just send them back the incorrect cable and they would promptly send me the correct cable, which was slightly more expensive than the one I originally ordered. They did an even exchange and I received the cable I intended to purchase at no additional cost to me or hassle.&lt;/p&gt;  &lt;p&gt;Based on the quality of the cables I received, prompt delivery, and the ease of doing business with them. I will direct my future needs for cables to them and highly recommend them for all of your cable needs.&lt;/p&gt;  &lt;p&gt;Thank you Optimized Cable Company!&lt;/p&gt;  &lt;p&gt;Optimized Cable Company&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;http://www.optimication-world.com/&quot;&gt;http://www.optimization-world.com/&lt;br /&gt;&lt;/a&gt;&lt;/p&gt;</description><link>http://lspence.blogspot.com/2009/12/optimized-cable-experience.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-4985873587462323942</guid><pubDate>Fri, 07 Aug 2009 03:04:00 +0000</pubDate><atom:updated>2009-08-06T23:09:25.608-04:00</atom:updated><title>Linux and USB Hard Drive “fsck died with exit status 8”</title><description>&lt;p&gt;I decided to setup an old AMD 1.7 GHz system I had as a BackupPC server to back up a few machines I have and experienced an issue with a USB 2.0 Hard Drive. I thought I’d share my situation in case someone else runs into a similar situation.&lt;/p&gt;  &lt;p&gt;My BackupPC server has 2 internal IDE hard drives and an external USB 2.0 750 GB SATA hard drive, which is used to store the backups. After I had completed the installation of Ubuntu 9.04 Server edition and rebooted I received the following error during the file system checks.&lt;/p&gt;  &lt;h5&gt;&lt;font face=&quot;Arial&quot;&gt;Failed to open the device &#39;UUID=2b1da3c5-d190-47c9-8f39-760100368e2c&#39; : No Such file or directory&lt;/font&gt;&lt;/h5&gt;  &lt;h5&gt;&lt;font face=&quot;Arial&quot;&gt;fsck died with exit status 8&lt;/font&gt;&lt;/h5&gt;  &lt;h5&gt;&lt;font face=&quot;Arial&quot;&gt;&amp;#160;&amp;#160;&amp;#160; ...fail!&lt;/font&gt;&lt;/h5&gt;  &lt;h5&gt;&lt;font face=&quot;Arial&quot;&gt;* File system check failed. &lt;/font&gt;&lt;/h5&gt;  &lt;h5&gt;&lt;font face=&quot;Arial&quot;&gt;A log is being saved in /var/log/fsck/checkfs if that location is writable.&lt;/font&gt;&lt;/h5&gt;  &lt;h5&gt;&lt;font face=&quot;Arial&quot;&gt;Please repair the file system manually. &lt;/font&gt;&lt;/h5&gt;  &lt;h5&gt;&lt;font face=&quot;Arial&quot;&gt;*&amp;#160; A maintenance shell will now be started.&lt;/font&gt;&lt;/h5&gt;  &lt;h5&gt;&lt;font face=&quot;Arial&quot;&gt;CONTROL-D will terminate this shell and resume system boot.&lt;/font&gt;&lt;/h5&gt;  &lt;p&gt;After researching the error and trying various suggestions I realized that all I needed to do was exclude the external USB hard drive from having it’s file system checked during startup. I solved the issue by editing /etc/fstab and setting the entry for the USB hard drive’s PASS column to a 0, which essentially tells fsck to not check the file system. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;/p&gt;  &lt;h5&gt;&lt;font size=&quot;2&quot; face=&quot;Arial&quot;&gt;# /var was on /dev/sdc1 during installation&lt;/font&gt;&lt;/h5&gt;  &lt;h5&gt;&lt;font size=&quot;2&quot; face=&quot;Arial&quot;&gt;UUID=2b1da3c5-d190-47c9-8f39-760100368e2c /var&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; reiserfs relatime&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 0&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2&lt;/font&gt;&lt;/h5&gt;  &lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt;&lt;/p&gt;  &lt;h6&gt;&lt;font size=&quot;2&quot; face=&quot;Arial&quot;&gt;&lt;/font&gt;&lt;/h6&gt;  &lt;h5&gt;&lt;font size=&quot;2&quot; face=&quot;Arial&quot;&gt;# /var was on /dev/sdc1 during installation&lt;/font&gt;&lt;/h5&gt;  &lt;h5&gt;&lt;font size=&quot;2&quot; face=&quot;Arial&quot;&gt;UUID=2b1da3c5-d190-47c9-8f39-760100368e2c /var&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; reiserfs relatime&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 0&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 0&lt;/font&gt;&lt;/h5&gt;  &lt;p&gt;After this little modification to /etc/fstab, I rebooted and once the system came up, I manually mounted the device for my USB 2.0 hard drive as such and all was good.&lt;/p&gt;  &lt;h5&gt;&lt;font size=&quot;2&quot; face=&quot;Arial&quot;&gt;sudo mount /dev/sdc1&lt;/font&gt;&lt;/h5&gt;  &lt;p&gt;By the way BackupPC setup and configuration can be a little challenging, so I recommend aside from the official documentation the following link, which I’ve found to still be relevant for both Debian and Ubuntu.&lt;/p&gt;  &lt;p&gt;&lt;a title=&quot;http://www.howtoforge.com/linux_backuppc&quot; href=&quot;http://www.howtoforge.com/linux_backuppc&quot;&gt;http://www.howtoforge.com/linux_backuppc&lt;/a&gt;&lt;/p&gt;  </description><link>http://lspence.blogspot.com/2009/08/linux-and-usb-hard-drive-fsck-died-with.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-573680699447921041</guid><pubDate>Wed, 26 Nov 2008 14:21:00 +0000</pubDate><atom:updated>2010-05-07T23:05:03.233-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Microsoft Charting Control</category><title>New Microsoft Charting Control</title><description>&lt;span style=&quot;font-size: 85%;&quot;&gt;Microsoft recently released a much needed charting control for both Winforms and ASP.NET. Looking at the WebSamples Project the controls look very impressive and offer many charting types both in 2D and 3D such as Bar and Column Charts, Line Charts, Area Charts, Pie and Doughnut Charts, Point Charts, Range Charts, Circular Charts, Accumulation Charts, Data Distribution Charts, Price Change Financial Charts, Advanced Financial Charts, and Combinational Charts.&lt;br /&gt;
&lt;br /&gt;
Congratulations to Microsoft for finally offering a nice set of free charting controls. You can read more and get the download links from ScottGu&#39;s Blog link below.&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;a border=&quot;0&quot; href=&quot;&quot;&gt;&lt;span class=&quot;b24-booktitle&quot; id=&quot;b24-booktitle-26463&quot;&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href=&quot;http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx&quot;&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;</description><link>http://lspence.blogspot.com/2008/11/new-microsoft-charting-control.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-7563015129994221123</guid><pubDate>Mon, 17 Nov 2008 19:18:00 +0000</pubDate><atom:updated>2010-05-07T23:03:52.634-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Email</category><category domain="http://www.blogger.com/atom/ns#">Embedding Image</category><title>Embedding an image within an email</title><description>&lt;span style=&quot;font-size: 85%;&quot;&gt;Not to long ago I remember seeing a post on the ASP.NET forums where someone had a need to embed an image within an email that they generated from their web application. I decided to put together a short sample that does just that. Using the code I&#39;ll provide you can embed an image within your email, so that when you open the email up with in Yahoo&#39;s Webmail client  or any other Web based email client the image will be displayed in-line as opposed to being sent as an attachment. This code is just a sample and can be further improved, but it should get you started. I have verified that the image is embedded in-line when sent to GMail, Yahoo, and Hotmail.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;Here is the Sample&#39;s HTML.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;NOTE:  Make sure to add the attribute ValidateRequest=&quot;false&quot; to the Page Directive&lt;/span&gt;. This is so that you can embeded HTML into your email message. Also please beware that this will also allow for XSS via Javascript.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;    &amp;lt;div&amp;gt;
&amp;lt;div&amp;gt;
&amp;lt;asp:Label ID=&quot;ToLabel&quot; runat=&quot;server&quot; Style=&quot;padding-left: 1.8em&quot; Text=&quot;To:&quot; /&amp;gt;
&amp;lt;asp:TextBox ID=&quot;ToTextBox&quot; runat=&quot;server&quot; /&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div&amp;gt;
&amp;lt;asp:Label ID=&quot;FromLabel&quot; runat=&quot;server&quot; Style=&quot;padding-left: .8em&quot; Text=&quot;From:&quot; /&amp;gt;
&amp;lt;asp:TextBox ID=&quot;FromTextBox&quot; runat=&quot;server&quot; /&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div&amp;gt;
&amp;lt;asp:Label ID=&quot;SubjectLabel&quot; runat=&quot;server&quot; Text=&quot;Subject:&quot; /&amp;gt;
&amp;lt;asp:TextBox ID=&quot;SubjectTextBox&quot; runat=&quot;server&quot; /&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div&amp;gt;
&amp;lt;asp:Label ID=&quot;BodyLabel&quot; runat=&quot;server&quot; Style=&quot;padding-left: .8em&quot; Text=&quot;Body:&quot; /&amp;gt;
&amp;lt;asp:TextBox ID=&quot;BodyTextBox&quot; runat=&quot;server&quot; TextMode=&quot;MultiLine&quot; Width=&quot;250px&quot; Height=&quot;100px&quot; /&amp;gt;
&amp;lt;asp:Image ID=&quot;SelectedImage&quot; runat=&quot;server&quot; style=&quot;left: 200px; top: 200px;&quot;
Height=&quot;100px&quot; Width=&quot;100px&quot; /&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div&amp;gt;
&amp;lt;br /&amp;gt;
&amp;lt;asp:Button ID=&quot;SendButton&quot; runat=&quot;server&quot; Style=&quot;margin-left: 10em&quot;
Text=&quot;Send&quot; onclick=&quot;SendButton_Click&quot; /&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div&amp;gt;
&amp;lt;br /&amp;gt;
&amp;lt;div style=&quot;width: 550px; overflow: scroll; height: 100px;&quot;&amp;gt;
&amp;lt;asp:DataList ID=&quot;ImageDataList&quot; runat=&quot;server&quot; BackColor=&quot;White&quot;
BorderColor=&quot;#CCCCCC&quot; BorderStyle=&quot;None&quot; BorderWidth=&quot;1px&quot; CellPadding=&quot;4&quot;
ForeColor=&quot;Black&quot; GridLines=&quot;Horizontal&quot; HorizontalAlign=&quot;Center&quot;
RepeatDirection=&quot;Horizontal&quot; Height=&quot;90px&quot; Width=&quot;500px&quot;
onitemcommand=&quot;ImageDataList_ItemCommand&quot;&amp;gt;
&amp;lt;FooterStyle BackColor=&quot;#CCCC99&quot; ForeColor=&quot;Black&quot; /&amp;gt;
&amp;lt;SelectedItemStyle BackColor=&quot;#CC3333&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; /&amp;gt;
&amp;lt;HeaderStyle BackColor=&quot;#333333&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; /&amp;gt;
&amp;lt;ItemTemplate&amp;gt;
&amp;lt;asp:ImageButton ID=&quot;ProfileImageButton&quot; runat=&quot;server&quot;
ImageUrl=&#39;&amp;lt;%# Eval(&quot;FullName&quot;) %&amp;gt;&#39; /&amp;gt;
&amp;lt;/ItemTemplate&amp;gt;
&amp;lt;/asp:DataList&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;br /&amp;gt;
&amp;lt;asp:Label ID=&quot;StatusLabel&quot; runat=&quot;server&quot; /&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;Here&#39;s the Sample&#39;s Code make sure to include the following namespaces.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;using System.IO;
using System.Net;
using System.Net.Mail;

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
StatusLabel.Visible = false;
DirectoryInfo dir = new DirectoryInfo(Server.MapPath(&quot;~/Images&quot;));
int total = dir.GetFiles(&quot;*.jpg&quot;).Length;
if (total &amp;gt; 3)
{
ImageDataList.RepeatColumns = total + 1;
}

ImageDataList.DataSource = dir.GetFiles(&quot;*.jpg&quot;);
ImageDataList.DataBind();
}
}

protected void SendButton_Click(object sender, EventArgs e)
{
NetworkCredential loginInfo = new NetworkCredential(&quot;username@gmail.com&quot;, &quot;yourGMailPassword&quot;);
MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress(Server.HtmlEncode(ToTextBox.Text)));
msg.From = new MailAddress(Server.HtmlEncode(FromTextBox.Text));
msg.Subject = Server.HtmlEncode(SubjectTextBox.Text);
msg.Body = BodyTextBox.Text;

AlternateView body = AlternateView.CreateAlternateViewFromString(msg.Subject + &quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&quot; + msg.Body + &quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;img src=cid:profile /&amp;gt;&quot;, null, &quot;text/html&quot;);
try
{
LinkedResource profileImg = new LinkedResource(SelectedImage.ImageUrl);
profileImg.ContentId = &quot;profile&quot;;
body.LinkedResources.Add(profileImg);
}
catch (ArgumentException argEx)
{
StatusLabel.Visible = true;
StatusLabel.Style.Add(&quot;color&quot;, &quot;#CC0033&quot;);
StatusLabel.Text = &quot;An image was not selected.&quot;;
return;
}
catch (Exception ex)
{
StatusLabel.Visible = true;
StatusLabel.Style.Add(&quot;color&quot;, &quot;#CC0033&quot;);
StatusLabel.Text = &quot;The following error occurred: &quot; + &quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&quot; + ex.Message;
}

msg.AlternateViews.Add(body);
msg.IsBodyHtml = true;

SmtpClient client = new SmtpClient(&quot;smtp.gmail.com&quot;, 587);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInfo;

try
{
client.Send(msg);
}
catch (SmtpException smtpEx)
{
StatusLabel.Visible = true;
StatusLabel.Style.Add(&quot;color&quot;, &quot;#CC0033&quot;);
StatusLabel.Text = &quot;The following error occurred: &quot; + &quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&quot; + smtpEx.Message;
}
catch (Exception ex)
{
StatusLabel.Visible = true;
StatusLabel.Style.Add(&quot;color&quot;, &quot;#CC0033&quot;);
StatusLabel.Text = &quot;The following error occurred: &quot; + &quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&quot; + ex.Message;
}

StatusLabel.Visible = true;
StatusLabel.Style.Add(&quot;color&quot;, &quot;#009966&quot;);
StatusLabel.Text = &quot;Email sent successfully.&quot;;
}

protected void ImageDataList_ItemCommand(object source, DataListCommandEventArgs e)
{
SelectedImage.ImageUrl = ((ImageButton)e.CommandSource).ImageUrl;
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA1fl3fOZsK90Bu_eeRpAvPFzeof__z3gjNgsHK-nw9lPCdhml9_y1NCwivAOcX3G2fAiG0wcx3g_XM39quxrOZjNrCDeuFY6jFPGC73IPcgMxW2Ae3AmsLzq4tFKAYeWHWSDsljZnH3w/s1600-h/EmailWithImage.png&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5269742093092870530&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA1fl3fOZsK90Bu_eeRpAvPFzeof__z3gjNgsHK-nw9lPCdhml9_y1NCwivAOcX3G2fAiG0wcx3g_XM39quxrOZjNrCDeuFY6jFPGC73IPcgMxW2Ae3AmsLzq4tFKAYeWHWSDsljZnH3w/s320/EmailWithImage.png&quot; style=&quot;cursor: pointer; height: 210px; width: 320px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrEzLe4DuykZeg_PtBHWMri4VdXQjWcCcWvDZQvEqlWMq6rEr__M2Fp4BpKTACiB3LwdH9S9f0Ov1csjKnN5e7RpKnoldSNFor04nliQCfZay-Xt2KWySUFaydHGdnkmzkPlQ4Lcf1968/s1600-h/EmailWithImage2.png&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5269742231699519330&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrEzLe4DuykZeg_PtBHWMri4VdXQjWcCcWvDZQvEqlWMq6rEr__M2Fp4BpKTACiB3LwdH9S9f0Ov1csjKnN5e7RpKnoldSNFor04nliQCfZay-Xt2KWySUFaydHGdnkmzkPlQ4Lcf1968/s320/EmailWithImage2.png&quot; style=&quot;cursor: pointer; height: 228px; width: 320px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihAsibdDcg4jVyvKs4vnC2_CpmOl6w0mx6GE2hrm7C-YmfgXhgtgE4sfn2VnDoW3WbKyBrSlCVOdqV1TdVPgHQNQYZl_TCb6YzzEHEiFjm7x9nMBJ8ea8FTzgE8sYEdQtOJWsXEBx14Qk/s1600-h/EmailWithImage3.png&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5272228981881077730&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihAsibdDcg4jVyvKs4vnC2_CpmOl6w0mx6GE2hrm7C-YmfgXhgtgE4sfn2VnDoW3WbKyBrSlCVOdqV1TdVPgHQNQYZl_TCb6YzzEHEiFjm7x9nMBJ8ea8FTzgE8sYEdQtOJWsXEBx14Qk/s320/EmailWithImage3.png&quot; style=&quot;cursor: pointer; height: 263px; width: 320px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXuEcODzxyr7ebUrzbnUVipCTUZL3SA-WxD4IQRQfAKGo4wBtKj1U4qeTVZRNPchH1rcsuXI-ec5cVFeetCI881V01mAtJX1PoNknbj6X__HGw6VL_73EgNtTkb1bko7MmTCeW3osbnY4/s1600-h/EmailWithImage4.png&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5272229430249052482&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXuEcODzxyr7ebUrzbnUVipCTUZL3SA-WxD4IQRQfAKGo4wBtKj1U4qeTVZRNPchH1rcsuXI-ec5cVFeetCI881V01mAtJX1PoNknbj6X__HGw6VL_73EgNtTkb1bko7MmTCeW3osbnY4/s320/EmailWithImage4.png&quot; style=&quot;cursor: pointer; height: 223px; width: 320px;&quot; /&gt;&lt;/a&gt;</description><link>http://lspence.blogspot.com/2008/11/embedding-image-within-email.html</link><author>noreply@blogger.com (Lance Spence)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA1fl3fOZsK90Bu_eeRpAvPFzeof__z3gjNgsHK-nw9lPCdhml9_y1NCwivAOcX3G2fAiG0wcx3g_XM39quxrOZjNrCDeuFY6jFPGC73IPcgMxW2Ae3AmsLzq4tFKAYeWHWSDsljZnH3w/s72-c/EmailWithImage.png" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-3412554410055395524</guid><pubDate>Thu, 30 Oct 2008 19:10:00 +0000</pubDate><atom:updated>2010-05-07T23:03:21.292-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">AJAX</category><category domain="http://www.blogger.com/atom/ns#">Control Toolkit</category><title>Recovering lost AJAX Control Toolkit Controls in VS2008</title><description>&lt;span style=&quot;font-size: 85%;&quot;&gt;When using Visual Studio 2008 and you have the AJAX Control Toolkit installed you might have experienced that your AJAX Controls disappear from the Toolbox. If you right-click on a Tab in the Toolbox and select Show All,  you&#39;ll see that the controls are still there; however, they are all greyed out. This happens when using Visual Studio 2008 and targeting .Net Framework 2.0 in both Web Application Projects and Web Sites. You can resolve this by doing the following for Web Applications and Web Sites.&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;Web Solutions:&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;1. Click Project.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;2. Select &lt;i&gt;ProjectName&lt;/i&gt; Properties.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;3.  Under Target Framework, change it from .NET Framework 2.0 to .NET Framework 3.5.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;4. Click Save.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;Web Sites:&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;1. Click Website.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;2. Select Start Options.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;3. Select Build and under Target Framework, change it from .NET Framework 2.0 to .NET Framework 3.5.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;4. Click OK. &lt;/span&gt;</description><link>http://lspence.blogspot.com/2008/10/recovering-lost-ajax-control-toolkit.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-3991622473103157430</guid><pubDate>Thu, 10 Jul 2008 16:14:00 +0000</pubDate><atom:updated>2010-05-07T23:03:00.050-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><category domain="http://www.blogger.com/atom/ns#">File Upload</category><title>ASP.NET FileUpload Control Issue</title><description>&lt;span style=&quot;font-size: 85%;&quot;&gt;I had an issue with file paths when using the ASP.NET 2.0 FileUpload Control that was giving me a fit for a little while. After some searching on Google, I gained a little more insight and discovered that if you use PostedFile that IE saves the file&#39;s complete path, which includes the path location of where the file was uploaded from in addition to the location you are saving files to on the server. If you use PostedFile with Firefox, Opera, or Safari, the file&#39;s complete path is trimmed to just the filename and the location you are saving files to on the server.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;Instead of using for example:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;string path = &quot;/uploads/ + FileUpload1.PostedFile;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;Use this:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;string path = &quot;/uploads/ + FileUpload1.Filename;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;This will assign only the file&#39;s filename to the variable path, so if you are saving the paths of files in a database and upload files using IE the path will not also contain the location of the file on the client&#39;s machine as well as the location you are saving your files to on the server.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;I had never used the FileUpload Control before until recently, so hopefully this will help anyone out using it for the first time.&lt;/span&gt;</description><link>http://lspence.blogspot.com/2008/07/aspnet-fileupload-control-issue.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-1721205330598189722</guid><pubDate>Thu, 17 Apr 2008 01:58:00 +0000</pubDate><atom:updated>2010-05-07T23:02:21.503-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Activiation Email</category><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><title>Sending an Activation Email with ASP.NET 2.0 Expanded</title><description>&lt;span style=&quot;font-size: 85%;&quot;&gt;I had a request to show an example that would build on my original &quot;Sending an Activation Email with ASP.NET 2.0&quot; to provide a user with a link to log them in. What follows shows how you can place a link on the final Account   Details page that when clicked will take the user to a Login page with their username already pre-filled for them.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Activate.aspx&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;&amp;lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot;  CodeFile=&quot;Activate.aspx.cs&quot; Inherits=&quot;Activate&quot; %&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;
&amp;lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &amp;gt;
&amp;lt;head runat=&quot;server&quot;&amp;gt;
&amp;lt;title&amp;gt;Activation Page&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;form id=&quot;form1&quot; runat=&quot;server&quot;&amp;gt;
&amp;lt;br /&amp;gt;
&amp;lt;asp:Table ID=&quot;Table1&quot; runat=&quot;server&quot; CellPadding=&quot;1&quot; CellSpacing=&quot;0&quot; GridLines=&quot;Both&quot; BorderStyle=&quot;Groove&quot; BackColor=&quot;BlanchedAlmond&quot; Caption=&quot;Account Information&quot;&amp;gt;
&amp;lt;asp:TableRow&amp;gt;
&amp;lt;asp:TableCell HorizontalAlign=&quot;Right&quot; runat=&quot;server&quot;&amp;gt;Username:&amp;lt;/asp:TableCell&amp;gt;
&amp;lt;asp:TableCell HorizontalAlign=&quot;Left&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;asp:Label ID=&quot;ActiviationNameLabel&quot; runat=&quot;server&quot; Style=&quot;position: static&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;/asp:TableCell&amp;gt;
&amp;lt;/asp:TableRow&amp;gt;
&amp;lt;asp:TableRow&amp;gt;
&amp;lt;asp:TableCell HorizontalAlign=&quot;Right&quot; runat=&quot;server&quot;&amp;gt;Account Created:&amp;lt;/asp:TableCell&amp;gt;
&amp;lt;asp:TableCell HorizontalAlign=&quot;Left&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;asp:Label ID=&quot;ActivationCreationDateLabel&quot; runat=&quot;server&quot; Style=&quot;position: static&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;/asp:TableCell&amp;gt;
&amp;lt;/asp:TableRow&amp;gt;
&amp;lt;asp:TableRow&amp;gt;
&amp;lt;asp:TableCell HorizontalAlign=&quot;Right&quot; runat=&quot;server&quot;&amp;gt;Account Status:&amp;lt;/asp:TableCell&amp;gt;
&amp;lt;asp:TableCell HorizontalAlign=&quot;Left&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;asp:Label ID=&quot;ActivationStatusLabel&quot; runat=&quot;server&quot; style=&quot;position: static&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;/asp:TableCell&amp;gt;
&amp;lt;/asp:TableRow&amp;gt;
&amp;lt;asp:TableRow&amp;gt;
&amp;lt;asp:TableCell HorizontalAlign=&quot;Right&quot; runat=&quot;server&quot;&amp;gt;
&amp;lt;br /&amp;gt;
&amp;lt;asp:HyperLink ID=&quot;HyperLink1&quot; runat=&quot;server&quot; NavigateUrl=&quot;~/Login.aspx&quot;&amp;gt;Goto Login Page&amp;lt;/asp:HyperLink&amp;gt;
&amp;lt;/asp:TableCell&amp;gt;
&amp;lt;/asp:TableRow&amp;gt;
&amp;lt;/asp:Table&amp;gt;
&amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;b&gt;Activate.aspx.cs&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;This updated code stores the username in a Session variable, so that it can be used to populate the Username field of the Login Control.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string userID = Request.QueryString[&quot;ID&quot;];
Guid gd = new Guid(userID);
MembershipUser user = Membership.GetUser(gd);
user.IsApproved = true;
Roles.AddUserToRole(user.ToString(), &quot;Power Users&quot;);
Membership.UpdateUser(user);
ActiviationNameLabel.Text = user.UserName;
ActivationCreationDateLabel.Text = user.CreationDate.ToShortDateString();
if (user.IsApproved)
{
ActivationStatusLabel.Text = &quot;Active&quot;;
}
else
{
ActivationStatusLabel.Text = &quot;Pending&quot;;
}

Session[&quot;UserName&quot;] = user.UserName;
}
}
&lt;/code&gt;&lt;/pre&gt;&lt;b&gt;Login.aspx&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;&amp;lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;Login.aspx.cs&quot; Inherits=&quot;Login&quot; %&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;
&amp;lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &amp;gt;
&amp;lt;head runat=&quot;server&quot;&amp;gt;
&amp;lt;title&amp;gt;Login Page&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;form id=&quot;form1&quot; runat=&quot;server&quot;&amp;gt;
&amp;lt;div style=&quot;text-align: center&quot;&amp;gt;
&amp;lt;asp:Login ID=&quot;Login1&quot; runat=&quot;server&quot; BackColor=&quot;#F7F6F3&quot; BorderColor=&quot;#E6E2D8&quot; BorderPadding=&quot;4&quot; BorderStyle=&quot;Solid&quot; BorderWidth=&quot;1px&quot; Font-Names=&quot;Verdana&quot; Font-Size=&quot;0.8em&quot; ForeColor=&quot;#333333&quot; DestinationPageUrl=&quot;~/Main.aspx&quot;&amp;gt;
&amp;lt;TextBoxStyle Font-Size=&quot;0.8em&quot; /&amp;gt;
&amp;lt;LoginButtonStyle BackColor=&quot;#FFFBFF&quot; BorderColor=&quot;#CCCCCC&quot; BorderStyle=&quot;Solid&quot; BorderWidth=&quot;1px&quot;
Font-Names=&quot;Verdana&quot; Font-Size=&quot;0.8em&quot; ForeColor=&quot;#284775&quot; /&amp;gt;
&amp;lt;InstructionTextStyle Font-Italic=&quot;True&quot; ForeColor=&quot;Black&quot; /&amp;gt;
&amp;lt;TitleTextStyle BackColor=&quot;#5D7B9D&quot; Font-Bold=&quot;True&quot; Font-Size=&quot;0.9em&quot; ForeColor=&quot;White&quot; /&amp;gt;
&amp;lt;/asp:Login&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;b&gt;Login.aspx.cs&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;This simple Login page retrieves the user&#39;s Username from the session and assigns it to the Login controls UserName TextBox. It first checks to see if the session variable is null or empty if it is then the Login Control&#39;s UserName TextBox is left blank.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (!(String.IsNullOrEmpty((string)Session[&quot;UserName&quot;])))
{
string username = Session[&quot;UserName&quot;].ToString();
Login1.UserName = username;
}
else
{
Login1.UserName = string.Empty;
}
}
}
&lt;/code&gt;&lt;/pre&gt;&lt;b&gt;Main.aspx&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;Upon successful login the user is redirected to a simple welcome page called Main.aspx.&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;&amp;lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;Main.aspx.cs&quot; Inherits=&quot;Main&quot; %&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;
&amp;lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &amp;gt;
&amp;lt;head runat=&quot;server&quot;&amp;gt;
&amp;lt;title&amp;gt;Main Website Page&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;form id=&quot;form1&quot; runat=&quot;server&quot;&amp;gt;
&amp;lt;div&amp;gt;
&amp;lt;asp:LoginView ID=&quot;LoginView1&quot; runat=&quot;server&quot;&amp;gt;
&amp;lt;LoggedInTemplate&amp;gt;
Welcome
&amp;lt;asp:LoginName ID=&quot;LoginName1&quot; runat=&quot;server&quot; /&amp;gt;
!&amp;lt;br /&amp;gt;
&amp;lt;br /&amp;gt;
&amp;lt;asp:LoginStatus ID=&quot;LoginStatus1&quot; runat=&quot;server&quot; LogoutAction=&quot;RedirectToLoginPage&quot;
LogoutPageUrl=&quot;~/Login.aspx&quot; /&amp;gt;
&amp;lt;/LoggedInTemplate&amp;gt;
&amp;lt;/asp:LoginView&amp;gt;
&amp;amp;nbsp;&amp;lt;/div&amp;gt;
&amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZLkuabMI_w0ieUR2K1Vmmnd9Iyi35U8MomEclQNhlmFQk6od0av0dMubRLZdcB3IXd8NvG0dGs6pBIYzj2Xw_3u5VwUk4FFptMJn3pI_p0srWUFSEgd8W81KT3cLjxjPajy9CeiDvcqk/s1600-h/sshot-1.jpg&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5190039537126456466&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZLkuabMI_w0ieUR2K1Vmmnd9Iyi35U8MomEclQNhlmFQk6od0av0dMubRLZdcB3IXd8NvG0dGs6pBIYzj2Xw_3u5VwUk4FFptMJn3pI_p0srWUFSEgd8W81KT3cLjxjPajy9CeiDvcqk/s320/sshot-1.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKtmVgkCOrDfr1ti5uiwp0BFTB0n9WNKH-lrePA7Cif6Hcqr6kIjs8ouDxe6dwwZ0QSgTzmz8B5TV8v_2lYxedIi0lp5DbBiVpuJtGyjtfjeVm7xAXI5yuEjXZV0ppSwTojM8wiWNAj1g/s1600-h/sshot-2.jpg&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5190039885018807458&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKtmVgkCOrDfr1ti5uiwp0BFTB0n9WNKH-lrePA7Cif6Hcqr6kIjs8ouDxe6dwwZ0QSgTzmz8B5TV8v_2lYxedIi0lp5DbBiVpuJtGyjtfjeVm7xAXI5yuEjXZV0ppSwTojM8wiWNAj1g/s320/sshot-2.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihTVAn5kB3gCT6ZU0DWrFEqhDDfGQkph5MxYFwP3KyJnF7Dz7YG6D6kAav6Edz3ACUpMV-zFLocS7HdH6eKvCA59w0rMOqScC6O6haJ1nTEzf4vXh_ct41dU17wJNMGXcsxFsVXXu_lkA/s1600-h/sshot-3.jpg&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5190040202846387378&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihTVAn5kB3gCT6ZU0DWrFEqhDDfGQkph5MxYFwP3KyJnF7Dz7YG6D6kAav6Edz3ACUpMV-zFLocS7HdH6eKvCA59w0rMOqScC6O6haJ1nTEzf4vXh_ct41dU17wJNMGXcsxFsVXXu_lkA/s320/sshot-3.jpg&quot; /&gt;&lt;/a&gt;</description><link>http://lspence.blogspot.com/2008/04/sending-activation-email-with-aspnet-20.html</link><author>noreply@blogger.com (Lance Spence)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZLkuabMI_w0ieUR2K1Vmmnd9Iyi35U8MomEclQNhlmFQk6od0av0dMubRLZdcB3IXd8NvG0dGs6pBIYzj2Xw_3u5VwUk4FFptMJn3pI_p0srWUFSEgd8W81KT3cLjxjPajy9CeiDvcqk/s72-c/sshot-1.jpg" height="72" width="72"/><thr:total>8</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-2555154855936545069</guid><pubDate>Tue, 26 Feb 2008 15:37:00 +0000</pubDate><atom:updated>2010-05-07T23:02:35.933-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Activiation Email</category><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><title>Sending an Activation Email with ASP.NET 2.0</title><description>&lt;span style=&quot;font-size: 85%;&quot;&gt;Many sites as you&#39;ve seen send out an email that contains a link to activate your account after you&#39;ve filled out all requested information. This is primarily seen on Web Forum sites and other sites that require a membership. I&#39;m going to show a quick example of how to do this using ASP.NET and sending the email via Gmail or some other SMTP server such as your hosting company&#39;s smtp server.&lt;/span&gt; &lt;span style=&quot;font-size: 85%;&quot;&gt;It is assumed that you have already configured your &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_0&quot;&gt;ASPNETDB&lt;/span&gt; with Membership and Roles. This is just a basic email activation you can expand upon it and add other features you might want.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;Start by dropping a standard &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_1&quot;&gt;CreateUserWizard&lt;/span&gt; Control on a page. I&#39;ve dropped the control on a page called Default.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_2&quot;&gt;aspx&lt;/span&gt;. You can format it later with any of the available Format templates Microsoft has provided or customize it using &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_3&quot;&gt;CSS&lt;/span&gt; if you like.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;Below is the code-behind for the Default.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_4&quot;&gt;aspx&lt;/span&gt; page. This code essentially grabs the &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_5&quot;&gt;Username&lt;/span&gt;, Password, and Email address that was entered through the &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_6&quot;&gt;CreateUserWizard&lt;/span&gt; Control puts the information into a &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_7&quot;&gt;StringBuilder&lt;/span&gt; object along with a link to the Activate.&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_8&quot;&gt;aspx&lt;/span&gt; page. The &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_9&quot;&gt;UserID&lt;/span&gt; is a &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_10&quot;&gt;Guid&lt;/span&gt; value that is appended to the Activate URL as a query string.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;Using a conditional you can select to send the emails via your Hosting Companies SMTP server, a local SMTP server, or a Gmail account.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;#define Gmail
#define SMTP

using System;
using System.Data;
using System.Configuration;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{

protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
StringBuilder bodyMsg = new StringBuilder();
TextBox username = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl(&quot;UserName&quot;);
TextBox password = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl(&quot;Password&quot;);
TextBox email = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl(&quot;Email&quot;);

CreateUserWizard cuw = (CreateUserWizard)sender;
MembershipUser user = Membership.GetUser(cuw.UserName);
Guid userID = (Guid)user.ProviderUserKey;

bodyMsg.Append(&quot;Thank you for creating your account.\n\nPlease follow this link to activate: &quot;);
bodyMsg.Append(&quot;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;a href=http://yourserver/SendEmailConfirmationSample/Activate.aspx?ID=&quot; + userID.ToString() + &quot;&amp;gt;Activate Your Account&amp;lt;/a&amp;gt;&quot;);
bodyMsg.Append(&quot;&amp;lt;br /&amp;gt;&quot;);
bodyMsg.Append(&quot;&amp;lt;br /&amp;gt;&quot;);
bodyMsg.AppendFormat(&quot;UserName: {0}&quot;, username.Text);
bodyMsg.Append(&quot;&amp;lt;br /&amp;gt;&quot;);
bodyMsg.AppendFormat(&quot;Password: {0}&quot;, password.Text);
bodyMsg.Append(&quot;&amp;lt;br /&amp;gt;&quot;);
bodyMsg.AppendFormat(&quot;Registered Email: {0}&quot;, email.Text);

#if SMTP
// Sending email via local or web hosts smtp server.
NetworkCredential loginInfo = new NetworkCredential(&quot;yourusername&quot;, &quot;yourpassword&quot;);
MailMessage msg = new MailMessage();
msg.From = new MailAddress(&quot;youremailaddress&quot;);
msg.To.Add(new MailAddress(CreateUserWizard1.Email));
msg.Subject = &quot;Account Information&quot;;
msg.Body = bodyMsg.ToString();
msg.IsBodyHtml = true;

SmtpClient client = new SmtpClient(&quot;smtpserver&quot;, 25);
client.Credentials = loginInfo;
client.Send(msg);
#endif

#if Gmail
// Sending email via Gmail.
NetworkCredential loginInfo = new NetworkCredential(&quot;yourUsername@gmail.com&quot;, &quot;yourGmailPassword&quot;);
MailMessage msg = new MailMessage();
msg.From = new MailAddress(&quot;yourUsername@gmail.com&quot;);
msg.To.Add(new MailAddress(CreateUserWizard1.Email));
msg.Subject = &quot;Account Information&quot;;
msg.Body = bodyMsg.ToString();
msg.IsBodyHtml = true;

SmtpClient client = new SmtpClient(&quot;smtp.gmail.com&quot;, 587);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInfo;
client.Send(msg);
#endif

Response.Redirect(&quot;~/thankyoupage.aspx&quot;);
}
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;b&gt;Signing Up For A New Account.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA96DpUrKg2ni0cxL_Qx6qSGmLyLFIEYUaoIukOyiq2Aozs3WjQipgcaUO0ISaOl1TMNRKDqgSPtEq7I9RDKHakstJmOAtuaOwjsPopc5Rh3RvuIKsTR5zc3R-sT9D76UCSqDLnMcRvwM/s1600-h/Screen1.jpg&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5171323417675023218&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA96DpUrKg2ni0cxL_Qx6qSGmLyLFIEYUaoIukOyiq2Aozs3WjQipgcaUO0ISaOl1TMNRKDqgSPtEq7I9RDKHakstJmOAtuaOwjsPopc5Rh3RvuIKsTR5zc3R-sT9D76UCSqDLnMcRvwM/s320/Screen1.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;b&gt;The Confirmation email that is sent.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIzrAwhkMrdDbGANF5yLnZpWABrs20MgFC-uUxNx1wPgiKNWfYNgQB7cXvzbrCDKdBTunrMDQ4Bs_RhPehsE1JaEw83nLAqFMK5CIQYgVfdO-gEFQzYCy538V0EJ5OxV09v5KAJmnyqJE/s1600-h/Screen2.jpg&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5171324104869790594&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIzrAwhkMrdDbGANF5yLnZpWABrs20MgFC-uUxNx1wPgiKNWfYNgQB7cXvzbrCDKdBTunrMDQ4Bs_RhPehsE1JaEw83nLAqFMK5CIQYgVfdO-gEFQzYCy538V0EJ5OxV09v5KAJmnyqJE/s320/Screen2.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;b&gt;Here you can see the email that I received in my Gmail Inbox.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqWY-mW1op2vCp9HKEcmRyjuW7BV0AbgOgRkDz-ox1TgxAjPJ8h6BgQtYICdjhQkDwVxlaOB0IIgQI6J2MlM-WVP_Ga5mKAow1Y3RJbWAa2fVOdhskS8NAcYVTfgM1nXdRjMQ0CkK05YA/s1600-h/Screen3.jpg&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5171325135661941650&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqWY-mW1op2vCp9HKEcmRyjuW7BV0AbgOgRkDz-ox1TgxAjPJ8h6BgQtYICdjhQkDwVxlaOB0IIgQI6J2MlM-WVP_Ga5mKAow1Y3RJbWAa2fVOdhskS8NAcYVTfgM1nXdRjMQ0CkK05YA/s320/Screen3.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;b&gt;Here are the contents of the email that was sent.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxOZp_0oLjfeh2yNXJuPO_rzvCRucGfXgqUOGpIq9doOlsOYdCpLCRipelT__8L8cfclF9Jm6cBbTeH9BeyGEDP5HrgMLr8dCBMVpi-YykIWTMh5x7uHXzYCc40Oyt9LSU6K7oE3VpAcE/s1600-h/Screen4.jpg&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5171325874396316578&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxOZp_0oLjfeh2yNXJuPO_rzvCRucGfXgqUOGpIq9doOlsOYdCpLCRipelT__8L8cfclF9Jm6cBbTeH9BeyGEDP5HrgMLr8dCBMVpi-YykIWTMh5x7uHXzYCc40Oyt9LSU6K7oE3VpAcE/s320/Screen4.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;The Activate.aspx page&#39;s code behind gets the ID that was passed in the query string and uses it to link the user to the account that was created, as well as adds the user to the Power Users Role in ASPNETDB. The page then displays the Username, Date the account was created, and the Status of the user&#39;s account.&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;&amp;lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;Activate.aspx.cs&quot; Inherits=&quot;Activate&quot; %&amp;gt;



&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;



&amp;lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &amp;gt;

&amp;lt;head runat=&quot;server&quot;&amp;gt;

&amp;lt;title&amp;gt;Activation Page&amp;lt;/title&amp;gt;

&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;

&amp;lt;form id=&quot;form1&quot; runat=&quot;server&quot;&amp;gt;

&amp;lt;br /&amp;gt;

&amp;lt;asp:Table ID=&quot;Table1&quot; runat=&quot;server&quot; CellPadding=&quot;1&quot; CellSpacing=&quot;0&quot; GridLines=&quot;Both&quot; BorderStyle=&quot;Groove&quot; BackColor=&quot;BlanchedAlmond&quot; Caption=&quot;Account Information&quot;&amp;gt;

&amp;lt;asp:TableRow runat=&quot;server&quot;&amp;gt;

&amp;lt;asp:TableCell HorizontalAlign=&quot;Right&quot; runat=&quot;server&quot;&amp;gt;Username:&amp;lt;/asp:TableCell&amp;gt;

&amp;lt;asp:TableCell HorizontalAlign=&quot;Left&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;asp:Label ID=&quot;ActiviationNameLabel&quot; runat=&quot;server&quot; Style=&quot;position: static&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;/asp:TableCell&amp;gt;

&amp;lt;/asp:TableRow&amp;gt;

&amp;lt;asp:TableRow runat=&quot;server&quot;&amp;gt;

&amp;lt;asp:TableCell HorizontalAlign=&quot;Right&quot; runat=&quot;server&quot;&amp;gt;Account Created:&amp;lt;/asp:TableCell&amp;gt;

&amp;lt;asp:TableCell HorizontalAlign=&quot;Left&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;asp:Label ID=&quot;ActivationCreationDateLabel&quot; runat=&quot;server&quot; Style=&quot;position: static&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;/asp:TableCell&amp;gt;

&amp;lt;/asp:TableRow&amp;gt;

&amp;lt;asp:TableRow runat=&quot;server&quot;&amp;gt;

&amp;lt;asp:TableCell HorizontalAlign=&quot;Right&quot; runat=&quot;server&quot;&amp;gt;Account Status:&amp;lt;/asp:TableCell&amp;gt;

&amp;lt;asp:TableCell HorizontalAlign=&quot;Left&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;asp:Label ID=&quot;ActivationStatusLabel&quot; runat=&quot;server&quot; style=&quot;position: static&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;/asp:TableCell&amp;gt;

&amp;lt;/asp:TableRow&amp;gt;

&amp;lt;/asp:Table&amp;gt;

&amp;lt;/form&amp;gt;

&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;



public partial class Activate : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (!Page.IsPostBack)

{

string userID = Request.QueryString[&quot;ID&quot;];

Guid gd = new Guid(userID);

MembershipUser user = Membership.GetUser(gd);

user.IsApproved = true;

Roles.AddUserToRole(user.ToString(), &quot;Power Users&quot;);

Membership.UpdateUser(user);



ActiviationNameLabel.Text = user.UserName;

ActivationCreationDateLabel.Text = user.CreationDate.ToShortDateString();

if (user.IsApproved)

{

ActivationStatusLabel.Text = &quot;Active&quot;;

}

else

{

ActivationStatusLabel.Text = &quot;Pending&quot;;

}

}

}

}

&lt;/code&gt;&lt;/pre&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;b&gt;Here are the final Account Details from the Activate.aspx screen.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCFFCWWqvsOR6Pza4ZZjMmGR9g0OQ-CTi1FWknOlx5HMzk3Jc2Luh4JC2Ue7TiiL867-gXasxBsVyFt2j0sbovTQtwSXOQbJQZCcnkQWSSz0LIp-SqjE0LKilrGlPtQOHsfW6CGh8YI-0/s1600-h/Screen5.jpg&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5171329280305382322&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCFFCWWqvsOR6Pza4ZZjMmGR9g0OQ-CTi1FWknOlx5HMzk3Jc2Luh4JC2Ue7TiiL867-gXasxBsVyFt2j0sbovTQtwSXOQbJQZCcnkQWSSz0LIp-SqjE0LKilrGlPtQOHsfW6CGh8YI-0/s320/Screen5.jpg&quot; /&gt;&lt;/a&gt;&lt;/span&gt;</description><link>http://lspence.blogspot.com/2008/02/sending-activation-email-with-aspnet-20.html</link><author>noreply@blogger.com (Lance Spence)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA96DpUrKg2ni0cxL_Qx6qSGmLyLFIEYUaoIukOyiq2Aozs3WjQipgcaUO0ISaOl1TMNRKDqgSPtEq7I9RDKHakstJmOAtuaOwjsPopc5Rh3RvuIKsTR5zc3R-sT9D76UCSqDLnMcRvwM/s72-c/Screen1.jpg" height="72" width="72"/><thr:total>24</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-1298462996076549976</guid><pubDate>Tue, 29 Jan 2008 02:45:00 +0000</pubDate><atom:updated>2010-05-07T23:01:33.645-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">AJAX</category><category domain="http://www.blogger.com/atom/ns#">CollapsiblePanel</category><title>How-To Auto Collapse Microsoft AJAX Collapsible Panel</title><description>&lt;span style=&quot;font-size: 85%;&quot;&gt;Here&#39;s a quick tip on how to automatically collapse a Collapsible Panel through code. This is useful in a situation such as having a Collapsible Panel that contains a few controls used in data entry and once the user has entered the data and clicked on a button to submit their data you want the panel to collapse automatically.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;You would think that just performing a (control name) CollapsiblePanelExtender1.collapse = True would collapse the panel; however, this will not work by itself. This is due to the fact that there is a short delay between the first rendering of the page and the running of the Javascript to modify it. To have the panel collapse you will need to add one more line, so your code will look like this.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;CollapsiblePanelExtender1.Collapsed = True;
CollapsiblePanelExtender1.ClientState = &quot;true&quot;;
&lt;/code&gt;&lt;/pre&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;You can also prevent the PopControlExtender from briefly showing controls it contains by placing the controls within a Panel Control and setting the Panel Control&#39;s visibility style to &lt;b&gt;hidden&lt;/b&gt;. This will stop the annoying flickering that happens when the page is first rendered.&lt;/span&gt;</description><link>http://lspence.blogspot.com/2008/01/how-to-auto-collapse-microsoft-ajax.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>8</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-7637936845040418184</guid><pubDate>Thu, 10 Jan 2008 21:05:00 +0000</pubDate><atom:updated>2008-01-10T16:09:13.603-05:00</atom:updated><title>Cheat Sheets</title><description>A co-worker gave me this very useful cheat-sheet resource.&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.ilovejackdaniels.com/cheat-sheets/&quot;&gt;http://www.ilovejackdaniels.com/cheat-sheets/&lt;/a&gt;</description><link>http://lspence.blogspot.com/2008/01/cheat-sheets.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-4055443479818318262</guid><pubDate>Mon, 31 Dec 2007 20:23:00 +0000</pubDate><atom:updated>2008-01-02T08:52:43.017-05:00</atom:updated><title>Maintaining Control Values Between Pages</title><description>&lt;span style=&quot;font-size:85%;&quot;&gt;Here is a quick  example of how you can maintain the values of controls when switching back and forth between different web pages by making use of Session variables. You can use ASP.NET Session variables to pass the values from one web page to another, but if you need to return to the previous page via a button for example the web page will loose the previous values it had. You can maintain those values just as if you had clicked your browser&#39;s back button by using Session variables.&lt;br /&gt;&lt;br /&gt;Below is a short example that demonstrates this.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Default.aspx&lt;/span&gt;&lt;br /&gt;&lt;pre style=&quot;border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;&quot;&gt;&lt;code&gt;&amp;lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot;  CodeFile=&quot;Default.aspx.cs&quot; Inherits=&quot;_Default&quot; %&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &amp;gt;&lt;br /&gt;&amp;lt;head runat=&quot;server&quot;&amp;gt;&lt;br /&gt;&amp;lt;title&amp;gt;Untitled Page&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;lt;form id=&quot;form1&quot; runat=&quot;server&quot;&amp;gt;&lt;br /&gt;&amp;lt;div&amp;gt;&lt;br /&gt; &amp;lt;asp:Label ID=&quot;FNLabel&quot; runat=&quot;server&quot; Text=&quot;First Name&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;&lt;br /&gt; &amp;lt;asp:Label ID=&quot;LNLabel&quot; runat=&quot;server&quot; Text=&quot;Last Name&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt; &amp;lt;asp:TextBox ID=&quot;FNTextBox&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt; &amp;lt;asp:TextBox ID=&quot;LNTextBox&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;amp;nbsp;&amp;lt;br /&amp;gt;&lt;br /&gt; &amp;lt;br /&amp;gt;&lt;br /&gt; &amp;lt;asp:DropDownList ID=&quot;IncomeDropDownList&quot; runat=&quot;server&quot; AutoPostBack=&quot;True&quot;&amp;gt;&lt;br /&gt;     &amp;lt;asp:ListItem&amp;gt;10K -30K&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;     &amp;lt;asp:ListItem&amp;gt;31K - 50K&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;     &amp;lt;asp:ListItem&amp;gt;51K - 70K&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;     &amp;lt;asp:ListItem&amp;gt;71K - 90K&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;     &amp;lt;asp:ListItem&amp;gt;91K+&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt; &amp;lt;/asp:DropDownList&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt; &amp;lt;br /&amp;gt;&lt;br /&gt; &amp;lt;asp:RadioButtonList ID=&quot;ResidenceRadioButtonList&quot; runat=&quot;server&quot; AutoPostBack=&quot;True&quot;&amp;gt;&lt;br /&gt;     &amp;lt;asp:ListItem&amp;gt;Apartment&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;     &amp;lt;asp:ListItem&amp;gt;Mobile Home&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;     &amp;lt;asp:ListItem&amp;gt;Townhouse&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;     &amp;lt;asp:ListItem&amp;gt;Single Family House&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt; &amp;lt;/asp:RadioButtonList&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt; &amp;lt;asp:Calendar ID=&quot;AcctStartCalendar&quot; runat=&quot;server&quot; BackColor=&quot;White&quot; BorderColor=&quot;#999999&quot; CellPadding=&quot;4&quot; DayNameFormat=&quot;Shortest&quot; Font-Names=&quot;Verdana&quot; Font-Size=&quot;8pt&quot; ForeColor=&quot;Black&quot; Height=&quot;180px&quot; Width=&quot;200px&quot;&amp;gt;&lt;br /&gt;     &amp;lt;SelectedDayStyle BackColor=&quot;Green&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; /&amp;gt;&lt;br /&gt;     &amp;lt;TodayDayStyle BackColor=&quot;#CCCCCC&quot; ForeColor=&quot;Black&quot; /&amp;gt;&lt;br /&gt;     &amp;lt;SelectorStyle BackColor=&quot;#CCCCCC&quot; /&amp;gt;&lt;br /&gt;     &amp;lt;WeekendDayStyle BackColor=&quot;#FFFFCC&quot; /&amp;gt;&lt;br /&gt;     &amp;lt;OtherMonthDayStyle ForeColor=&quot;#808080&quot; /&amp;gt;&lt;br /&gt;     &amp;lt;NextPrevStyle VerticalAlign=&quot;Bottom&quot; /&amp;gt;&lt;br /&gt;     &amp;lt;DayHeaderStyle BackColor=&quot;#CCCCCC&quot; Font-Bold=&quot;True&quot; Font-Size=&quot;7pt&quot; /&amp;gt;&lt;br /&gt;     &amp;lt;TitleStyle BackColor=&quot;#999999&quot; BorderColor=&quot;Black&quot; Font-Bold=&quot;True&quot; /&amp;gt;&lt;br /&gt; &amp;lt;/asp:Calendar&amp;gt;&lt;br /&gt; &amp;lt;br /&amp;gt;&lt;br /&gt; &amp;lt;asp:Button ID=&quot;SubmitButton&quot;&lt;br /&gt;     runat=&quot;server&quot; OnClick=&quot;Button1_Click&quot; Text=&quot;Submit&quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt; &amp;lt;br /&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Default.aspx.cs&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;pre style=&quot;border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;&quot;&gt;&lt;code&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;&lt;br /&gt;public partial class _Default : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;  LoadExistingValues();&lt;br /&gt;}&lt;br /&gt;protected void Button1_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;  Session[&quot;value1&quot;] = FNTextBox.Text;&lt;br /&gt;  Session[&quot;value2&quot;] = LNTextBox.Text;&lt;br /&gt;  Session[&quot;value3&quot;] = IncomeDropDownList.SelectedValue;&lt;br /&gt;  Session[&quot;value4&quot;] = ResidenceRadioButtonList.SelectedValue;&lt;br /&gt;  Session[&quot;value5&quot;] = AcctStartCalendar.SelectedDate;&lt;br /&gt;&lt;br /&gt;  Response.Redirect(&quot;~/Page2.aspx&quot;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private void LoadExistingValues()&lt;br /&gt;{&lt;br /&gt;  if (!Page.IsPostBack)&lt;br /&gt;  {&lt;br /&gt;      if (Session[&quot;value1&quot;] != null)&lt;br /&gt;      {&lt;br /&gt;          FNTextBox.Text = Session[&quot;value1&quot;].ToString();&lt;br /&gt;          LNTextBox.Text = Session[&quot;value2&quot;].ToString();&lt;br /&gt;          IncomeDropDownList.SelectedValue = Session[&quot;value3&quot;].ToString();&lt;br /&gt;          ResidenceRadioButtonList.SelectedValue = Session[&quot;value4&quot;].ToString();&lt;br /&gt;&lt;br /&gt;          AcctStartCalendar.SelectedDate = Convert.ToDateTime((Session[&quot;value5&quot;]));&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;Page2.aspx&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;br /&gt;&lt;pre style=&quot;border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;&quot;&gt;&lt;code&gt;&amp;lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;Page2.aspx.cs&quot; Inherits=&quot;Page2&quot; %&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &amp;gt;&lt;br /&gt;&amp;lt;head runat=&quot;server&quot;&amp;gt;&lt;br /&gt;&amp;lt;title&amp;gt;Untitled Page&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;lt;form id=&quot;form1&quot; runat=&quot;server&quot;&amp;gt;&lt;br /&gt;&amp;lt;div&amp;gt;&lt;br /&gt;   &amp;lt;asp:Label ID=&quot;FNLabel&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;,&lt;br /&gt;   &amp;lt;asp:Label ID=&quot;LNLabel&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;   &amp;lt;br /&amp;gt;&lt;br /&gt;   &amp;lt;asp:Label ID=&quot;IncomeLabel&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;   &amp;lt;br /&amp;gt;&lt;br /&gt;   &amp;lt;asp:Label ID=&quot;ResidenceLabel&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;   &amp;lt;br /&amp;gt;&lt;br /&gt;   &amp;lt;asp:Calendar ID=&quot;AcctSelectionCalendar&quot; runat=&quot;server&quot;&amp;gt;&amp;lt;/asp:Calendar&amp;gt;&lt;br /&gt;   &amp;lt;br /&amp;gt;&lt;br /&gt;   &amp;lt;br /&amp;gt;&lt;br /&gt;   &amp;amp;nbsp;&lt;br /&gt;   &amp;lt;asp:Button ID=&quot;PreButton&quot; runat=&quot;server&quot; OnClick=&quot;Button1_Click&quot; Text=&quot;Return to previous page&quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Page2.aspx.cs&lt;/span&gt;&lt;br /&gt;&lt;pre style=&quot;border: 1px dashed rgb(153, 153, 153); padding: 5px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;&quot;&gt;&lt;code&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;&lt;br /&gt;public partial class Page2 : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;    FNLabel.Text = (Session[&quot;value1&quot;]).ToString();&lt;br /&gt;    LNLabel.Text = (Session[&quot;value2&quot;]).ToString();&lt;br /&gt;    IncomeLabel.Text = (Session[&quot;value3&quot;]).ToString();&lt;br /&gt;    ResidenceLabel.Text = (Session[&quot;value4&quot;]).ToString();&lt;br /&gt;    AcctSelectionCalendar.SelectedDate = Convert.ToDateTime((Session[&quot;value5&quot;]));&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;protected void Button1_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;    Response.Redirect(&quot;~/Default.aspx&quot;, true);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;This little example should show you how easy it is to maintain the values of controls when navigating back and forth between pages. I have not experimented extensively with other controls, so further tweaking may be required.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;</description><link>http://lspence.blogspot.com/2007/12/maintaining-control-values-between.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-8318915246695216325</guid><pubDate>Wed, 12 Dec 2007 13:39:00 +0000</pubDate><atom:updated>2010-05-07T23:00:31.325-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">IIS</category><title>Running ASP.NET 2.0 in Integrated Mode on IIS 7</title><description>&lt;span style=&quot;font-size: 85%;&quot;&gt;I just wanted to share this blog link that discusses the changes you&#39;ll need to be aware of when you running your ASP.NET 2.0 applications in Integrated Mode on IIS 7 on Vista or Windows Server 2008.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://mvolo.com/blogs/serverside/archive/2007/12/08/IIS-7.0-Breaking-Changes-ASP.NET-2.0-applications-Integrated-mode.aspx&quot;&gt;http://mvolo.com/blogs/serverside/archive/2007/12/08/IIS-7.0-Breaking-Changes-ASP.NET-2.0-applications-Integrated-mode.aspx&lt;/a&gt;&lt;br /&gt;
&lt;/span&gt;</description><link>http://lspence.blogspot.com/2007/12/running-aspnet-20-in-integrated-mode-on.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-4996338706661550137</guid><pubDate>Fri, 26 Oct 2007 14:20:00 +0000</pubDate><atom:updated>2007-10-26T10:23:51.000-04:00</atom:updated><title>.NET Daily Tips</title><description>&lt;span style=&quot;font-size:85%;&quot;&gt;I stumbled across this website and thought I&#39;d share it with everyone. Visit this site  frequently for some little known tips you might not have ever known about regarding .NET&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href=&quot;http://dotnettipoftheday.org/tips/&quot;&gt;http://dotnettipoftheday.org/tips/&lt;/a&gt;</description><link>http://lspence.blogspot.com/2007/10/net-daily-tips.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-2834166071876001535</guid><pubDate>Tue, 11 Sep 2007 21:17:00 +0000</pubDate><atom:updated>2010-05-07T22:59:56.174-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Visual Studio</category><title>Resetting Visual Studio 2005 to Original Settings</title><description>&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;NOTE: Issuing the following command will clear any custom and environmental settings&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;.&lt;br /&gt;
&lt;br /&gt;
You may come across a situation where your Visual Studio 2005 Environment is non-functional in one manner or another. This recently happened to me when I was trying to reset the environment to the General Environment settings using the Import and Export Settings Wizard. During the process I encountered an error which left the IDE in a state in which it would try to Initialize the Toolbox and after a few seconds close Visual Studio. Thus I was unable to access any of the ToolBox controls.&lt;br /&gt;
&lt;br /&gt;
After a quick search I came across a command that you run from the Visual Studio Command Prompt to reset the IDE to its original install settings. If after exhausting all possible repair options you need to run this command please backup any custom and/or environmental settings you do not want to lose prior to its use.&lt;br /&gt;
&lt;br /&gt;
Then perform the following:&lt;br /&gt;
&lt;br /&gt;
1. Click Start and then select All Programs.&lt;br /&gt;
2. Select Microsoft Visual Studio 2005.&lt;br /&gt;
3. Select Visual Studio Tools and then Visual Studio 2005 Command Prompt.&lt;br /&gt;
4. Enter &lt;span style=&quot;font-weight: bold;&quot;&gt;devenv /resetuserdata&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
You will not receive any confirmation of reset completion, so you can use task manager to monitor the &lt;span style=&quot;font-weight: bold;&quot;&gt;devenv&lt;/span&gt; process for its completion.&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;/span&gt;</description><link>http://lspence.blogspot.com/2007/09/resetting-visual-studio-2005-to.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-3160265530729601365</guid><pubDate>Sat, 11 Aug 2007 02:16:00 +0000</pubDate><atom:updated>2007-08-10T22:55:19.983-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Foreign Characters</category><category domain="http://www.blogger.com/atom/ns#">Special Characters</category><category domain="http://www.blogger.com/atom/ns#">Symbols</category><title>Symbols, Accents, Punctuation, and Foreign Characters</title><description>Have you ever needed to type special symbols or characters such as the Registered Trademark Symbol, Copyright Symbol, or perhaps an Umlaut or the Math Division Symbol in a document or web page? Trying to remember the codes that represent them or having to reference some web page that list them can be really impractical. There is a much easier way to access these symbols.&lt;br /&gt;&lt;br /&gt;Many people are unaware of a small program that comes with Windows and Linux Distributions that provides them for you along with their associated codes. This same type of program I&#39;m sure comes with OSX as well as other Operating Systems; however, I am unable to verify this due to my lack of access to the numerous number of Operating Systems available.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;In Windows 2000/XP/Vista&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;1. Click the Start Button.&lt;br /&gt;2. Select All Programs.&lt;br /&gt;3. Select Accessories.&lt;br /&gt;4. Select System Tools.&lt;br /&gt;5. Select Character Map.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;In Ubuntu Linux (Other Linux Distros may have similar steps)&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;1. Click Applications from the Task Bar.&lt;br /&gt;2. Select Accessories.&lt;br /&gt;3. Select Character Map.&lt;br /&gt;&lt;br /&gt;Whenever you need to make use of a special symbol or foreign character just to mention a couple types; this is a very simple way that is readily available to you. No need to search for the codes for such symbols via the Internet or consult some other reference material.</description><link>http://lspence.blogspot.com/2007/08/symbols-accents-punctuation-and-foreign.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-6530004374267778914</guid><pubDate>Wed, 25 Jul 2007 12:48:00 +0000</pubDate><atom:updated>2007-08-07T21:52:41.196-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Master Page</category><title>Accessing Master Page Controls via Content Pages</title><description>&lt;span style=&quot;font-size:85%;&quot;&gt;There are a couple of ways to access the controls of Master Pages in ASP.NET 2.0 from within your content pages. You can do this in a non-strongly typed manner or a strongly type manner. I will provide a sample below that demonstrates each approach.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;Non-Strongly Typed&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Lets say your Master Page contains a Label that displays the current Date. Within your content page use the FindControl method to locate the control in the Master Page whose property you want to access. Note you must perform an explicit cast.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Label lbl = (Label)Master.FindControl(&quot;DateLabel&quot;);&lt;br /&gt;lbl.Text = DateTime.Today.ToLongDateString();&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;FONT-WEIGHT: bold&quot;&gt;Strongly Typed&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;In the code-behind of your Master Page create a property that accesses the control you want to manipulate.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;FONT-STYLE: italic&quot;&gt;public string GetCurrentDate&lt;br /&gt;{&lt;br /&gt;get { return DateLabel.Text; }&lt;br /&gt;set { DateLabel.Text = value; }&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the HTML source of your content page add the following beneath the &lt;em&gt;Page&lt;/em&gt; &lt;%@ Page %&gt;&lt;%@ Page %&gt;&lt;%@ Page %&gt;directive. Add MasterType before TypeName.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt; typename=&quot;Site&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Replace &lt;em&gt;&quot;Site&quot;&lt;/em&gt; with the class name of your Master Page. You could also re-write the above using &lt;em&gt;VirtualPath &lt;/em&gt;in place of &lt;em&gt;TypeName.&lt;/em&gt;&lt;/span&gt; &lt;strong&gt;NOTE: Blogger will not display the percent signs that are between the &lt;&gt; as well it also Strips out the MasterType Directive.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;To do this just replace the &lt;em&gt;MasterPage.master&lt;/em&gt; with the name of your Master Page.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Finally in the code-behind of your content page you can set the DateLabel to the current date on your Master Page as below:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;em&gt;this.Master.GetCurrentDate = DateTime.Today.ToLongDateString();&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt;&lt;/em&gt;</description><link>http://lspence.blogspot.com/2007/07/accessing-master-page-controls-via.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-2940822809239359411</guid><pubDate>Thu, 12 Jul 2007 19:55:00 +0000</pubDate><atom:updated>2007-07-13T23:34:38.672-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Connection  Strings</category><category domain="http://www.blogger.com/atom/ns#">SQL</category><category domain="http://www.blogger.com/atom/ns#">Web Service</category><title>Free Web Services and SQL Connection Strings</title><description>I wanted to share the following resources I came across hopefully if you ever need them they&#39;ll be helpful to you.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Web Services&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.webservicex.net/WCF/default.aspx&quot;&gt;http://www.webservicex.net/WCF/default.aspx&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://www.xmethods.net/&quot;&gt;http://www.xmethods.net/&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://www.webservicelist.com/&quot;&gt;http://www.webservicelist.com/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SQL Connection Strings&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.connectionstrings.com/&quot;&gt;http://www.connectionstrings.com/&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://www.carlprothman.net/Default.aspx?tabid=81&quot;&gt;http://www.carlprothman.net/Default.aspx?tabid=81&lt;/a&gt;</description><link>http://lspence.blogspot.com/2007/07/free-web-services-and-sql-connection.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-9023145151373152398</guid><pubDate>Thu, 21 Jun 2007 16:48:00 +0000</pubDate><atom:updated>2010-05-07T22:58:59.801-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">AJAX</category><category domain="http://www.blogger.com/atom/ns#">ASP.NET</category><category domain="http://www.blogger.com/atom/ns#">Code Snippets</category><category domain="http://www.blogger.com/atom/ns#">CollapsiblePanel</category><category domain="http://www.blogger.com/atom/ns#">Pop Up</category><title>More Useful C# Code Snippets</title><description>&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;span style=&quot;font-size: 100%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Display Pop-Up Error Messages In An ASP.NET Application&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;I came across an issue in which someone needed to pop-up a Window to display an error message to users in their ASP.NET application. I did some research and discovered this very handy bit of code that will display a JavaScript Alert MessageBox that you can populate with the error message.&lt;br /&gt;
&lt;br /&gt;
Below is an example I created that purposely causes a DivisonByZero Exception and displays this in a JavaScript Alert MessageBox.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;int num1 = 10;
int num2 = 0;
int result;

try
{
result = n1 /n2;
}
catch (DivideByZeroException ex)
{
DisplayErrorMsg(ex);
}


private void DisplayErrorMsg(Exception ex)
{
RegisterStartupScript(Guid.NewGuid().ToString(),
string.Format(&quot;&amp;lt;script language=&#39;Javascript&#39;&amp;gt;alert(&#39;{0}&#39;);&amp;lt;/script&amp;gt;&quot;, ex.Message));
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: 100%;&quot;&gt;Populate The Display Text Of A CollapsiblePanel Control From A File&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 0pt;&quot;&gt;&lt;span style=&quot;font-size: 100%;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
I had the need to populate the text to be displayed in an ASP.NET AJAX CollapsiblePanel Control via a text file as opposed to just embedding the text between a &lt;asp:panel&gt;&lt;/asp:panel&gt;tag of my Content Panel. I had to display a large amount of text that displayed some &lt;span style=&quot;font-weight: bold;&quot;&gt;Terms and Conditions&lt;/span&gt; and there was just to much to put between the tags. Besides it really would make the code ugly having all of that text embedded.&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: 100%;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 0pt;&quot;&gt;&lt;span style=&quot;font-size: 100%;&quot;&gt;&lt;span style=&quot;font-size: 0pt;&quot;&gt;The solution I decided to go with was to create a Web User Control and fill the control with the text to be displayed. Then I went back to the page that I was going to display this text on and dropped the Custom Control inside of my CollapsiblePanel&#39;s ContentPanel. I then went into the HTML source of the page and surrounded the ContentPanel with a &lt;span style=&quot;font-weight: bold;&quot;&gt;Div&lt;/span&gt; tag and sat the height, overflow, and background color.&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXXhG-KSR-AZPUOiVH40g90AcATJQCDA2OYaTW0u_06gRu0kKPDVWb92uC6ONLh5tavUZsuoOb0_xhld1DUMhPHdBZuUG-IKGCqeGgReSKfcBOEXAe5jbK3xco6sBEvB6hadjU_z-Z85s/s1600-h/Panel_Closed.png&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5078594924758169826&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXXhG-KSR-AZPUOiVH40g90AcATJQCDA2OYaTW0u_06gRu0kKPDVWb92uC6ONLh5tavUZsuoOb0_xhld1DUMhPHdBZuUG-IKGCqeGgReSKfcBOEXAe5jbK3xco6sBEvB6hadjU_z-Z85s/s320/Panel_Closed.png&quot; style=&quot;cursor: pointer;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCK2HYjDpdwvpzRRd4z3mAS5tIcMk50y3taP0XT-hx85WY8b1N8CwsRQUiFLOfLoxQ02bOppuZcO1SW4EL__ryr0huYi3wC-Rbp2YYWq6ZasMP2HNBA_zaAXmp0FKq5MTUSlh_zJlgzG8/s1600-h/Panel_Opened.png&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5078595307010259186&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCK2HYjDpdwvpzRRd4z3mAS5tIcMk50y3taP0XT-hx85WY8b1N8CwsRQUiFLOfLoxQ02bOppuZcO1SW4EL__ryr0huYi3wC-Rbp2YYWq6ZasMP2HNBA_zaAXmp0FKq5MTUSlh_zJlgzG8/s320/Panel_Opened.png&quot; style=&quot;cursor: pointer;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;&amp;lt;ajaxToolkit:CollapsiblePanelExtender ID=&quot;CollapsiblePanelExtender1&quot; runat=&quot;server&quot;
TargetControlID=&quot;ContentPanel&quot;
ExpandControlID=&quot;TitlePanel&quot;
CollapseControlID=&quot;TitlePanel&quot;
Collapsed=&quot;false&quot;
TextLabelID=&quot;Label1&quot;
ExpandedText=&quot;(Hide Details...)&quot;
CollapsedText=&quot;(Show Details)&quot;
ImageControlID=&quot;Image1&quot;
CollapsedImage=&quot;images/expand.jpg&quot;
ExpandedImage=&quot;images/collapse.jpg&quot;
SuppressPostBack=&quot;true&quot;&amp;gt;
&amp;lt;/ajaxToolkit:CollapsiblePanelExtender&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;&amp;lt;asp:Panel ID=&quot;TitlePanel&quot; runat=&quot;server&quot; Height=&quot;30px&quot; Width=&quot;545px&quot;&amp;gt;
&amp;lt;asp:Image ID=&quot;Image1&quot; runat=&quot;server&quot; ImageUrl=&quot;~/images/expand.jpg&quot;/&amp;gt;
Terms and Conditions
&amp;lt;asp:Label ID=&quot;Label1&quot; runat=&quot;server&quot; Text=&quot;Label&quot;&amp;gt;(Show Details ...)&amp;lt;/asp:Label&amp;gt;
&amp;lt;/asp:Panel&amp;gt;
&amp;lt;asp:Panel ID=&quot;ContentPanel&quot; runat=&quot;server&quot; Height=&quot;0px&quot; Width=&quot;545px&quot;&amp;gt;                                
&amp;lt;div style=&quot;height:150px;overflow:scroll;background-color:ButtonFace;&quot; &amp;gt;
&amp;lt;uc2:Terms ID=&quot;Terms1&quot; runat=&quot;server&quot; /&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/asp:Panel&amp;gt;
&lt;/code&gt;&lt;/pre&gt;</description><link>http://lspence.blogspot.com/2007/06/more-useful-c-code-snippets.html</link><author>noreply@blogger.com (Lance Spence)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXXhG-KSR-AZPUOiVH40g90AcATJQCDA2OYaTW0u_06gRu0kKPDVWb92uC6ONLh5tavUZsuoOb0_xhld1DUMhPHdBZuUG-IKGCqeGgReSKfcBOEXAe5jbK3xco6sBEvB6hadjU_z-Z85s/s72-c/Panel_Closed.png" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7622642958068848741.post-1951260430116738327</guid><pubDate>Fri, 08 Jun 2007 18:50:00 +0000</pubDate><atom:updated>2010-05-07T22:59:25.271-04:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Code Snippets</category><title>Useful C# Code Snippets</title><description>&lt;b&gt;Mapping a month name to its chronological order value&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;The following C# code can be used to map a month name to its equivalent numeric chronological order value. You can use this code in a method and pass the month in as a string to convert for example &quot;JUN&quot; to 06. You can modify the array to map the full month name in place of it&#39;s three letter abbreviation.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 100%;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;border-left: 1px dashed rgb(153, 153, 153); border-right: 1px dashed rgb(153, 153, 153); border-top: 1px dashed rgb(153, 153, 153); border-width: 1px; overflow: auto; padding-left: 5px; padding-right: 5px; width: 100%;&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-size: 78%;&quot;&gt;public string MonthToNumberMapper(string month)
{
string Month = month.ToUpper();
string ConvertedMonth = null;
string[,] MonthsToConvert = new string[,]
{
{ &quot;JAN&quot;, &quot;01&quot; }, { &quot;FEB&quot;, &quot;02&quot; }, { &quot;MAR&quot;, &quot;03&quot; }, { &quot;APR&quot;, &quot;04&quot; },
{ &quot;MAY&quot;, &quot;05&quot; }, { &quot;JUN&quot;, &quot;06&quot; }, { &quot;JUL&quot;, &quot;07&quot; }, { &quot;AUG&quot;, &quot;08&quot; },
{ &quot;SEP&quot;, &quot;09&quot; }, { &quot;OCT&quot;, &quot;10&quot; }, { &quot;NOV&quot;, &quot;11&quot; }, { &quot;DEC&quot;, &quot;12&quot; }
};

// Determine the numeric month.
for (int i = 0; i &amp;lt; MonthsToConvert.Length / 2; i++)
{
if (Month == MonthsToConvert[i, 0])
{
ConvertedMonth = MonthsToConvert[i, 1];
break;
}
}

return ConvertedMonth;
}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Converting the text in a ComboBox Control to Uppercase&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;The following C# code can be placed in the TextChanged event handler of a ComboBox Control to change the case of the text entered to uppercase. This works for text entered into or selected within the ComboBox Control.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;border-color: rgb(153, 153, 153); border-left: 1px dashed rgb(153, 153, 153); border-right: 1px dashed rgb(153, 153, 153); border-top: 1px dashed rgb(153, 153, 153); border-width: 1px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; width: 100%;&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-size: 78%;&quot;&gt;private void StateComboBox_TextChanged(object sender, EventArgs e)
{
String stateText = (string)StateComboBox.Text;
stateText = stateText.ToUpper();
StateComboBox.Text = stateText;
installStateComboBox.SelectionStart = installStateComboBox.Text.Length;
}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;</description><link>http://lspence.blogspot.com/2007/06/useful-c-code-snippets.html</link><author>noreply@blogger.com (Lance Spence)</author><thr:total>3</thr:total></item></channel></rss>