<?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>Castner IT Blog &#187; IIS</title>
	<atom:link href="http://www.castnerit.com.au/blog/category/iis/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.castnerit.com.au/blog</link>
	<description>ASP.NET, SEO, Small Business IT</description>
	<lastBuildDate>Thu, 12 Jan 2012 21:59:23 +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>Inserting a PayPal Buy Now Button into an ASP.NET Form</title>
		<link>http://www.castnerit.com.au/blog/2008/12/inserting-a-paypal-buy-now-button-into-an-aspnet-form/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=inserting-a-paypal-buy-now-button-into-an-aspnet-form</link>
		<comments>http://www.castnerit.com.au/blog/2008/12/inserting-a-paypal-buy-now-button-into-an-aspnet-form/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 01:22:27 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>

		<guid isPermaLink="false">http://castnerit.com/blog/?p=101</guid>
		<description><![CDATA[When working with ASP.NET pages, one difficulty that often arises is that you need two forms on the page &#8211; the normal form required by ASP.NET and a second form for something else such as a PayPal button or a search tool. The solution that I discovered is to not have two forms but simply [...]]]></description>
			<content:encoded><![CDATA[<p>When working with ASP.NET pages, one difficulty that often arises is that you need two forms on the page &#8211; the normal form required by ASP.NET and a second form for something else such as a PayPal button or a search tool. The solution that I discovered is to not have two forms but simply have one form (the normal one in the master page). It usually only requires some minor changes to the controls in the 2nd form for it to work. For example, here is the adjusted code for a PayPal Buy Now button:<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;cmd&#8221; value=&#8221;_xclick&#8221; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;business&#8221; value=&#8221;<a href="mailto:gcastner@asianfoods.com">gcastner@asianfoods.com</a>&#8221; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;item_name&#8221; value=&#8221;Sweet and sour sauce&#8221;/&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;item_number&#8221; value=&#8221;SAUCE001&#8243; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;amount&#8221; value=&#8221;100.00&#8243; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;no_shipping&#8221; value=&#8221;2&#8243; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;no_note&#8221; value=&#8221;1&#8243; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;currency_code&#8221; value=&#8221;USD&#8221; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;lc&#8221; value=&#8221;US&#8221; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;bn&#8221; value=&#8221;PP-BuyNowBF&#8221; /&gt;<br />
&lt;img alt=&#8221;" style=&#8217;border:0px;&#8217; src=&#8217;<a href="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif">https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif</a>&#8221; width=&#8221;1&#8243; height=&#8221;1&#8243; /&gt;<br />
&lt;asp:Button ID=&#8221;Button2&#8243; runat=&#8221;server&#8221; Text=&#8221;Button&#8221; PostBackUrl=&#8221;<a href="https://www.sandbox.paypal.com/cgi-bin/webscr">https://www.sandbox.paypal.com/cgi-bin/webscr</a>&#8221; /&gt;</p>
<p>The main changes from the PayPal supplied code are the removal of the form tags and the inclusion of the asp:button. The reason for the change is that because ASP.NET pages are already web forms, we cannot simply add a 2nd form into the page (it would cause an error).</p>
<p>Another useful thing is that you can set the default button for the page, or different parts of the page. This example sets the default button when someone presses enter to the login button rather than the search button at the top of the page. You need to enclose the relevant controls in a panel control.</p>
<p>  Protected Sub panelLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles panelLogin.Load</p>
<p>    Page.Form.DefaultFocus = Login1.FindControl(&#8220;UserName&#8221;).UniqueID<br />
    Page.Form.DefaultButton = Login1.FindControl(&#8220;LoginButton&#8221;).UniqueID</p>
<p>  End Sub</p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2008/12/inserting-a-paypal-buy-now-button-into-an-aspnet-form/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft reporting: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.</title>
		<link>http://www.castnerit.com.au/blog/2008/10/microsoft-reporting-failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=microsoft-reporting-failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints</link>
		<comments>http://www.castnerit.com.au/blog/2008/10/microsoft-reporting-failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 13:05:04 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[Small Business Online]]></category>

		<guid isPermaLink="false">http://castnerit.com/blog/?p=87</guid>
		<description><![CDATA[This error was bugging me for a long time until I found this excellent forum discussion: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=541116&#38;SiteId=1 The following points summarize the causes and solutions from the forum and offer some additional help: 1. Check if you have changed the length of any fields in the underlying database table after creating the dataset. If you [...]]]></description>
			<content:encoded><![CDATA[<p>This error was bugging <img src='http://www.castnerit.com.au/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  me for a long time until I found this excellent forum discussion:</p>
<p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=541116&amp;SiteId=1">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=541116&amp;SiteId=1</a></p>
<p>The following points summarize the causes and solutions from the forum and offer some additional help:</p>
<p>1. Check if you have changed the length of any fields in the underlying database table after creating the dataset. If you have, you may need to manually change them in the dataset as well. If you are using Visual Studio 2008, open the xsd file and click on the relevant field name. Ensure the maxlength property matches your new field length.</p>
<div id="attachment_88" class="wp-caption aligncenter" style="width: 310px"><a href="http://castnerit.com/blog/wp-content/uploads/2008/10/clipboard03.jpg"><img class="size-medium wp-image-88" title="Check maxlength property" src="http://castnerit.com/blog/wp-content/uploads/2008/10/clipboard03-300x132.jpg" alt="Check maxlength property" width="300" height="132" /></a><p class="wp-caption-text">Check maxlength property</p></div>
<p>2. If you base your dataset off a view rather than a table, and that view contains a primary key field from the underlying table, visual studio may set unique to true for that field. If your view is constructed in such a way that the field is not unique, then the error will occur. In Visual Studio 2008, open the xsd file, click on the field and set unique to false in properties.</p>
<p>There were other causes of the error but these seemed to be the two most common.</p>
<p>Cheers,<br />
Grant</p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2008/10/microsoft-reporting-failed-to-enable-constraints-one-or-more-rows-contain-values-violating-non-null-unique-or-foreign-key-constraints/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A better way of handling maxRequestLength exceptions</title>
		<link>http://www.castnerit.com.au/blog/2008/10/a-better-way-of-handling-maxrequestlength-exceptions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-better-way-of-handling-maxrequestlength-exceptions</link>
		<comments>http://www.castnerit.com.au/blog/2008/10/a-better-way-of-handling-maxrequestlength-exceptions/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 01:37:17 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>

		<guid isPermaLink="false">http://castnerit.com/blog/?p=85</guid>
		<description><![CDATA[ASP.NET 2 includes the FileUpload control to make it easier to create pages that allow users to upload files. The default maximum file size is 4096 KB to minimize the potential for denial of service attacks. You can change the maximum file size by editing your configuration files (see for example http://msdn2.microsoft.com/en-US/library/system.web.configuration.httpruntimesection.maxrequestlength(VS.80).aspx and http://support.softartisans.com/kbview_825.aspx). The [...]]]></description>
			<content:encoded><![CDATA[<p>ASP.NET 2 includes the FileUpload control to make it easier to create pages that allow users to upload files. The default maximum file size is 4096 KB to minimize the potential for denial of service attacks. You can change the maximum file size by editing your configuration files (see for example <a href="http://msdn2.microsoft.com/en-US/library/system.web.configuration.httpruntimesection.maxrequestlength(VS.80).aspx">http://msdn2.microsoft.com/en-US/library/system.web.configuration.httpruntimesection.maxrequestlength(VS.80).aspx</a> and <a href="http://support.softartisans.com/kbview_825.aspx">http://support.softartisans.com/kbview_825.aspx</a>).</p>
<p>The problem is that when users attempt to upload a file that is too large, it is difficult to capture and handle the exception that is created. The usual try..catch doesn&#8217;t handle the exception because the exception occurs before then. The exception is &#8220;System.Web.HttpException: Maximum request length exceeded&#8221;. You could of course increase the maximum file size but that defeats the purpose of the limit in the first place.</p>
<p>Here is one solution for handling the exception that is at least nicer than the standard ASP.NET exception message:</p>
<p>1. Create a global.asax file. If you&#8217;re using Visual Studio 2005 it will set up a number of common subroutines for you. You need to use Sub Application_Error. Your code should look something like this:</p>
<p>&lt;script runat=&#8221;server&#8221;&gt;<br />
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)<br />
Dim currentException As Exception<br />
currentException = Server.GetLastError.GetBaseException()<br />
Response.Redirect(&#8220;/error.aspx?Err=&#8221; &amp; Server.UrlEncode(currentException.Message))<br />
End Sub<br />
&lt;/script&gt;</p>
<p>The application_Error sub fires as a last resort, in other words, when you haven&#8217;t explicitly handled the exception anywhere else in your code.</p>
<p>2. You can now create an error.aspx that displays the exception message (from the querystring). For this exception the message is &#8220;<span id="ctl00_ContentPlaceHolder1_lblError">Maximum request length exceeded&#8221;. You could also test for the message and give users more information on the error.</span></p>
<p><span>Please let me know if you have any comments, suggestions, or improvements.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2008/10/a-better-way-of-handling-maxrequestlength-exceptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating multiple websites in IIS 6 for student projects</title>
		<link>http://www.castnerit.com.au/blog/2008/10/creating-multiple-websites-in-iis-6-for-student-projects/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creating-multiple-websites-in-iis-6-for-student-projects</link>
		<comments>http://www.castnerit.com.au/blog/2008/10/creating-multiple-websites-in-iis-6-for-student-projects/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 07:09:21 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[CheckBoxList]]></category>

		<guid isPermaLink="false">http://castnerit.com/blog/?p=82</guid>
		<description><![CDATA[Every term I had to create between 100 and 200 web sites for students in my classes. Here are the steps I used to create those site in IIS 6. The student&#8217;s active directory accounts were already set up by our system administrator. I use FrontPage Server Extensions to allow students to transfer files to [...]]]></description>
			<content:encoded><![CDATA[<p>Every term I had to create between 100 and 200 web sites for students in my classes. Here are the steps I used to create those site in IIS 6. The student&#8217;s active directory accounts were already set up by our system administrator. I use FrontPage Server Extensions to allow students to transfer files to the server. Sections in italics below need to be replaced with your settings.</p>
<p>1. Create Directories:</p>
<p>md <em>studentdirectory</em></p>
<p>2. Assign the student user account relevant permissions:</p>
<p>xcacls <em>studentdirectory </em>/T /E /G <em>studentusername:</em>F</p>
<p>3. Create a virtual directory in IIS for each student:</p>
<p>iisvdir /create &#8220;<em>IISsitename</em>&#8221; <em>studentvirtualdirectoryname studentdirectory</em></p>
<p>4. Create a subweb for each student:</p>
<p>&#8220;C:\Program Files\Common Files\Microsoft Shared\web server extensions\50\bin\owsadm&#8221; -o install -p 1100 -w <em>studentvirtualdirectoryname</em> -u <em>usernameWithSufficientPermissionsOnServer</em></p>
<p><em></em>5. Give the new subweb unique permissions:</p>
<p>&#8220;C:\Program Files\Common Files\Microsoft Shared\web server extensions\50\bin\owsadm&#8221; -o setperms -p 1100 -w <em>studentsubwebname</em> -i false -u <em>usernameWithSufficientPermissionsOnServer</em></p>
<p>6. Give the student the author role on the subweb:</p>
<p>&#8220;C:\Program Files\Common Files\Microsoft Shared\web server extensions\50\bin\owsadm&#8221; -o roleusers -command add -u <em>studentusername</em> -p 1100 -w <em>studentsubwebname</em> -name Author</p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2008/10/creating-multiple-websites-in-iis-6-for-student-projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Formatting columns in a GridView</title>
		<link>http://www.castnerit.com.au/blog/2008/08/formatting-columns-in-a-gridview/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=formatting-columns-in-a-gridview</link>
		<comments>http://www.castnerit.com.au/blog/2008/08/formatting-columns-in-a-gridview/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 15:40:18 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[eLearning]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[Monodroid]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>

		<guid isPermaLink="false">http://castnerit.com/blog/?p=64</guid>
		<description><![CDATA[Formatting columns in a GridView is relatively straightforward, once you know the appropriate format string. Here are the steps if you are using Expression Web, Visual Studio, or Visual Web Developer: Open the Task Pane of your GridView and select Edit Columns In the Selected Fields Box, select the column you want to edit Find [...]]]></description>
			<content:encoded><![CDATA[<p>Formatting columns in a GridView is relatively straightforward, <em>once you know the appropriate format string.</em></p>
<p>Here are the steps if you are using Expression Web, Visual Studio, or Visual Web Developer:</p>
<ol>
<li>Open the Task Pane of your GridView and select <strong>Edit Columns</strong></li>
<li>In the <strong>Selected Fields</strong> Box, select the column you want to edit</li>
<li>Find the <strong>HTMLEncode</strong> property and set it to <strong>false.</strong></li>
<li>Find the <strong>DataFormatString</strong> property and set it to the appropriate formatstring. The standard format of a format string is {0:<em>format string</em>}</li>
</ol>
<p>Some examples of format strings are:</p>
<p>{0:c} to format as currency<br />
{0:M-dd-yyyy} to format as a date</p>
<p>For more formatting strings, go to <a href="http://msdn2.microsoft.com/en-us/library/aa720089(VS.71).aspx">Formatting Types</a> on MSDN.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2008/08/formatting-columns-in-a-gridview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting SQL Server newline character to HTML break &lt;br/&gt;</title>
		<link>http://www.castnerit.com.au/blog/2008/07/converting-newline-character-to/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=converting-newline-character-to</link>
		<comments>http://www.castnerit.com.au/blog/2008/07/converting-newline-character-to/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 05:50:17 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[Sausage Sizzle Map]]></category>
		<category><![CDATA[Small Business Online]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[A common scenario (at least for me) is the following: 1. Accept text input into a web form that includes multiline text boxes. The text often includes line breaks. 2. The text is stored in a database such as SQL Server 2005. SQL Server 2005 has no problem storing the line breaks. 3. I then [...]]]></description>
			<content:encoded><![CDATA[<p>A common scenario (at least for me) is the following:</p>
<p>1. Accept text input into a web form that includes multiline text boxes. The text often includes line breaks.<br />
2. The text is stored in a database such as SQL Server 2005. SQL Server 2005 has no problem storing the line breaks.<br />
3. I then display the data in an ASP.NET gridview control. Because the control renders as HTML, it doesn&#8217;t recognize the newline escape characters.</p>
<p>The problem is how to convert the newline characters into &lt;br /&gt;. Here is one solution. It is closely based on this MSDN article: <a href="http://msdn2.microsoft.com/en-us/library/xwewhkd1.aspx">http://msdn2.microsoft.com/en-us/library/xwewhkd1.aspx</a> (regex.replace)</p>
<p>This C# example assumes you are using an ASP.NET FormView with a label called lblSampleText:<br />
<code><br />
//Create a regular expression that matches a newline<br />
string pattern = "\n";<br />
Regex rgx = new Regex(pattern);<br />
//Find the relevant label from the FormView<br />
Label vL1 = checked((Label)FormView1.FindControl("lblSampleText"));<br />
string inputStr = vL1.Text;<br />
//Replace the newline character with br<br />
string outputStr = rgx.Replace(inputStr,"&lt;br/&gt;");<br />
// Display the resulting string<br />
vL1.Text = outputStr;</code></p>
<p>This VB example assumes you are using a GridView with a TemplateField control. Inside the TemplateField control (ItemTemplate) is a label called lblSampleText.</p>
<p><code>Protected Sub GridView3_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView3.RowDataBound<br />
If e.Row.RowType = DataControlRowType.DataRow Then<br />
' Create a regular expression that matches a newline<br />
Dim pattern As String = "\n"<br />
Dim rgx As New Regex(pattern)<br />
' Find the relevant label from the gridview<br />
Dim inputStr As String = CType(e.Row.FindControl("lblSampleText"), Label).Text<br />
' Replace the newline character with &lt;br/&gt;<br />
Dim outputStr As String = rgx.Replace (inputStr, "&lt;br/&gt;")<br />
' Display the resulting string.<br />
CType(e.Row.FindControl("lblSampleText"), Label).Text = outputStr<br />
End If<br />
End Sub<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2008/07/converting-newline-character-to/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Changing the Password Complexity in ASP.NET</title>
		<link>http://www.castnerit.com.au/blog/2008/07/changing-the-password-complexity-in-aspnet/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=changing-the-password-complexity-in-aspnet</link>
		<comments>http://www.castnerit.com.au/blog/2008/07/changing-the-password-complexity-in-aspnet/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 20:55:12 +0000</pubDate>
		<dc:creator>Grant Castner</dc:creator>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[Microsoft Office]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.castnerit.com.au/blog/?p=8</guid>
		<description><![CDATA[Here is a great blog post on how to change the password complexity requirements in ASP.NET: http://weblogs.asp.net/owscott/archive/2005/05/11/406550.aspx]]></description>
			<content:encoded><![CDATA[<p>Here is a great blog post on how to change the password complexity requirements in ASP.NET:<br />
<a href="http://weblogs.asp.net/owscott/archive/2005/05/11/406550.aspx">http://weblogs.asp.net/owscott/archive/2005/05/11/406550.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.castnerit.com.au/blog/2008/07/changing-the-password-complexity-in-aspnet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

