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

<channel>
	<title>Codelab Blog &#187; ASP.NET</title>
	<atom:link href="http://blog.codelab.co.nz/category/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.codelab.co.nz</link>
	<description>Technical Articles and News from Codelab Ltd</description>
	<lastBuildDate>Tue, 17 Jan 2012 13:10:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Perform ASP.NET Postback using JQuery</title>
		<link>http://blog.codelab.co.nz/2011/10/27/perform-asp-net-postback-using-jquery/</link>
		<comments>http://blog.codelab.co.nz/2011/10/27/perform-asp-net-postback-using-jquery/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 23:47:24 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[ViewState]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=363</guid>
		<description><![CDATA[Came across a situation where I needed to disable the ASP.NET button using JQuery when the user clicks on the button, this is so we stop the user from clicking the button twice while the page is doing a postback. Firstly, add the following JQuery/Javascript code: &#60;script&#62; &#160;function autoSubmit() &#160;{ &#160;&#60;%= ClientScript.GetPostBackEventReference(btnSaveChanges, &#34;&#34;) %&#62;; &#160;} [...]]]></description>
			<content:encoded><![CDATA[<p>Came across a situation where I needed to disable the ASP.NET button using JQuery when the user clicks on the button, this is so we stop the user from clicking the button twice while the page is doing a postback.</p>
<p>Firstly, add the following JQuery/Javascript code:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;script&gt;<br />
<br />
&nbsp;function autoSubmit()<br />
&nbsp;{<br />
&nbsp;&lt;%= ClientScript.GetPostBackEventReference(btnSaveChanges, &quot;&quot;) %&gt;;<br />
&nbsp;}<br />
&nbsp; &nbsp; &nbsp;$(function () {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$(&quot;#&lt;%= btnSaveChanges.ClientID %&gt;&quot;).click(function () {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$(this).attr(&quot;disabled&quot;, &quot;true&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;autoSubmit();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;});<br />
&nbsp; &nbsp; &nbsp;});<br />
&lt;/script&gt;</div></div>
<p>You can inject the correct generated javascript code from using the function GetPostBackEventReference between the server tags.   Bind a click event to the ASP.NET server control which disables the button and call the autosubmit javascript function to perform a post back on the ASP.NET button control.   </p>
<p>References</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms153112.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ms153112.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2011/10/27/perform-asp-net-postback-using-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elmah and MVC 3 Error Handling</title>
		<link>http://blog.codelab.co.nz/2011/07/12/elmah-and-mvc-3-error-handling/</link>
		<comments>http://blog.codelab.co.nz/2011/07/12/elmah-and-mvc-3-error-handling/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 09:57:56 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=348</guid>
		<description><![CDATA[I came into an issue where I have Elmah configured on a ASP.NET MVC 3 website. I notice that the errors were not getting logged or emailed as per my configuration settings in web.config. I found that MVC3 Error Handling was handling all the errors before Elmah could handle the error and report it correctly. [...]]]></description>
			<content:encoded><![CDATA[<p>I came into an issue where I have Elmah configured on a ASP.NET MVC 3 website. I notice that the errors were not getting logged or emailed as per my configuration settings in web.config.<br />
I found that MVC3 Error Handling was handling all the errors before Elmah could handle the error and report it correctly.</p>
<p>This link was very helpful:</p>
<p><a title="Elmah and MVC 3" href="http://thecodersperspective.posterous.com/how-to-get-elmah-and-mvc3-error-handling-to-p">http://thecodersperspective.posterous.com/how-to-get-elmah-and-mvc3-error-handling-to-p</a></p>
<p>Also when using Elmah on a production environment, its a good idea to lock down the permissions for the elmah.axd handler so only users in a particular role have access to this file. (Assuming that your website is using forms authentication and role provider)</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;&lt;location path=&quot;elmah.axd&quot;&gt;<br />
&nbsp; &nbsp; &lt;system.web&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;authorization&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;allow roles=&quot;Administrators&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;deny users=&quot;*&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;/authorization&gt;<br />
&nbsp; &nbsp; &lt;/system.web&gt;<br />
&nbsp; &lt;/location&gt;</div></div>
<p>And also make sure that this setting is set to false so its not available to remote users.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;security allowRemoteAccess=&quot;0&quot; /&gt;</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2011/07/12/elmah-and-mvc-3-error-handling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using UserControl.RenderControl()</title>
		<link>http://blog.codelab.co.nz/2011/06/07/using-usercontrol-rendercontrol/</link>
		<comments>http://blog.codelab.co.nz/2011/06/07/using-usercontrol-rendercontrol/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 22:08:15 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=341</guid>
		<description><![CDATA[Perhaps you want to reuse a usercontrol in a email? or you need to generate the html from a usercontrol for a specific purpose? Firstly, here is the code to render the html from a user control to a string builder object: &#160; &#160;Dim sb As New StringBuilder() &#160; &#160;Using sw As New StringWriter(sb) &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Perhaps you want to reuse a usercontrol in a email? or you need to generate the html from a usercontrol for a specific purpose?</p>
<p>Firstly, here is the code to render the html from a user control to a string builder object:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp;Dim sb As New StringBuilder()<br />
&nbsp; &nbsp;Using sw As New StringWriter(sb)<br />
&nbsp; &nbsp; &nbsp; Using htmlTw As New HtmlTextWriter(sw)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim ucUserControl As UCUserControl = LoadControl(&quot;myUserControl.ascx&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ucUserControl .Visible = True<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ucUserControl .Display() 'This is a custom method to do some processing<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ucUserControl .RenderControl(htmlTw)<br />
&nbsp; &nbsp; &nbsp; End Using<br />
&nbsp; &nbsp;End Using</div></div>
<p>Secondly, make sure that you set <em><strong>enableEventValidation=&#8221;false&#8221;</strong></em> on the page you are generating the html from.   You will get an error if this is enabled.   You could extend this futher by adding a boolean variable to the page and only disabling Event Validation while rending the control.</p>
<p>Thirdly, override the <em><strong>VerifyRenderingInServerForm</strong></em> method and make it doing &#8220;nothing&#8221;.   If you do not do this, you will get an error saying that you have no form sever tag in your user control.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Public Overrides Sub VerifyRenderingInServerForm(control As System.Web.UI.Control)<br />
'Do nothing<br />
End Sub</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2011/06/07/using-usercontrol-rendercontrol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back to Basics &#8211; Deleting Cookies using ASP.NET</title>
		<link>http://blog.codelab.co.nz/2011/05/11/back-to-basics-deleting-cookies-using-asp-net/</link>
		<comments>http://blog.codelab.co.nz/2011/05/11/back-to-basics-deleting-cookies-using-asp-net/#comments</comments>
		<pubDate>Tue, 10 May 2011 23:21:58 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=331</guid>
		<description><![CDATA[You cannot instruct ASP.NET to physically remove cookies from the user&#8217;s computer so you have to tell the user&#8217;s browser to modify the cookie in order to trigger the browser to remove the cookie. See code example: HttpCookie aCookie; string cookieName; int limit = Request.Cookies.Count; for (int i=0; i { cookieName = Request.Cookies[i].Name; aCookie = [...]]]></description>
			<content:encoded><![CDATA[<p>You cannot instruct ASP.NET to physically remove cookies from the user&#8217;s computer so you have to tell the user&#8217;s browser to modify the cookie in order to trigger the browser to remove the cookie.</p>
<p>See code example:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HttpCookie aCookie;<br />
string cookieName;<br />
int limit = Request.Cookies.Count;<br />
for (int i=0; i {<br />
cookieName = Request.Cookies[i].Name;<br />
aCookie = new HttpCookie(cookieName);<br />
aCookie.Expires = DateTime.Now.AddDays(-1);<br />
Response.Cookies.Add(aCookie);<br />
}</div></div>
<p>&nbsp;</p>
<p><strong><em>References:</em></strong></p>
<p><a title="Cookie Overview" href="http://msdn.microsoft.com/en-us/library/ms178194.aspx#Y5776" target="_blank">http://msdn.microsoft.com/en-us/library/ms178194.aspx#Y5776</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2011/05/11/back-to-basics-deleting-cookies-using-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>handling multiple submit buttons in one form (asp.net webforms)</title>
		<link>http://blog.codelab.co.nz/2011/05/06/handling-multiple-submit-buttons/</link>
		<comments>http://blog.codelab.co.nz/2011/05/06/handling-multiple-submit-buttons/#comments</comments>
		<pubDate>Fri, 06 May 2011 05:00:03 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[W3C]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=325</guid>
		<description><![CDATA[I came across an issue where I had the following setup with an asp.net website: I had a master page with one main form element I had a submit button in the master page which acts as a search button across the website I had a login page that also has a submit button Naturally [...]]]></description>
			<content:encoded><![CDATA[<p>I came across an issue where I had the following setup with an asp.net website:</p>
<ol>
<li>I had a master page with one main form element</li>
<li>I had a submit button in the master page which acts as a search button across the website</li>
<li>I had a login page that also has a submit button</li>
</ol>
<p>Naturally when the user presses the enter key, it naturally takes the first submit button on the webpage as being the default submit button.   Therefore when a user enters their credentials on the login page, they will always be taken to the search page which is defined by the input button on the master page.</p>
<p>I used jQuery to help solve this issue, you need to do two important things:</p>
<p>1) You need to set a default selector on the input button you want to submit, i.e on the login button I put:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;&lt;input class=&quot;buttondefault&quot; name=&quot;myButton&quot; type=&quot;submit&quot; /&gt;</div></div>
<p>&nbsp;</p>
<p>2) Use the following code (Note this code can easily be refactored to be more efficient):</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$(&quot;form input&quot;).keypress(function (e) {<br />
if ((e.which &amp;&amp; e.which == 13) || (e.keyCode &amp;&amp; e.keyCode == 13)) {<br />
//if the search has text then submit that button first<br />
if ($('.buttondefault').length &gt; 0) {<br />
$('.buttondefault').click();<br />
return false;<br />
}<br />
$('#myMasterButtonClass input[type=submit]').click();<br />
return false;<br />
} else {<br />
return true;<br />
}<br />
});</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2011/05/06/handling-multiple-submit-buttons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Detect when a session has ended ASP.NET</title>
		<link>http://blog.codelab.co.nz/2010/06/30/detect-when-session-ended/</link>
		<comments>http://blog.codelab.co.nz/2010/06/30/detect-when-session-ended/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 03:32:02 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=259</guid>
		<description><![CDATA[A problem that I have had in the past is trying to find out when a session has expired within ASP.NET and how to deal with the expired session.   One solution is to add the following code into the Page_Init event.   You can add this event into a class that inherits the Page class so [...]]]></description>
			<content:encoded><![CDATA[<p>A problem that I have had in the past is trying to find out when a session has expired within ASP.NET and how to deal with the expired session.   One solution is to add the following code into the Page_Init event.   You can add this event into a class that inherits the Page class so that you can reuse on more than one page or all pages if needed.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">If Not Context.Session Is Nothing Then<br />
If Session.IsNewSession Then<br />
Dim szCookieHeader As String = Request.Headers(&quot;Cookie&quot;)<br />
If Not String.IsNullOrEmpty(szCookieHeader) And szCookieHeader.IndexOf(&quot;ASP.NET_SessionId&quot;) &amp;gt;= 0 Then<br />
Response.Redirect(&quot;/sessiontimeoutpage.aspx&quot;)<br />
End If<br />
End If<br />
End If</div></div>
<p>This code checks if a new session has been created and if the header has a ASP.NET Session id.   This makes sure that we are checking for a session that has just been created.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2010/06/30/detect-when-session-ended/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Could not load file or assembly &#8216;NameOfAssemblyGoesHere&#8217;</title>
		<link>http://blog.codelab.co.nz/2010/06/11/247/</link>
		<comments>http://blog.codelab.co.nz/2010/06/11/247/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 04:46:00 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=247</guid>
		<description><![CDATA[Encounted the following error: Could not load file or assembly &#8216;NameOfAssemblyGoesHere&#8217; or one of its dependencies. An attempt was made to load a program with an incorrect format. The problem happened when deploying a web application to a 64bit server where all the required DLL&#8217;s where marked as running only on a 32bit system.   You [...]]]></description>
			<content:encoded><![CDATA[<p>Encounted the following error:</p>
<blockquote><p>Could not load file or assembly &#8216;NameOfAssemblyGoesHere&#8217; or  one of its dependencies. An attempt was made to load a program with an  incorrect format.</p></blockquote>
<p>The problem happened when deploying a web application to a 64bit server where all the required DLL&#8217;s where marked as running only on a 32bit system.   You can change this by setting the target platform to AnyCPU which will solve this issue.   There is another workaround which is setting IIS compatability mode to 32bit, Open a command prompt and navigate to the  %systemdrive%\Inetpub\AdminScripts directory.  Type in the command cscript.exe adsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 “true”.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2010/06/11/247/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change username in ASP.NET Membership Provider</title>
		<link>http://blog.codelab.co.nz/2010/05/31/change-username-in-asp-net-membership-provider/</link>
		<comments>http://blog.codelab.co.nz/2010/05/31/change-username-in-asp-net-membership-provider/#comments</comments>
		<pubDate>Sun, 30 May 2010 22:11:33 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=240</guid>
		<description><![CDATA[Found a great article here about the process of changing the username with the ASP.NET Membership Provider. Here is a summary of the process that I found best useful which is one of the comments: 1. Make sure New UserName is Unique 2. Update the aspnet_Users table directly 3. Execute to following code to change [...]]]></description>
			<content:encoded><![CDATA[<p>Found a great article <a href="http://omaralzabir.com/how_to_change_user_name_in_asp_net_2_0_membership_provider/">here </a>about the process of changing the username with the ASP.NET Membership Provider.</p>
<p>Here is a summary of the process that I found best useful which is one of the comments:</p>
<p>1. Make sure New UserName is Unique</p>
<p>2. Update the aspnet_Users table directly</p>
<p>3. Execute to following code to change the username/cookie/identity  without leaving the webpage…</p>
<p>&#8216; Obtains the name of the FormsAuthentication Cookie, uses that name  to request the Cookie and Decrypts the Cookies information into a  AuthTicket</p>
<p>Dim AuthTicket As FormsAuthenticationTicket =  FormsAuthentication.Decrypt(HttpContext.Current.Request.Cookies(FormsAuthentication.FormsCookieName).Value)</p>
<p>&#8216; Instantiates a new user identity authenticated using forms  authentication based on the FormsAuthenticationTicket.</p>
<p>&#8216; The FormsAuthenticationTicket has been created using the exact same  parameters of the user with the Old Username except the Old Username  has been updated with the New Username.</p>
<p>Dim NewFormsIdentity As New FormsIdentity(New  FormsAuthenticationTicket(AuthTicket.Version, NewUsername,  AuthTicket.IssueDate, AuthTicket.Expiration, AuthTicket.IsPersistent,  AuthTicket.UserData))</p>
<p>&#8216; Parse out the AuthTicket&#8217;s UserData into a string array of Roles</p>
<p>Dim Roles As String() = AuthTicket.UserData.Split(“|”.ToCharArray)</p>
<p>&#8216; Creates a new user that has the NewFormsIdentity and belongs to the  array of Roles, if any, that was stored in the  FormsAuthenticationTicket</p>
<p>Dim NewGenericPrincipal As New  System.Security.Principal.GenericPrincipal(NewFormsIdentity, Roles)</p>
<p>&#8216; Sets the security information for the current HTTP request to the  new user.  The Username has now been changed (i.e.  HttpContext.Current.User.Identity.Name = NewUsername, prior to this step  is was the OldUsername)</p>
<p>HttpContext.Current.User = NewGenericPrincipal</p>
<p>&#8216; Removes the forms-authentication ticket from the browser</p>
<p>FormsAuthentication.SignOut()</p>
<p>&#8216; Cancels the current session</p>
<p>HttpContext.Current.Session.Abandon()</p>
<p>&#8216; Creates an authentication ticket for the supplied New Username and  adds it to the cookies collection of the response or the URL</p>
<p>FormsAuthentication.SetAuthCookie(HttpContext.Current.User.Identity.Name,  AuthTicket.IsPersistent)</p>
<p>4. Response.Redirect back to the same page if needed.</p>
<p><em><strong>References:</strong></em></p>
<p><a href="http://omaralzabir.com/how_to_change_user_name_in_asp_net_2_0_membership_provider/">http://omaralzabir.com/how_to_change_user_name_in_asp_net_2_0_membership_provider/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2010/05/31/change-username-in-asp-net-membership-provider/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A way around page refreshes/back button problems with a simple concept</title>
		<link>http://blog.codelab.co.nz/2010/05/17/a-way-around-page-refreshesback-button-problems-with-a-simple-concept/</link>
		<comments>http://blog.codelab.co.nz/2010/05/17/a-way-around-page-refreshesback-button-problems-with-a-simple-concept/#comments</comments>
		<pubDate>Mon, 17 May 2010 09:58:24 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Coding Practices]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=231</guid>
		<description><![CDATA[The problem: You have a form in which the user fills out and clicks a &#8220;submit&#8221; button that validates their input, does some processing and output&#8217;s some results. The problem being the application needs to cater for page refreshes, back buttons and the case of the page being submitted more than once (latency/slow internet connection). [...]]]></description>
			<content:encoded><![CDATA[<p><em>The problem:</em></p>
<p>You have a form in which the user fills out and clicks a &#8220;submit&#8221; button that validates their input, does some processing and output&#8217;s some results. The problem being the application needs to cater for page refreshes, back buttons and the case of the page being submitted more than once (latency/slow internet connection).</p>
<p><em>The Solution:</em></p>
<p>Possible solutions can be (<em>this assumes not using Ajax as a solution</em>), once the user clicks the submit button the server validates the user&#8217;s input and has processed the information. Store a unique id in session and redirect to a &#8220;complete&#8221; page. If the user clicks the back button and resubmits the page, you can build logic to check if a unique id exists in session and if it does, redirect to the complete page without having to re-process the information.</p>
<p>If the user is on the complete page and refreshes the page, because its on a page which has used a GET, there is no processing done and hence no duplication of data.</p>
<p><strong><em>References:</em></strong></p>
<p><a href="http://en.wikipedia.org/wiki/Post/Redirect/Get">http://en.wikipedia.org/wiki/Post/Redirect/Get</a></p>
<p><a href="http://stackoverflow.com/questions/665399/how-do-i-stop-the-back-and-refresh-buttons-from-resubmitting-my-form">http://stackoverflow.com/questions/665399/how-do-i-stop-the-back-and-refresh-buttons-from-resubmitting-my-form</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2010/05/17/a-way-around-page-refreshesback-button-problems-with-a-simple-concept/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DateTime.ToString()</title>
		<link>http://blog.codelab.co.nz/2009/11/05/datetime-tostring/</link>
		<comments>http://blog.codelab.co.nz/2009/11/05/datetime-tostring/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 23:02:03 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=148</guid>
		<description><![CDATA[Here is a link that is useful as a reference for DateTime.ToString patterns References: http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm]]></description>
			<content:encoded><![CDATA[<p>Here is a link that is useful as a reference for DateTime.ToString patterns</p>
<p>References:</p>
<p><a href="http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm">http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2009/11/05/datetime-tostring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

