<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>where coding happens ! &#187; Uncategorized</title>
	<atom:link href="http://oricode.wordpress.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://oricode.wordpress.com</link>
	<description>useful coding tips from my everyday experiences</description>
	<lastBuildDate>Tue, 02 Feb 2010 12:28:02 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='oricode.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/4251e25dbc1433381b5511fe333bd7d4?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>where coding happens ! &#187; Uncategorized</title>
		<link>http://oricode.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://oricode.wordpress.com/osd.xml" title="where coding happens !" />
	<atom:link rel='hub' href='http://oricode.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Redirect the user to a custom page when clicking to a document link in a Document Library</title>
		<link>http://oricode.wordpress.com/2010/02/02/redirect-the-user-to-a-custom-page-when-clicking-to-a-document-link-in-a-document-library/</link>
		<comments>http://oricode.wordpress.com/2010/02/02/redirect-the-user-to-a-custom-page-when-clicking-to-a-document-link-in-a-document-library/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 12:28:02 +0000</pubDate>
		<dc:creator>oricode</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oricode.wordpress.com/?p=52</guid>
		<description><![CDATA[
The normal behaviour of Sharepoint when a user click on a document in a Document Library is to download it. Depending on the document type, in will open the default download dialog or it will open it with a client application. However, it is not always like that. There is also, the scenario where the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oricode.wordpress.com&blog=2786525&post=52&subd=oricode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>
The normal behaviour of Sharepoint when a user click on a document in a Document Library is to download it. Depending on the document type, in will open the default download dialog or it will open it with a client application. However, it is not always like that. There is also, the scenario where the user clicks on a document link and the Sharepoint server calls a server page to perform a different action other than simply downloading the file. The best example of this is when a user clicks on a browser-enabled Infopath Form in a Forms Library, in that case, we can see that the user is redirected to a Forms Server page called _layouts/FormServer.aspx and that page is responsible for delivering an html view of the Infopath Form in the client browser&#8230;
</p>
<p><b><br />
Do you want to read more ? I am moving to my new site ! Please follow the link to read all the content of this article: <a href='http://www.oriolardevol.com/Article/Details/18'>Redirect the user to a custom page when clicking to a document link in a Document Library</a><br />
</b></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oricode.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oricode.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oricode.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oricode.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oricode.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oricode.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oricode.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oricode.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oricode.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oricode.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oricode.wordpress.com&blog=2786525&post=52&subd=oricode&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://oricode.wordpress.com/2010/02/02/redirect-the-user-to-a-custom-page-when-clicking-to-a-document-link-in-a-document-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2c244f054dfb41041e2adcc475899fe4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">oricode</media:title>
		</media:content>
	</item>
		<item>
		<title>Sharepoint webpart for Silverlight 2.0</title>
		<link>http://oricode.wordpress.com/2008/03/31/sharepoint-webpart-for-silverlight-20/</link>
		<comments>http://oricode.wordpress.com/2008/03/31/sharepoint-webpart-for-silverlight-20/#comments</comments>
		<pubDate>Mon, 31 Mar 2008 07:12:44 +0000</pubDate>
		<dc:creator>oricode</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Webpart]]></category>

		<guid isPermaLink="false">http://oricode.wordpress.com/?p=16</guid>
		<description><![CDATA[Before the last release of Silverlight 2.0 beta 1 embedding a silverlight application in a webpart was a somewhat tedious thing to do. Basically, you had to deploy your silverlight.dll and .xaml file within your Sharepoint solution as well as a bunch of javascript files that are called from your sharepoint webpart to create your silverlight content.
With [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oricode.wordpress.com&blog=2786525&post=16&subd=oricode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Before the last release of Silverlight 2.0 beta 1 embedding a silverlight application in a webpart was a somewhat tedious thing to do. Basically, you had to deploy your silverlight.dll and .xaml file within your Sharepoint solution as well as a bunch of javascript files that are called from your sharepoint webpart to create your silverlight content.</p>
<p>With the last release of Silverlight 2.0 all this steps are no longer necessary and we can easily host Silverlight Applications in Sharepoint Webparts just by including Silverlight controls and deploying .xap files with our solution.</p>
<p>For this example, I&#8217;ll create a generic webpart that will be able to load any .xap file accessible at our server. It will have a <em>XapUrl</em> property where we will be able to write a Url where the webpart will search for the xap file. Obviously this means that the .xap file must be deployed in our server, I usually do that by including the file in my Sharepoint Solution and deploying it in the <em>_layouts</em> folder of my server.</p>
<p>So following, is the code of my Silverlight Webpart</p>
<pre class="brush: csharp;">

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.WebPartPages;
using System.Web.UI.WebControls.WebParts;
using System.Runtime.InteropServices;
using System.Web.UI;

namespace Examples.SilverLight
{
    public class SilverLightWebpart : System.Web.UI.WebControls.WebParts.WebPart
    {
        private ScriptManager _scriptHandler;
        private System.Web.UI.SilverlightControls.Silverlight _silverlightControl;

        private string _xapUrl = string.Empty;
        [WebBrowsable(true), Personalizable(true)]
        public string XapUrl
        {
            get { return _xapUrl; }
            set { _xapUrl = value; }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            _scriptHandler = ScriptManager.GetCurrent(this.Page);
            if (_scriptHandler == null)
            {
                _scriptHandler = new ScriptManager();
                _scriptHandler.ID = &quot;ScriptManager1&quot;;
                this.Controls.Add(_scriptHandler);
            }

            if (!string.IsNullOrEmpty(_xapUrl))
            {
                _silverlightControl = new System.Web.UI.SilverlightControls.Silverlight();
                _silverlightControl.ID = &quot;Xaml1&quot;;
                _silverlightControl.Source = _xapUrl;
                _silverlightControl.Version = &quot;2.0&quot;;
                this.Controls.Add(_silverlightControl);
            }
        }

    }
}
</pre>
<p>Basically what we are doing is adding a ScriptManager and a Silverlight controls to our class. The only things we have to take care of are to ensure that there is only one instance of a ScriptManager in our current page (we do that with the call <em>ScriptManager.GetCurrent(this.Page);</em>) and that we must create the controls in the <em>OnInit</em> event of our webpart instead of the usual <em>CreateChildControls</em> event if not, we will get an exception from <em>ScriptManager.RegisterScriptControl</em> telling &#8220;<strong>Script controls may not be registered before PreRender</strong>&#8220;</p>
<p>And that&#8217;s all, see how simple is now to host silverlight applications in our sharepoint server !</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/oricode.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/oricode.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oricode.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oricode.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oricode.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oricode.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oricode.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oricode.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oricode.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oricode.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oricode.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oricode.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oricode.wordpress.com&blog=2786525&post=16&subd=oricode&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://oricode.wordpress.com/2008/03/31/sharepoint-webpart-for-silverlight-20/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2c244f054dfb41041e2adcc475899fe4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">oricode</media:title>
		</media:content>
	</item>
		<item>
		<title>Deploy a XML file in your Sharepoint Solution to the Web Application Folder</title>
		<link>http://oricode.wordpress.com/2008/02/27/deploy-a-xml-file-in-your-sharepoint-solution-to-the-web-application-folder/</link>
		<comments>http://oricode.wordpress.com/2008/02/27/deploy-a-xml-file-in-your-sharepoint-solution-to-the-web-application-folder/#comments</comments>
		<pubDate>Wed, 27 Feb 2008 16:58:27 +0000</pubDate>
		<dc:creator>oricode</dc:creator>
				<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Solution]]></category>

		<guid isPermaLink="false">http://oricode.wordpress.com/?p=12</guid>
		<description><![CDATA[This is a small trick I&#8217;ve been using these days in a Sharepoint Solution in order to add a xml file with some data which some webpart will read later on a Sharepoint site and make use of it. There are many ways to accomplish this each one with it&#8217;s benefits and drawbacks.
The first approach [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oricode.wordpress.com&blog=2786525&post=12&subd=oricode&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>This is a small trick I&#8217;ve been using these days in a Sharepoint Solution in order to add a xml file with some data which some webpart will read later on a Sharepoint site and make use of it. There are many ways to accomplish this each one with it&#8217;s benefits and drawbacks.</p>
<p>The first approach I thought of was to deploy the xml file in the _layouts folder and then query the data using a <em>WebClient </em>request from my webpart, the problem I found is that if anonymous access wasn&#8217;t enabled for the site, the request failed with a <em>401 Unauthorized </em>exception because the ASP.Net credentials where the ones used by default to access the resource. One solution was to enable the impersonation at the web.config file of the application and then, the current user&#8217;s credentials would be used instead, but as I didn&#8217;t know where my solution would be deployed and didn&#8217;t have any control over the web.config file configuration, I rejected this approach.</p>
<p>Finally, I decided to deploy locally the xml file in the bin folder of the application and then accessing it with a simple <em>StreamReader</em>. The first problem was how to deploy the file ? Finally, I found the small trick I was talking about, you can deploy any file from a Sharepoint Solution in the <em>bin </em>folder of the web application just by doing the same as you do with a normal assembly .dll file, with the <font size="2" color="#0000ff">&lt;</font><font size="2" color="#a31515">Assembly</font><font size="2" color="#0000ff">&gt;</font> tag in the manifest.xml file:</p>
<p><font size="2" color="#0000ff">&lt;<font size="2" color="#a31515">Assemblies</font><font size="2" color="#0000ff">&gt;&lt;</font><font size="2" color="#a31515">Assembly</font><font size="2" color="#0000ff"> </font><font size="2" color="#ff0000">DeploymentTarget</font><font size="2" color="#0000ff">=</font><font size="2">&#8220;</font><font size="2" color="#0000ff">WebApplication</font><font size="2">&#8220;</font><font size="2" color="#0000ff"> </font><font size="2" color="#ff0000">Location</font><font size="2" color="#0000ff">=</font><font size="2">&#8220;</font><font size="2" color="#0000ff">MyData.xml</font><font size="2">&#8220;</font><font size="2" color="#0000ff"> /&gt;&lt;/</font><font size="2" color="#a31515">Assemblies</font><font size="2" color="#0000ff">&gt;</font></font></p>
<p>When the Solution is deployed, the xml file will be copied to all the <em>bin </em>folders of the selected web application. This raises the obvious drawback of this approach: There&#8217;s one xml file for each web application and there&#8217;s no easy way to globally manage them.<br />
Since we will be accessing the xml file from our webpart, and assuming we haven&#8217;t set our trust level to Full (because we know it&#8217;s a bad thing to do!), we must grant our assembly the<em> FileIOPermission  </em>in order to be able to read the file. We can do this in the manifest.xml with the following section:</p>
<p><font size="2" color="#0000ff"><font size="2" color="#0000ff"><font size="2" color="#0000ff">&lt;<font size="2" color="#a31515">CodeAccessSecurity</font><font size="2" color="#0000ff">&gt;</font></font><font size="2" color="#0000ff"><font size="2" color="#0000ff">&lt;</font><font size="2" color="#a31515">PolicyItem</font><font size="2" color="#0000ff">&gt;</font><font size="2" color="#0000ff">&lt;<font size="2" color="#a31515">PermissionSet</font><font size="2" color="#0000ff"> </font><font size="2" color="#ff0000">class</font><font size="2" color="#0000ff">=</font><font size="2">&#8220;</font><font size="2" color="#0000ff">NamedPermissionSet</font><font size="2">&#8220;</font><font size="2" color="#0000ff"> </font><font size="2" color="#ff0000">version</font><font size="2" color="#0000ff">=</font><font size="2">&#8220;</font><font size="2" color="#0000ff">1</font><font size="2">&#8220;</font><font size="2" color="#0000ff"> </font><font size="2" color="#ff0000">Description</font><font size="2" color="#0000ff">=</font><font size="2">&#8220;</font><font size="2" color="#0000ff">Permission set for OurAssembly</font><font size="2">&#8220;</font><font size="2" color="#0000ff">&gt;&lt;</font></font></font><font size="2" color="#0000ff"><font size="2" color="#a31515">IPermission</font><font size="2" color="#0000ff"> </font><font size="2" color="#ff0000">class</font><font size="2" color="#0000ff">=</font><font size="2">&#8220;</font><font size="2" color="#0000ff">System.Security.Permissions.FileIOPermission</font><font size="2">&#8220;</font><font size="2" color="#0000ff"> </font><font size="2" color="#ff0000">version</font><font size="2" color="#0000ff">=</font><font size="2">&#8220;</font><font size="2" color="#0000ff">1</font><font size="2">&#8220;</font><font size="2" color="#0000ff"> </font><font size="2" color="#ff0000">Unrestricted</font><font size="2" color="#0000ff">=</font><font size="2">&#8220;</font><font size="2" color="#0000ff">true</font><font size="2">&#8220;</font><font size="2" color="#0000ff"> /&gt; </font><font size="2" color="#0000ff">&lt;/<font size="2" color="#a31515">PermissionSet</font><font size="2" color="#0000ff">&gt;&lt;</font></font><font size="2" color="#0000ff"><font size="2" color="#a31515">Assemblies</font><font size="2" color="#0000ff">&gt;</font><font size="2" color="#0000ff">&lt;<font size="2" color="#a31515">Assembly</font><font size="2" color="#0000ff"> </font><font size="2" color="#ff0000">Name</font><font size="2" color="#0000ff">=</font><font size="2">&#8220;</font><font size="2" color="#0000ff">OurAssembly</font><font size="2">&#8220;</font><font size="2" color="#0000ff"> /&gt;&lt;/</font></font></font></font></font><font size="2" color="#0000ff"> </font><font size="2" color="#0000ff"><font size="2" color="#a31515">Assemblies</font><font size="2" color="#0000ff">&gt;</font><font size="2" color="#0000ff">&lt;/<font size="2" color="#a31515">PolicyItem</font><font size="2" color="#0000ff">&gt;&lt;/<font size="2" color="#a31515">CodeAccessSecurity</font><font size="2" color="#0000ff">&gt;</font></font></font></font></font></p>
<p>Please note that I&#8217;ve set the <em>unrestricted=true </em>attribute just to keep it simple but you should set the Read attribute to the appropiate folder.Now, we can read the file from our webpart:</p>
<pre class="brush: csharp;">
string loc = HttpContext.Current.Server.MapPath(&quot;/&quot;) + &quot;bin\&quot;;
using (StreamReader reader = new StreamReader(loc + @&quot;MyData.xml&quot;))
{
    XDoc = XDocument.Load(reader, LoadOptions.None);
}</pre>
<p>And that&#8217;s all, with this approach we can deploy all kinds of xml data and even .dll configuration files or any other localresource you might need. I hope it&#8217;s helpful and don&#8217;t forget to leave a comment if so !</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/oricode.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/oricode.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oricode.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oricode.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oricode.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oricode.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oricode.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oricode.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oricode.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oricode.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oricode.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oricode.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oricode.wordpress.com&blog=2786525&post=12&subd=oricode&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://oricode.wordpress.com/2008/02/27/deploy-a-xml-file-in-your-sharepoint-solution-to-the-web-application-folder/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2c244f054dfb41041e2adcc475899fe4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">oricode</media:title>
		</media:content>
	</item>
	</channel>
</rss>