<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.dotnetmafia.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Corey Roth [MVP] : ASP.NET</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/ASP.NET/default.aspx</link><description>Tags: ASP.NET</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>301 Redirects in .NET 4.0</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/08/28/301-redirects-in-net-4-0.aspx</link><pubDate>Fri, 28 Aug 2009 14:46:48 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:960</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=960</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/08/28/301-redirects-in-net-4-0.aspx#comments</comments><description>&lt;p&gt;I posted in the past how to do a simple search engine friendly redirect using the &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/03/26/search-engine-friendly-redirect.aspx"&gt;301 HTTP status code&lt;/a&gt;.&amp;#160; I thought this was always something that needed to be included in the framework and it looks like it finally will be in .NET 4.0.&amp;#160; I saw this mentioned in &lt;a href="http://weblogs.asp.net/scottgu/archive/2009/08/27/multi-targeting-support-vs-2010-and-net-4-series.aspx"&gt;Scottgu’s&lt;/a&gt; post about multi-targeting and thought it was worth mentioning today since I have posted on it in the past.&amp;#160; To do a 301 redirect, use the new &lt;em&gt;RedirectPermanent()&lt;/em&gt; method on the response object.&amp;#160; It takes the same parameters as the Redirect() method.&amp;#160; Here is what it would look like.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Response.RedirectPermanent(“/SomeOtherPage.aspx”);&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;This type of redirect obviously doesn’t really matter for internal sites, but for public facing sites, if you are relying on a redirect somewhere, it is best to do it with a 301 as the search engines don’t really care for the standard 302 redirect.&amp;#160; At least they didn’t at one time.&amp;#160; I am not SEO expert.&lt;/p&gt;  &lt;p&gt;Follow me on &lt;a href="http://twitter.com/coreyroth"&gt;twitter&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=960" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Cutting+Edge/default.aspx">Cutting Edge</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/.NET+4.0/default.aspx">.NET 4.0</category></item><item><title>Compilation Error with Generic Handler in Visual Studio 2008</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/07/27/compilation-error-with-generic-handler-in-visual-studio-2008.aspx</link><pubDate>Mon, 27 Jul 2009 22:04:27 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:940</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=940</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/07/27/compilation-error-with-generic-handler-in-visual-studio-2008.aspx#comments</comments><description>&lt;p&gt;Anyone else out there notice that if you add an generic handler to your project that it won’t compile?&amp;#160; It appears to be an issue with the template included in Visual Studio and it may have been resolved in a service pack but currently I don’t think so.&amp;#160; The file type I am describing is the .ashx generic handler and not the ASP.NET Handler as you can see below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/GenericHandler_4A06CD67.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="GenericHandler" border="0" alt="GenericHandler" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/GenericHandler_thumb_622A37C2.png" width="476" height="279" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;After it creates the file you might immediately notice there are issues.&amp;#160; If you go to compile it, you’ll get errors like seen below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/GenericHandlerError_6EB7E4DE.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="GenericHandlerError" border="0" alt="GenericHandlerError" src="http://www.dotnetmafia.com/blogs/dotnettipoftheday/GenericHandlerError_thumb_26F65BF7.png" width="715" height="63" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Luckily, resolving the error is quite easy.&amp;#160; You just need to add System.Web.Services to your using block.&amp;#160; Once you do that, you can compile successfully and begin building your handler.&amp;#160; I just thought I would point this out since I have seen this on multiple systems now.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=940" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category></item><item><title>Troubleshooting the DelegateControl</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/04/02/troubleshooting-the-delegatecontrol.aspx</link><pubDate>Thu, 02 Apr 2009 17:28:03 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:882</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=882</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/04/02/troubleshooting-the-delegatecontrol.aspx#comments</comments><description>&lt;p&gt;I’ve have been using SharePoint’s &lt;a href="http://msdn.microsoft.com/en-us/library/ms470880.aspx"&gt;DelegateControl&lt;/a&gt; a lot again lately.&amp;#160; If you are not familiar with it, it allows you to drop a placeholder on a page and then later specify what control goes in it by activating a feature.&amp;#160; You can effectively use it as an alternative to the &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/30/how-to-build-your-own-smartpart-control.aspx"&gt;SmartPart&lt;/a&gt; for putting user control’s on pages when you are deploying custom pages (i.e.: in a site definition or via publishing).&amp;#160; However, one thing I have discovered is that if something goes wrong with the delegate control, there is absolutely zero feedback on the page to let you know that your control could not be loaded.&amp;#160; It simply just displays the page without your control.&amp;#160; &lt;/p&gt;  &lt;p&gt;This is pretty annoying, but it is pretty easy to figure out what the issue is.&amp;#160; As I have said many times in the past, the LOGS folder in the 12 hive is your friend.&amp;#160; Most issues you have in SharePoint can be resolved by taking a look at this folder.&amp;#160; For my latest issue, I opened up the latest log file, to find the following entries.&lt;/p&gt;  &lt;p&gt;04/01/2009 14:56:21.98&amp;#160; w3wp.exe (0x6DA4)&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 0x6980 Windows SharePoint Services&amp;#160;&amp;#160;&amp;#160; General&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 8e1n High&amp;#160;&amp;#160;&amp;#160;&amp;#160; Failed to create a user control from virtual path &amp;#39;/_ControlTemplates/MyControls/MyControl.ascx&amp;#39;: Type &amp;#39;System.Web.UI.WebControls.ListView&amp;#39; does not have a public property named &amp;#39;ItemSeperatorTemplate&amp;#39;.&amp;#160; &lt;/p&gt;  &lt;p&gt;As you can see in my case, I was stupid and misspelled ItemSeparatorTemplate on my &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/07/02/hate-repeaters-try-a-listview.aspx"&gt;ListView&lt;/a&gt; control.&amp;#160; This caused my control to throw a runtime exception.&amp;#160; In a way I guess you can argue that this is nice, because the DelegateControl caught the exception and the entire page didn’t die with a yellow screen.&amp;#160; However, it would be nice if the error could be reported without having to dig through the LOGS folder.&amp;#160; Just remember any unhandled exception your user control might throw will cause the delegate control to display nothing.&amp;#160; If you want more information on the DelegateControl, &lt;a href="http://msdn.microsoft.com/en-us/library/ms470880.aspx"&gt;MSDN&lt;/a&gt; has some decent information on it.&lt;/p&gt;  &lt;p&gt;Follow me on &lt;a href="http://twitter.com/coreyroth"&gt;twitter&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=882" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>Introduction to SharePoint Development: Deploy a User Control in SharePoint</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/11/18/introduction-to-sharepoint-development-deploy-a-user-control-in-sharepoint.aspx</link><pubDate>Tue, 18 Nov 2008 20:07:58 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:780</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=780</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/11/18/introduction-to-sharepoint-development-deploy-a-user-control-in-sharepoint.aspx#comments</comments><description>&lt;p&gt;A common question I get with new SharePoint developers is &amp;quot;How do I deploy my user control in SharePoint?&amp;quot;.&amp;nbsp; Many times they know of the &lt;a href="http://www.codeplex.com/smartpart"&gt;SmartPart&lt;/a&gt; or even how to &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/30/how-to-build-your-own-smartpart-control.aspx"&gt;make their own&lt;/a&gt;, but its the matter of deploying things that may not be clear.&amp;nbsp; Before starting this, you need to read how to &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/22/intro-to-sharepoint-development-how-to-build-and-deploy-a-web-part.aspx"&gt;build and deploy a web part&lt;/a&gt;.&amp;nbsp; Many of the concepts in that article are used here and explained in more detail.&lt;/p&gt; &lt;p&gt;To build a user control, you start in very much the same way as you do with regular ASP.NET.&amp;nbsp; My recommendation is to start by creating a web application project.&amp;nbsp; You can also use a regular class library, but its easier if you use a web application project since it has the file types you need as well as references.&amp;nbsp; If you already have a class library, you can easily convert it to a web application project using a &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/02/22/how-to-hack-a-class-library-project-into-a-web-application-project.aspx"&gt;hack&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Once you have a web application project, create your user control as normal.&amp;nbsp; Build the project and then its time to deploy.&amp;nbsp; We&amp;#39;ll first talk about where the files go on the server and then we&amp;#39;ll look at how we can get the files there with a solution package.&amp;nbsp; Let&amp;#39;s assume, I have a control called MyControl.ascx.&amp;nbsp; This file has to be deployed to the SharePoint server along with its binary.&amp;nbsp; If you are using a SmartPart, the ascx file to go is in a folder called UserControls located in the root of your web sites folder (by default c:\inetpub\wwwroot\wss\VirtualDirectories\80).&amp;nbsp; However with true SharePoint development you have to break the my controls go in X folder on my site way of thinking.&amp;nbsp; In SharePoint, everything is designed to be modular no matter how many web applications your server hosts.&amp;nbsp; &lt;/p&gt; &lt;p&gt;I recommend creating your own web part to host your user control that will work with any folder.&amp;nbsp; SharePoint itself puts all user controls in the &lt;em&gt;CONTROLTEMPLATES &lt;/em&gt;folder in the 12 hive (C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12).&amp;nbsp; You can place your controls here as well, but I recommend creating a subfolder here to keep your controls separate.&amp;nbsp; In this case, I will create a folder called MyControls and copy MyControl.ascx into it.&amp;nbsp; At this point you are probably wondering what is the path to my control if its in the 12 hive?&amp;nbsp; On any SharePoint web application, there is a virtual directory called &lt;em&gt;_controltemplates&lt;/em&gt;.&amp;nbsp; This happens to map to the folder we need.&amp;nbsp; Therefore, the path you would reference in your web part (or any web page) would be &lt;em&gt;~/_controltemplates/MyControls/MyControl.ascx&lt;/em&gt;.&lt;/p&gt; &lt;p&gt;Now, it is just a matter of deploying the binary.&amp;nbsp; In traditional ASP.NET, you could just copy the DLL of your web application project to the bin folder of the web application.&amp;nbsp; However, with SharePoint we can&amp;#39;t do that without specifying &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/07/05/how-to-configure-code-access-security-for-a-web-part.aspx"&gt;Code Access Security&lt;/a&gt; which is a pretty big undertaking when you are starting out.&amp;nbsp; For any file that is in the bin folder, SharePoint requires a security policy be set specifying exactly what permissions your DLL has.&amp;nbsp; I recommend deploying to the bin folder, but if you are just starting out, you don&amp;#39;t want to go there yet.&amp;nbsp; To get around this for now, there are two options: 1) Change the TrustLevel in the web.config to Full or 2) Deploy the DLL to the Global Assembly Cache.&amp;nbsp; I strongly recommend against #1, so for the sake of starting out, just copy your DLL to the GAC.&amp;nbsp; You will need to strongly name your assembly.&amp;nbsp; Any time you copy the DLL to the GAC, you will need to either recycle the application pool that your web application is using or reset IIS.&amp;nbsp; I know that can be a pain, but once you implement CAS, you don&amp;#39;t have to do that any more.&lt;/p&gt; &lt;p&gt;Just like with a web part, you have to add your user control as a safe control.&amp;nbsp; Just specify the assembly name and allowed namespaces.&lt;/p&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;font:13px &amp;#39;courier new&amp;#39;;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;SafeControls&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span&gt;SafeControl&lt;/span&gt;&lt;span style="color:blue;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:red;"&gt;Assembly&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;MyControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=03afd371f1d50a3a&lt;/span&gt;&amp;quot; &lt;span style="color:blue;"&gt;&lt;/span&gt;&lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;MyControls&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:red;"&gt;TypeName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;*&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:red;"&gt;Safe&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;True&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span&gt;SafeControls&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt; &lt;p&gt;At this point you are ready to try your new user control out.&amp;nbsp; To add it to a page like a web part, I recommend you follow the steps in this post to &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/30/how-to-build-your-own-smartpart-control.aspx"&gt;make your own SmartPart&lt;/a&gt;.&amp;nbsp; If you don&amp;#39;t know how to deploy a web part, follow my post on how to &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/22/intro-to-sharepoint-development-how-to-build-and-deploy-a-web-part.aspx"&gt;deploy a web part&lt;/a&gt;.&amp;nbsp; Once you have your smart part added, specify the path I mentioned above (&lt;em&gt;~/_controltemplates/MyControls/MyControl.ascx).&amp;nbsp; &lt;/em&gt;You can also add user controls to your master pages, just like you would in ASP.NET.&amp;nbsp; Just create the reference and add it to the .master. &lt;/p&gt; &lt;p&gt;This may sound like a lot at this point but it&amp;#39;s really not bad.&amp;nbsp; If there is enough interest in the article, I will try and get some code together in one package so people can use it as a starting point.&amp;nbsp; That is how you manually deploy a user control, we&amp;#39;ll move onto how we do it with a solution package.&lt;/p&gt; &lt;h5&gt;Deploying via Solution Package&lt;/h5&gt; &lt;p&gt;For deployment, we will pretty much follow what we did in the deployment of the web part.&amp;nbsp; For more details on building solution packages, please see that &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/22/intro-to-sharepoint-development-how-to-build-and-deploy-a-web-part.aspx"&gt;post&lt;/a&gt;.&amp;nbsp; In this case a feature is not necessary unless you want to automate the deployment of the &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/09/15/using-caml-to-add-web-parts-to-an-existing-page.aspx"&gt;user controls onto an existing page&lt;/a&gt;.&amp;nbsp; The cab.ddf file only contains lines to copy the binary and .ascx file.&lt;/p&gt;&lt;pre&gt;; ** MyControls.wsp  **
.OPTION EXPLICIT     ; Generate errors 
.Set CabinetNameTemplate=MyControls.wsp     
.set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory
.Set CompressionType=MSZIP;** All files are compressed in cabinet files
.Set UniqueFiles=&amp;quot;ON&amp;quot;
.Set Cabinet=on
.Set DiskDirectory1=Package

Solution\manifest.xml manifest.xml

;binaries
bin\MyControls.dll MyControls.dll

;feature files

;template files
MyControl.ascx CONTROLTEMPLATES\MyControls\MyControl.ascx
&lt;/pre&gt;
&lt;p&gt;The Manfiest.xml file will contain entries to copy your ascx file out as well as copy your binary to the GAC.&amp;nbsp; It will also add the Safe Control entry that you need.&amp;nbsp; Here is what the file would look like.&amp;nbsp; The &lt;em&gt;TemplateFile&lt;/em&gt; element is used to specify every .ascx file that you want copied to the server.&amp;nbsp; More details on what you can do with the manifest file are &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/09/04/more-on-manfiest-xml.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Solution&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;SolutionId&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;{FA34A0BE-FEAA-4750-9E82-B313F62C5CF9}&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="color:red;"&gt;xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;ResetWebServer&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;true&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TemplateFiles&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TemplateFile&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Location&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;CONTROLTEMPLATES\MyControls\MyControl.ascx&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TemplateFiles&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Assemblies&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Assembly&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;DeploymentTarget&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;GlobalAssemblyCache&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Location&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;MyControls.dll&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;SafeControls&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;SafeControl&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Assembly&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;MyControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=03afd371f1d50a3a&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Namespace&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;MyControls&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;TypeName&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;*&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;Safe&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;True&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;SafeControls&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Assembly&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Assemblies&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Solution&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;At this point, you build and deploy the .wsp file as described in &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/22/intro-to-sharepoint-development-how-to-build-and-deploy-a-web-part.aspx"&gt;my web part post&lt;/a&gt;.&amp;nbsp; Again, I strongly recommend reading that post if you are not familiar with any of the deployment steps yet.&amp;nbsp; The nice thing about having your user control in a solution package is that it is now completely portable.&amp;nbsp; It can be deployed to your other SharePoint servers very easily.&amp;nbsp; Once you have mastered the process, I recommend you start deploying your binaries to the bin folder with &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/07/05/how-to-configure-code-access-security-for-a-web-part.aspx"&gt;Code Access Security&lt;/a&gt;.&amp;nbsp; Once you have the solution package built, adding CAS is pretty easy and it saves you from having to kill your app pool every time you do a deployment.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=780" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Deployment/default.aspx">Deployment</category></item><item><title>Updating Data with LINQ to SQL and GridViews when using a View</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/07/updating-data-with-linq-to-sql-and-gridviews-when-using-a-view.aspx</link><pubDate>Tue, 07 Oct 2008 18:27:59 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:728</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=728</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/10/07/updating-data-with-linq-to-sql-and-gridviews-when-using-a-view.aspx#comments</comments><description>&lt;p&gt;Look! It&amp;#39;s a post that isn&amp;#39;t about SharePoint!&amp;nbsp; Today, I want to talk about some of the issues I have run into when trying to update data using a GridView when bound to a LinqDataSource.&amp;nbsp; This data source has an &lt;em&gt;EnableUpdate&lt;/em&gt; property, but unfortunately there is more to it than just that.&amp;nbsp; It works pretty well, but there are a few things that you have to do otherwise you will get the following error.&lt;/p&gt; &lt;p&gt;&lt;em&gt;The Entity is not of the correct type.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;In today&amp;#39;s example, I required a stored procedure to do the update because I was updating multiple tables behind the scenes.&amp;nbsp; Although LINQ can do this, the complexity of the update was simpler if I did it via stored procedure.&amp;nbsp; The data I am displaying in my GridView is based off a database view.&amp;nbsp; The first thing to do is drag the View into your LINQ to SQL class.&amp;nbsp; You need to make sure your view includes a primary key.&amp;nbsp; You then need to select the column and mark it as a Primary Key in the LINQ to SQL designer.&amp;nbsp; After you have your view defined, drag the stored procedure for your update into the designer.&amp;nbsp; Then on the properties of your view&amp;#39;s data class, you can set a default method for Insert, Update, and Delete.&amp;nbsp; In this case I am only worrying about Update.&amp;nbsp; If you click on Update, it will bring up a &lt;em&gt;Configure Behavior &lt;/em&gt;window which will allow give you two choices.&amp;nbsp; &lt;em&gt;Use Runtime &lt;/em&gt;will dynamically generate the CRUD logic at runtime.&amp;nbsp; In our case though, we will choose Customize and then pick our stored procedure out of the list.&lt;/p&gt; &lt;p&gt;After you have selected an update method, your LINQ to SQL class is good to go.&amp;nbsp; You are now ready to build your page.&amp;nbsp; Start by dragging a GridView and LinqDataSource onto your page.&amp;nbsp; On your LinqDataSource, set the EnableUpdate property to true.&amp;nbsp; Use the wizard to bind your LINQ to SQL database.&amp;nbsp;&amp;nbsp; Pick the Entity named after your view but when configuring columns be sure and choose all columns (*).&amp;nbsp; If you select individual columns, it populates the &lt;em&gt;Select &lt;/em&gt;property on the LinqDataSource and you will not be able to make updates.&amp;nbsp; At this point, you can bind your GridView to your LinqDataSource.&amp;nbsp; If you have followed all of the steps so far, the Enable Editing option should be available for you to check.&amp;nbsp; Check it and then the last thing you have to do is set the &lt;em&gt;DataKeyNames&lt;/em&gt; property on the GridView.&amp;nbsp; Set it to the name of your primary key and you should be ready to make updates using&amp;nbsp; a GridView.&lt;/p&gt; &lt;p&gt;I always find that I spend more time than I care to setting up GridViews.&amp;nbsp; Hopefully this will help if you ever need to use LINQ to SQL with a GridView.&amp;nbsp; Also don&amp;#39;t forget &lt;a href="http://techfests.com/Tulsa/2008/default.aspx"&gt;Tulsa TechFest&lt;/a&gt; this week where I will be talking about &lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/09/02/speaking-at-tulsa-tech-fest-again.aspx"&gt;Code Access Security in SharePoint&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=728" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/LINQ+to+SQL/default.aspx">LINQ to SQL</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/C_2300_+3.0/default.aspx">C# 3.0</category></item><item><title>How to: Use LINQ to SQL without using the Object Relational Designer</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/03/17/how-to-use-linq-to-sql-without-using-the-object-relational-designer.aspx</link><pubDate>Tue, 18 Mar 2008 00:54:20 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:537</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=537</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/03/17/how-to-use-linq-to-sql-without-using-the-object-relational-designer.aspx#comments</comments><description>&lt;p&gt;LINQ to SQL has already proved to be extremely easy to use to create object relational mappings when you have an existing database schema using the Object Relational Designer.&amp;nbsp; This designer is good, but you may not want something that is autogenerating your domain classes.&amp;nbsp; You may want to generate your domain classes yourself.&amp;nbsp; This is actually quite easy and works in a similar manner to other OR/Ms such as ActiveRecord.&amp;nbsp; The thing I like about it is that your domain objects do not have to inherit from some base class that has all of the underlying logic to access the database.&amp;nbsp; Instead you create a custom class separate from your domain objects that inherits from DataContext.&lt;/p&gt; &lt;p&gt;We&amp;#39;ll create a simple example of a products table for an e-Commerce web site.&amp;nbsp; Let&amp;#39;s start by looking at the domain object.&amp;nbsp; Before you create your domain object start by adding a reference to &lt;em&gt;System.Data.Linq&lt;/em&gt; to your class library if it is not already present.&amp;nbsp; You will then need to add a using statement in each domain class for &lt;em&gt;System.Data.Linq.Mapping&lt;/em&gt;.&lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;[&lt;span style="color:#2b91af;"&gt;Table&lt;/span&gt;(Name=&lt;span style="color:#a31515;"&gt;&amp;quot;Products&amp;quot;&lt;/span&gt;)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Product&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;{&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color:#2b91af;"&gt;Column&lt;/span&gt;]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; Name;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color:#2b91af;"&gt;Column&lt;/span&gt;(IsPrimaryKey=&lt;span style="color:blue;"&gt;true&lt;/span&gt;, Name=&lt;span style="color:#a31515;"&gt;&amp;quot;Id&amp;quot;&lt;/span&gt;)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; ProductId;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color:#2b91af;"&gt;Column&lt;/span&gt;(Name=&lt;span style="color:#a31515;"&gt;&amp;quot;Price&amp;quot;&lt;/span&gt;)]&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;double&lt;/span&gt; Price;&lt;/p&gt; &lt;p style="margin:0px;"&gt;}&lt;/p&gt;&lt;/div&gt; &lt;p&gt;The first thing you do in your domain class is decorate it with a &lt;strong&gt;Table&lt;/strong&gt; attribute.&amp;nbsp; An optional parameter here specifies the name of the underlying database table.&amp;nbsp; In this case my domain object it Product but my database table is named Products.&amp;nbsp; I then defined three properties representing columns in the table.&amp;nbsp; The &lt;strong&gt;Column&lt;/strong&gt; attribute specifies that the property will have a corresponding column in a database table.&amp;nbsp; The &lt;em&gt;IsPrimaryKey&lt;/em&gt; parameter specifies that the column is a primary key in the database.&amp;nbsp; The &lt;em&gt;Name&lt;/em&gt; parameter here also allows you to specify a different column name in the database.&lt;/p&gt; &lt;p&gt;That is really all that is required to create a domain object.&amp;nbsp; You can define a class for each domain object you want and you can also create relations between them (but I won&amp;#39;t be covering that here today).&amp;nbsp; Once you have your domain object created, you will need to create a DataContext class to actually be able to query your domain objects.&amp;nbsp; This is also pretty simple.&amp;nbsp; You just expose a property with the generic type of Table&amp;lt;&amp;gt; for each one of your domain objects.&amp;nbsp; The name of the property is what you will use with the DataContext when you are querying with LINQ.&lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;StoreDataContext&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;DataContext&lt;/span&gt;&lt;/p&gt; &lt;p style="margin:0px;"&gt;{&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Table&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Product&lt;/span&gt;&amp;gt; Products;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; StoreDataContext(&lt;span style="color:blue;"&gt;string&lt;/span&gt; connection)&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;span style="color:blue;"&gt;base&lt;/span&gt;(connection)&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt; &lt;p style="margin:0px;"&gt;}&lt;/p&gt;&lt;/div&gt; &lt;p&gt;Now that you have your domain objects written you will need to create the SQL tables that they represent.&amp;nbsp; You can do this manually, or you can have LINQ create the whole database for you.&amp;nbsp; Just create an instance of your DataContext and call the &lt;em&gt;CreateDatabase&lt;/em&gt; method.&amp;nbsp; This method infers the name of the database given the connection string you used.&amp;nbsp; If you did not specify the database, you need to add a &lt;strong&gt;Database&lt;/strong&gt; attribute with the name to your class.&lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;StoreDataContext&lt;/span&gt; myDataContext = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;StoreDataContext&lt;/span&gt;(myConnectionString);&lt;/p&gt; &lt;p style="margin:0px;"&gt;myDataContext.CreateDatabase();&lt;/p&gt;&lt;/div&gt; &lt;p&gt;Alright, so now your domain objects and database are created, now you just need to query something with it.&lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;var&lt;/span&gt; products = &lt;span style="color:blue;"&gt;from&lt;/span&gt; product &lt;span style="color:blue;"&gt;in&lt;/span&gt; myDataContext.Products&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;where&lt;/span&gt; product.Price &amp;gt; 49.99f&lt;/p&gt; &lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;select&lt;/span&gt; product;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;This simple query simply returns any product with a price greater than 49.99.&amp;nbsp; So, LINQ to SQL doesn&amp;#39;t have to be completely domain driven.&amp;nbsp; This gives you a lot of flexibility and makes it easy to add additional things to your domain logic if you want to.&amp;nbsp; The downside to this of course it that, when your database schema changes, your domain object is not going to get updated at the click of a button.&amp;nbsp; If you are building your domain objects in this manner though, this is probably not a concern to you though.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=537" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/LINQ+to+SQL/default.aspx">LINQ to SQL</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/C_2300_+3.0/default.aspx">C# 3.0</category></item><item><title>How to: Hack a Class Library Project into a Web Application Project</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/02/22/how-to-hack-a-class-library-project-into-a-web-application-project.aspx</link><pubDate>Fri, 22 Feb 2008 20:09:24 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:511</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=511</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/02/22/how-to-hack-a-class-library-project-into-a-web-application-project.aspx#comments</comments><description>&lt;p&gt;Kind of a weird tip here, but I have ran into a situation where I have needed to do this.&amp;nbsp; Basically, I have had an existing class library (for SharePoint development) and for some reason, I have decided I need to add ASP.NET file types to it (i.e. User Controls, Master Pages, etc.).&amp;nbsp; A class library doesn&amp;#39;t have these file types in the Add Item menu so you need a Web Application Project. When it comes down to it a Web Application Project really is the same thing as a class library, it just has some extra settings.&amp;nbsp; So when it comes down to it, you would either have to recreate the project and add your existing files back into it or just hack the XML of your .csproj file.&amp;nbsp; I obviously prefer the latter.&lt;/p&gt; &lt;p&gt;To do this, start by Unloading the Project by right clicking your project and choosing &lt;em&gt;Unload Project&lt;/em&gt;.&amp;nbsp; Next Right click on your unloaded project and choose &lt;em&gt;Edit &amp;lt;PrjectName&amp;gt;.csproj&lt;/em&gt;.&amp;nbsp; Paste the line below in the first ProjectGroup element.&amp;nbsp; Usually Visual Studio puts it underneath the ProjectGuid element.&amp;nbsp; &lt;/p&gt; &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new;"&gt; &lt;p style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ProjectTypeGuids&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;ProjectTypeGuids&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;p&gt;That is the only change that is required.&amp;nbsp; There are some optional settings that you can put in regarding the configuration of Cassini, but none of them are required to get you going.&amp;nbsp; You can always configure them in Visual Studio.&amp;nbsp; Once you have made the change, save the .csproj file and Reload Project.&amp;nbsp; Once the project is loaded, all of the ASP.NET file types will be present in your Add Item menu.&amp;nbsp; When you compile, it will still compile everything down to a single DLL and you can deploy it just as if it was a regular class library.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=511" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category></item><item><title>SPSqlDataSource: This control does not allow connection strings with the following keywords: ‘Integrated Security’, ‘Trusted_Connection’.</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/02/11/spsqldatasource-this-control-does-not-allow-connection-strings-with-the-following-keywords-integrated-security-trusted-connection.aspx</link><pubDate>Mon, 11 Feb 2008 16:28:00 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:482</guid><dc:creator>CoreyRoth</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=482</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/02/11/spsqldatasource-this-control-does-not-allow-connection-strings-with-the-following-keywords-integrated-security-trusted-connection.aspx#comments</comments><description>&lt;p&gt;I ran into this one again lately when deploying.&amp;nbsp; We are folowing best practices with our connection strings by using Integrated Security.&amp;nbsp; We have several controls on the web site making use of SqlDataSource controls.&amp;nbsp; However, at runtime, we are left when an error like the following.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Microsoft.SharePoint.WebPartPages.DataSourceControlDisabledException: This control does not allow connection strings with the following keywords: ‘Integrated Security’, ‘Trusted_Connection’.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This is because SharePoint puts a tagMapping in the web.config that maps the ASP.NET SqlDataSource to its SPSqlDataSource.&amp;nbsp; Why it does this, I have no idea?&amp;nbsp; If I check the SDK on that class, there is not so much as even a description of what the class does (come on Microsoft, you still need to work on this SDK documentation).&amp;nbsp; A workaround is actually pretty simple, remove the tagMapping.&amp;nbsp; However, you can&amp;#39;t just simply delete the line, you must use the remove element to get rid of it.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;lt;remove tagType=&amp;quot;System.Web.UI.WebControls.SqlDataSource, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&amp;quot; /&amp;gt;&lt;/p&gt;
&lt;p&gt;This will allow the control to work, but you also need to register the ASP.NET SqlDataSource as a safe control.&amp;nbsp; You know the syntax, but here it is in case to make it easy.&lt;/p&gt;
&lt;p&gt;&amp;lt;SafeControl Assembly=&amp;quot;System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&amp;quot; Namespace=&amp;quot;System.Web.UI.WebControls&amp;quot; TypeName=&amp;quot;SqlDataSource&amp;quot; Safe=&amp;quot;True&amp;quot; AllowRemoteDesigner=&amp;quot;False&amp;quot; /&amp;gt;&lt;/p&gt;
&lt;p&gt;That is all it takes and everything inside SharePoint still seems to work.&amp;nbsp; My point of today&amp;#39;s post is to put out the following questions.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;What is the purpose of this inherited control?&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Why on earth would it not support integrated security?&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Why does the SDK documentation continue to leave out details about key classes?&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;If you have the answer to any of those, please leave a comment.&lt;/p&gt;&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=482" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/SharePoint/default.aspx">SharePoint</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Error/default.aspx">Error</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>Binding a GridView to a Generic List of Primitives</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/09/21/binding-a-gridview-to-a-generic-list-of-primitives.aspx</link><pubDate>Fri, 21 Sep 2007 20:00:18 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:29</guid><dc:creator>C-Dog's .NET Tip of the Day</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=29</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/09/21/binding-a-gridview-to-a-generic-list-of-primitives.aspx#comments</comments><description>I have often bound GridViews to my own custom objects. However today, I needed to bind a GridView to a List&amp;lt;string&amp;gt;. I needed to customize the columns a bit and I soon realized I did not know what to specify as a DataField. I tried Item and just...(&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/09/21/binding-a-gridview-to-a-generic-list-of-primitives.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=29" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>How to expand a TreeView to the current page when using a SiteMapProvider</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/07/25/how-to-expand-a-treeview-to-the-current-page-when-using-a-sitemapprovider.aspx</link><pubDate>Wed, 25 Jul 2007 13:59:23 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:39</guid><dc:creator>C-Dog's .NET Tip of the Day</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=39</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/07/25/how-to-expand-a-treeview-to-the-current-page-when-using-a-sitemapprovider.aspx#comments</comments><description>Ok, well I started writing this post yesterday and somehow I accidently closed my browser and lost the entire contents of the post, so here I am at it trying it again. Lately, I have been working with a TreeView to handle hierarchical naviagation. Specifically...(&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/07/25/how-to-expand-a-treeview-to-the-current-page-when-using-a-sitemapprovider.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=39" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>Hate Repeaters? Try a ListView!</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/07/02/hate-repeaters-try-a-listview.aspx</link><pubDate>Mon, 02 Jul 2007 17:31:44 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:47</guid><dc:creator>C-Dog's .NET Tip of the Day</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.dotnetmafia.com/blogs/dotnettipoftheday/rsscomments.aspx?PostID=47</wfw:commentRss><comments>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/07/02/hate-repeaters-try-a-listview.aspx#comments</comments><description>Repeaters have always been a necessary evil. They are simply the only practical way to do custom formatting when binding to lists of data. Oddly enough, it turns out that not everyone just wants to display a grid of data. In the past, by using the repeater...(&lt;a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/07/02/hate-repeaters-try-a-listview.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=47" width="1" height="1"&gt;</description><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/Cutting+Edge/default.aspx">Cutting Edge</category><category domain="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item></channel></rss>