<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Gaurav Badhan's blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/gauravbadhan/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/gauravbadhan/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:23:17 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Image Carousel App Privacy Statement</title>
      <link>https://docs.microsoft.com/archive/blogs/gauravbadhan/image-carousel-app-privacy-statement</link>
      <pubDate>Wed, 03 Jul 2013 02:48:00 GMT</pubDate>
      <dc:creator><![CDATA[Gaurav Badhan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gauravbadhan/2013/07/03/image-carousel-app-privacy-statement/</guid>
      <description><![CDATA[Privacy Statement
Image Carousel SharePoint app&nbsp;does not use&nbsp;any Internet-based or mobile...]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: medium;"><strong>Privacy Statement</strong></span></p>
<p>Image Carousel SharePoint app&nbsp;does not use&nbsp;any Internet-based or mobile services.</p>
<p>This app does not&nbsp;collects and/or transmits user information.</p>]]></content:encoded>
    </item>
    <item>
      <title>Image Carousel App Support</title>
      <link>https://docs.microsoft.com/archive/blogs/gauravbadhan/image-carousel-app-support</link>
      <pubDate>Thu, 27 Jun 2013 05:28:00 GMT</pubDate>
      <dc:creator><![CDATA[Gaurav Badhan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gauravbadhan/2013/06/27/image-carousel-app-support/</guid>
      <description><![CDATA[Configuring Image Carousel app on your site

 	Add Image carousel as app part on your page
 	Go...]]></description>
      <content:encoded><![CDATA[<span style="font-size: small"><strong>Configuring Image Carousel app on your site</strong></span>
<ol>
 	<li>Add Image carousel as app part on your page</li>
 	<li>Go to app part properties and select the appropriate size
and maximum number of items to be shown in image carousel app part.</li>
 	<li>It supports 3 different sizes- Large: 940px X 350px, Medium:
620px X 260px and Small: 390px X 200px</li>
 	<li>You can choose up to 8 images to be shown in the image
carousel. It is restricted to maximum of 8 items because more items can hamper
the performance of your site page.</li>
 	<li>To configure images, click on the “Manage Carousel Items”
link on the app part, it takes you to the library where you can add the images.</li>
</ol>
Note: This link is visible only to site admins or site collection administrators

Once you add the image, you can set the following item
properties:
<ul>
 	<li><strong>Title:</strong> Text to be shown below the image on Image Carousel</li>
 	<li><strong>Detail Link:</strong> On clicking on the image, user will be
navigated to this URL</li>
 	<li><strong>Display Order:</strong> Order of the image in the Carousel. Image
Carousel shows images in ascending order of “Display Order” property on the
image.</li>
 	<li><strong>Open Link in New Window:</strong> Whether the URL in “Detail Link”
opens in a new window or same.</li>
</ul>
&nbsp;

<strong>*Update on Anonymous access issue</strong>:

It is verified that on an On-Premise site, the app works fine for anonymous users if following setting is done:
<ul>
 	<li>Go To Site Settings &gt; Site Permissions</li>
 	<li>Click on "Anonymous Access" button on the ribbon</li>
 	<li><strong>Uncheck</strong> the "Require Use Remote Interfaces permission" checkbox</li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/04/4743.AnonymousSettings.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/04/4743.AnonymousSettings.jpg" alt="" border="0" /></a>

&nbsp;

&nbsp;

For SharePoint Online sites, it is a known issue that any app that uses SharePoint list or library will not work on public facing SharePoint online site as per <a href="https://msdn.microsoft.com/en-us/library/office/dn579415(v=office.15).aspx">MSDN article</a>.

<strong>You will not see the "Anonymous Access" button on ribbon on SharePoint online site.</strong>

As this app uses an image library as the data source, it is currently not possible to make it work on a public facing SharePoint online site

Screenshot from MSDN below.

&nbsp;

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/04/5808.MSDNScreenshot.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/04/5808.MSDNScreenshot.jpg" alt="" border="0" /></a>]]></content:encoded>
    </item>
    <item>
      <title>Creating a custom navigation for SharePoint 2010</title>
      <link>https://docs.microsoft.com/archive/blogs/gauravbadhan/creating-a-custom-navigation-for-sharepoint-2010</link>
      <pubDate>Tue, 02 Apr 2013 05:40:00 GMT</pubDate>
      <dc:creator><![CDATA[Gaurav Badhan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gauravbadhan/2013/04/02/creating-a-custom-navigation-for-sharepoint-2010/</guid>
      <description><![CDATA[This blog is about creating a highly configurable custom navigation for SharePoint 2010 using...]]></description>
      <content:encoded><![CDATA[<p>This blog is about creating a highly configurable custom navigation for SharePoint 2010 using minimum code.</p>
<p>The navigation can be global navigation, current navigation or any navigation. It will all depend on how it is configured. &nbsp;</p>
<p>I will follow the approach creating a custom menu that would be placed on Master page using delegate control.&nbsp;&nbsp;</p>
<p><span style="color: #3366ff; font-size: medium;"><strong>Creating Delegate control:</strong></span></p>
<p><span style="font-size: small;">1. Create a user control under SharePoint mapped folder "CONTROLTEMPLATES". Let&rsquo;s name it &ldquo;GlobalNavigationControl.ascx&rdquo; that is going to be used as delegate control in the master page.&nbsp;&nbsp;</span></p>
<p><span style="font-size: small;">2. Open the .ascx file and add 2 user controls &lt;SharePoint:AspMeu&gt; and &lt;asp:SiteMapDataSource&gt; as shown in below code snippet. Also note that DataSourceID property of AspMenu should be the id of SiteMapDataSource.&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<pre class="scroll" style="padding-left: 30px;"><code class="cplusplus">&lt;SharePoint:AspMenu ID="MyGlobalNavigation" <br /> runat="server"<br /> EnableViewState="false"<br /> DataSourceID="MyTopSiteMap"<br /> AccessKey="&lt;%$Resources:wss,navigation_accesskey%&gt;"<br /> UseSimpleRendering="true"<br /> UseSeparateCss="false"<br /> Orientation="Horizontal" <br /> SkipLinkText=""<br /> CssClass="my-own-style"/&gt; <br /> <br /> &lt;asp:SiteMapDataSource id="MyTopSiteMap" runat="server"/&gt;</code></pre>
<p><span style="font-family: Times New Roman; font-size: small;">&nbsp;</span></p>
<p><span style="font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; To handle the styling of menu, use the CssClass property to&nbsp;set your own custom CSS class. </span></p>
<p><span style="font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSS class for v4.master is "s4-tn"</span></p>
<p><span style="font-size: small;">3. The behaviour of the menu will depend on the properties of these 2 controls. Since we have created our own control &ldquo;GlobalNavigationControl.ascx&rdquo;, we need to expose the properties of the 2 controls so that it can be configurable.</span></p>
<p><span style="font-size: small;">4. Go to code-behind and create public properties as shown below:</span></p>
<pre class="scroll"><code class="csharp">#region Menu control Properties<br /> <br /> /// &lt;summary&gt;<br /> /// Gets or sets number of levels to be displayed as static <br /> /// &lt;/summary&gt;<br /> public int StaticDisplayLevels<br /> {<br /> get;<br /> set;<br /> }<br /> <br /> /// &lt;summary&gt;<br /> /// Gets or sets maximum number of levels to be shown in flyout sub menus<br /> /// &lt;/summary&gt;<br /> public int MaximumDynamicDisplayLevels<br /> {<br /> get;<br /> set;<br /> }<br /> <br /> #endregion<br /> <br /> #region DataSource Properties<br /> <br /> /// &lt;summary&gt;<br /> /// Gets or sets provider for the site map data source<br /> /// &lt;/summary&gt;<br /> public string SiteMapProvider<br /> {<br /> get;<br /> set;<br /> }<br /> <br /> /// &lt;summary&gt;<br /> /// Gets or sets StartingNodeOffset for the site map data source<br /> /// &lt;/summary&gt;<br /> public int StartingNodeOffset<br /> {<br /> get;<br /> set;<br /> }<br /> <br /> /// &lt;summary&gt;<br /> /// Gets or sets a value indicating whether to start from current node or not<br /> /// &lt;/summary&gt;<br /> public bool StartFromCurrentNode<br /> {<br /> get;<br /> set;<br /> }<br /> <br /> /// &lt;summary&gt;<br /> /// Gets or sets a value indicating whether to show starting node or not<br /> /// &lt;/summary&gt;<br /> public bool ShowStartingNode<br /> {<br /> get;<br /> set;<br /> }<br /> <br /> #endregion<br /> </code>&nbsp;</pre>
<p><span style="font-size: small;">5. In page load event, assign the user control&rsquo;s property values to the properties of AspMenu and SiteMapDataSource:</span></p>
<pre class="scroll"><code class="csharp">protected void Page_Load(object sender, EventArgs e)<br /> {<br /> this.MyGlobalNavigation.MaximumDynamicDisplayLevels = this.MaximumDynamicDisplayLevels;<br /> this.MyGlobalNavigation.StaticDisplayLevels = this.StaticDisplayLevels;<br /> <br /> this.MyTopSiteMap.SiteMapProvider = this.SiteMapProvider;<br /> this.MyTopSiteMap.ShowStartingNode = this.ShowStartingNode;<br /> &hellip;<br /> &hellip;<br /> }</code></pre>
<p><span style="font-size: small;">&nbsp;6. Add Site map provider in web.config. Open web.config file of your site, go to node &ldquo;system.web/siteMap/providers&rdquo;.</span><br /><span style="font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp; Add below entry. Configure its properties like name, IncludePages, IncludeSubsites , ShowSiblings, etc. properly as per your requirements.&nbsp;</span></p>
<p>&nbsp;</p>
<pre class="scroll"><code class="html">&lt;add name="MyGlobalNavSiteMapProvider" description="Provider for Global Navigation" <br /> type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" <br /> NavigationType="Combined" EncodeOutput="false" IncludePages="Never" <br /> IncludeSubsites="Always" IncludeHeadings="True" IncludeAuthoredLinks="True" ShowSiblings="False" Version="14" /&gt;</code></pre>
<p><code class="cplusplus">&nbsp; </code></p>
<p><span style="font-size: small;">7. Now add an &ldquo;Empty Element&rdquo; for delegate control entry.</span></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/04/7127.AddDelegateControl.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-04/7127.AddDelegateControl.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/04/7127.AddDelegateControl.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-04/7127.AddDelegateControl.png" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p><span style="font-size: small;">8. Open Elements.xml of the delegate control and add below entry. This is setting the properties of the custom control that we just created above. Also note the property <strong>SiteMapProvider</strong>.This is actually the &ldquo;name&rdquo; of site map provider from web.config.</span></p>
<pre class="scroll"><code class="html">&lt;?xml version="1.0" encoding="utf-8"?&gt;<br /> &lt;Elements xmlns="https://schemas.microsoft.com/sharepoint/"&gt;<br /> &lt;Control Id="MyGlobalNavIDForMasterPage"<br /> Sequence="10"<br /> ControlSrc="~/_ControlTemplates/GlobalNavigationControl.ascx"&gt;<br /> &lt;Property Name="MaximumDynamicDisplayLevels"&gt;0&lt;/Property&gt;<br /> &lt;Property Name="StaticDisplayLevels"&gt;1&lt;/Property&gt;<br /> &lt;Property Name="ShowStartingNode"&gt;false&lt;/Property&gt;<br /> &lt;Property Name="SiteMapProvider"&gt;MyGlobalNavSiteMapProvider&lt;/Property&gt;<br /> &lt;/Control&gt; <br /> &lt;/Elements&gt;<br /> </code></pre>
<p><strong></strong>&nbsp;</p>
<p><strong><span style="color: #3366ff; font-family: 'Arial','sans-serif'; font-size: 13.5pt;">Add delegate control to master page:</span></strong>&nbsp;</p>
<ol>
<li><span style="font-size: small;">Open master page and go to the area/div where you want to add the navigation control.</span></li>
<li><span style="font-size: small;">Add the delegate control tag and make sure the property ControlId is set to the same ID that was set in the Elements.xml file of the delegate control.</span></li>
</ol>
<pre class="scroll"><code class="html">&lt;SharePoint:DelegateControl runat="server" ControlId=" MyGlobalNavIDForMasterPage "/&gt;</code></pre>
<p>&nbsp;</p>
<p><br />&nbsp;<strong><span style="color: #3366ff; font-family: 'Arial','sans-serif'; font-size: 13.5pt;">Add delegate control to the feature:</span></strong>&nbsp;</p>
<p><span style="font-size: small;">Make sure the delegate control is added to one of the feature of in the project. As soon as the feature is activated at a site or site collection, the menu will start appearing on the master page.</span></p>
<p>&nbsp;</p>
<p><span style="font-size: small;"><strong><span style="color: #3366ff; font-family: 'Arial','sans-serif'; font-size: 13.5pt;">Configuring the navigation to Up and Running site once the development is complete and you do not want to touch the code</span></strong></span></p>
<p><span style="font-size: small;">This particular navigation is configurable through 3 places.</span></p>
<ol>
<li><span style="font-size: small;">Form the delegate control Elements.xml. This will be available under your&nbsp;feature folder in 14&nbsp; hive. Here you can change the control's properties if required.</span></li>
<li><span style="font-size: small;">From the web.config site map provider. Properties like, show subsites, show pages can be set in web.config file. This is recommended only while development and not when the site is in production or available for end users. 3rd option is recommended in that case.</span></li>
<li><span style="font-size: small;">Open the site and go to site settings&gt;Look and Feel&gt;Navigation. Here you will find all the properties like show subsites, show pages, etc that we pre-configured in web.config file.&nbsp;&nbsp;</span></li>
</ol>]]></content:encoded>
    </item>
    <item>
      <title>How to read custom web part properties at client side using javascript in SharePoint 2010</title>
      <link>https://docs.microsoft.com/archive/blogs/gauravbadhan/how-to-read-custom-web-part-properties-at-client-side-using-javascript-in-sharepoint-2010</link>
      <pubDate>Thu, 08 Mar 2012 05:12:00 GMT</pubDate>
      <dc:creator><![CDATA[Gaurav Badhan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gauravbadhan/2012/03/08/how-to-read-custom-web-part-properties-at-client-side-using-javascript-in-sharepoint-2010/</guid>
      <description><![CDATA[There are some scenarios where you might need to have custom web part properties available at client...]]></description>
      <content:encoded><![CDATA[<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/04/3365.webp.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-04/3365.webp.png"></a>There are some scenarios where you might need to have custom web part properties available at client side. Reading web part properties in client side can be tricky while developing a sandbox solution for SharePoint Online, where&nbsp;we cannot&nbsp;use Visual Web Parts.</p>
<p>Examples of such scenarios are:</p>
<ul>
<li>Passing web part properties data to third party JavaScript.</li>
<li>Using web part properties to loading data on demand at client side.</li>
</ul>
<p>Here is the approach that is followed for this solution. Please note this is not the only approach to achieve this&nbsp;functionality.</p>
<p>1. Read the required web part properties at server side</p>
<p>2.&nbsp;Format the web part properties data as JSON string, so that it can be read by javascript.</p>
<p>3. Create a Hidden field&nbsp;and assign the JSON string as its value.</p>
<p>4. Add javascript reference and HTML controls to the page while rendering the page (Render event). The HTML controls contains a button that, on clicking,&nbsp;calls a javascript function.</p>
<p>5. Read the JSON object from hidden field value in the javascript.</p>
<p>6. Use the data as per your requirement.</p>
<p>&nbsp;</p>
<p><span style="color: #3366ff; font-size: medium;"><strong>Creating Solution:</strong></span></p>
<p>Lets start with creating a Sandbox solution in Visual Studio. It can be a farm solution also, I have chosen sandbox so that it can be&nbsp;deployed in SharePoint online also.</p>
<p>Add a "Scripts" <strong>Module</strong> and then a JavaScript file named "ReadPropertiesAtClient" in the Scripts module.</p>
<p>Add a simple<strong> Web Part</strong> (not a visual web part because it is a sandbox solution), named "ReadAtClientWebPart"</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/04/0068.solution.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-04/0068.solution.png"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/04/0068.solution.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-04/0068.solution.png" width="297" height="308" /></a></p>
<p>&nbsp;Open Elemets.xml and modify it to map it to Style Library:</p>
<p>&lt;?<span style="color: #800000;">xml</span> <span style="color: #ff0000;">version</span>="<span style="color: #0000ff;">1.0</span>" <span style="color: #ff0000;">encoding</span>="<span style="color: #0000ff;">utf-8</span>"?&gt;<br />&lt;<span style="color: #800000;">Elements </span><span style="color: #ff0000;">xmlns</span>="<a href="https://schemas.microsoft.com/sharepoint/">https://schemas.microsoft.com/sharepoint/</a>"&gt;<br />&nbsp; &lt;<span style="color: #800000;">Module </span><span style="color: #ff0000;">Name</span>="<span style="color: #0000ff;">Scripts</span>" <span style="color: #ff0000;">Url</span>="<span style="color: #0000ff;">Style Library/CustomScripts</span>"&gt;<br />&nbsp; &lt;<span style="color: #800000;">File </span><span style="color: #ff0000;">Path</span>="<span style="color: #0000ff;">Scripts\ReadPropertiesAtClient.js</span>" <span style="color: #ff0000;">Url</span>="<span style="color: #3366ff;">Scripts/ReadPropertiesAtClient.js</span>" <span style="color: #ff0000;">Type</span>="<span style="color: #0000ff;">GhostableInLibrary</span>" /&gt;<br />&lt;/<span style="color: #800000;">Module</span>&gt;<br />&lt;/<span style="color: #800000;">Elements</span>&gt;</p>
<p><span style="color: #3366ff; font-size: medium;"><strong></strong></span>&nbsp;</p>
<p><span style="color: #3366ff; font-size: medium;"><strong>The WebPart code:</strong></span></p>
<p>Create two sample web part properties (<span style="color: #000000;">WebPartName and <span style="color: #000000;">WebPartDescription)</span></span>&nbsp;that we will try to read.</p>
<p><span style="color: #2b91af; font-family: Consolas; font-size: small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas;" face="Consolas" color="#2b91af" size="2">[WebBrowsable(true)]<br />[WebDisplayName("Web Part Name")]<br />[WebDescription("Name of the WebPart")]<br />[Personalizable(PersonalizationScope.Shared)]&nbsp;&nbsp;&nbsp; <br /><span style="color: #0000ff;">public string</span> <span style="color: #000000;">WebPartName</span> { <span style="color: #0000ff;">get; set</span>; }</span></span></span></p>
<p><span style="color: #2b91af; font-family: Consolas; font-size: small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas;" face="Consolas" color="#2b91af" size="2">[WebBrowsable(true)]<br />[WebDisplayName("Web Part Description")]<br />[WebDescription("Web Part Description")]<br />[Personalizable(PersonalizationScope.Shared)]<br /><span style="color: #0000ff;">public string</span> <span style="color: #000000;">WebPartDescription</span> { <span style="color: #0000ff;">get; set</span>; }</span></span></span></p>
<p>Now we need to override 3 methods: <strong>CreateChildControls</strong>, <strong>OnPreRender</strong> and <strong>Render</strong></p>
<p>In <strong>CreateChildControls</strong>, create a hidden field object "hiddenWebPartProperties" and add it to controls</p>
<p><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">protected override void CreateChildControls()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base.CreateChildControls(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HiddenField hiddenWebPartProperties = new HiddenField() { ID = "hiddenWebPartProperties" };<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Controls.Add(hiddenWebPartProperties);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"></span></span></p>
<p>In&nbsp;<strong>OnPreRender</strong> create a JSON object of required webpart properies (WebPartName and WebPartDescription in&nbsp;our case).</p>
<p><span style="font-size: x-small;">protected override void OnPreRender(EventArgs e)</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base.OnPreRender(e);</span></p>
<p><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ////Construct JSON using the WebPart Properties</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string webPartPropertiesJSON = string.Empty;</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; webPartPropertiesJSON = "{ 'WebPartName':'" + this.WebPartName + "', 'WebPartDescription': '" </span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + this.WebPartDescription + "' }";</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((HiddenField)this.FindControl("hiddenWebPartProperties")).Value = webPartPropertiesJSON;</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p>&nbsp;</p>
<p><span style="font-size: small;">Override&nbsp;<strong>Render&nbsp;</strong>to add javascript reference and&nbsp;HTML controls to the page. For page controls, I have added a button in&nbsp;a "DIV" and&nbsp;assigned a client click event to the button. On click of the button a javascript function "showProperties" is called that accepts SharePoint server control ID.</span>&nbsp;</p>
<p><span style="font-size: x-small;">protected override void Render(HtmlTextWriter writer)</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.RenderContents(writer);</span></p>
<p><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer.AddAttribute(HtmlTextWriterAttribute.Src, </span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;string.Format("{0}/Style Library/CustomScripts/Scripts/ReadPropertiesAtClient.js",</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SPContext.Current.Site.ServerRelativeUrl.TrimEnd('/')));</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer.RenderBeginTag(HtmlTextWriterTag.Script);</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer.RenderEndTag();</span></p>
<p><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer.Write("&lt;div id='webPartDiv' style='align:center; margin:3px; border: solid thin black;" + </span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;"width: 400px; height: 200px'&gt;"+</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&lt;input type=\"button\" value=\"Click to see web part properties\""+</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;" onclick=\"showProperties('"+this.ClientID+"')\"/&gt;"+"&lt;/div&gt;");</span><br /><span style="font-size: x-small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p><span style="color: #3366ff; font-size: medium;"><strong>The&nbsp;JavaScript code:</strong></span></p>
<p>JavaScript code is very simple it has a function to show the properties on client side. Add below function to "ReadPropertiesAtClient.js" file.</p>
<p><span style="color: #0000ff;">&nbsp;&nbsp;&nbsp; function</span> showProperties(clientID) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<span style="color: #0000ff;">var</span> hiddenField = document.getElementById(clientID + '<span style="color: #800000;">_hiddenWebPartProperties</span>');<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">if</span> (hiddenField != undefined &amp;&amp; hiddenField != <span style="color: #0000ff;">null</span>) {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; webpartProperies = eval(<span style="color: #800000;">"("</span> + hiddenField.value + <span style="color: #800000;">")"</span>);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">var</span> properties = "<span style="color: #800000;">WebPart Name:</span> " + webpartProperies.WebPartName + "<span style="color: #800000;">. WebPart Description:</span> " + webpartProperies.WebPartDescription;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; alert(properties);<br />&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;</p>
<p><span style="color: #3366ff; font-size: medium;"><strong>Deploy and Run:</strong></span></p>
<p>Now the coding part is done, all we need to do is deploy the solution and&nbsp;add the webpart to a page.</p>
<p>Edit the web part and assign the value to the custom webpart properties, click 'Apply' and 'OK'. Now Click on 'Save and Close' button on the ribbon.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/04/7144.webp.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-04/7144.webp.png"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/04/7144.webp.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-04/7144.webp.png" width="409" height="367" /></a></p>
<p>The page is ready, now we can test our webpart. Click the button and the webpart properties are displayed in an alert box.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/04/3286.webp.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-04/3286.webp.png"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/48/04/3286.webp.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-48-04/3286.webp.png" width="387" height="181" /></a></p>
<p>&nbsp;</p>
<p><br />&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Deploy a SharePoint site using automated powershell script</title>
      <link>https://docs.microsoft.com/archive/blogs/gauravbadhan/deploy-a-sharepoint-site-using-automated-powershell-script</link>
      <pubDate>Wed, 23 Nov 2011 23:36:00 GMT</pubDate>
      <dc:creator><![CDATA[Gaurav Badhan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gauravbadhan/2011/11/23/deploy-a-sharepoint-site-using-automated-powershell-script/</guid>
      <description><![CDATA[This blog is about deploying a SharePoint solution using powershell script. Usually during the...]]></description>
      <content:encoded><![CDATA[<p>This blog is about deploying a SharePoint solution using powershell script. Usually during the development phase, a developer creates a web application, creates a site collection, then install the WSP solution manually. But the whole process can be automated in order to make deployment simple in testing, UAT or production environments.</p>
<p>We need 3 files in all for the deployment that needs to be placed in same folder:</p>
<p><strong>1.</strong> <strong>Deploy.bat</strong> - A batch file that is used as a trigger to execute the powershell script and can be called from command prompt.<br /><strong>2.</strong> <strong>Deploy.ps1</strong> - The powershell script file (.ps1).<br /><strong>3.</strong> <strong>Demo.Project.wsp</strong> - The SharePoint solution file.</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;"><strong>Deploy.bat</strong></span></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="798">
<p>powershell -Command "&amp; {Set-ExecutionPolicy bypass}" -NoExit<br />powershell -Command "&amp; {.\Deploy.ps1}" -NoExit</p>
<p>pause</p>
</td>
</tr>
</tbody>
</table>
<p><span style="text-decoration: underline;"></span><span style="text-decoration: underline;"><strong></strong></span>&nbsp;</p>
<p>We need some information about the environment and names of objects like site collection, web application, etc. Here we will have all these data stores in configurable variables.</p>
<p>The script will execute following steps including validation checks:</p>
<p>1. Create a web application<br />2. Create a site collection<br />3. Add and install WSP solution</p>
<p>You need to set the values of the variables mentioned at starting of the script under headings: <span style="color: #800000;">Web Application settings</span>, <span style="color: #800000;">Site Collection Settings</span> and <span style="color: #800000;">Solution Settings. <span style="color: #000000;">Once these configuration settings are done, you can run the script </span></span></p>
<p><span style="text-decoration: underline;"><strong>Deploy.ps1</strong></span></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="798">
<p>Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue</p>
<p>Write-Host <br />Write-Host "Initializing..." -foregroundcolor Green</p>
<p><span style="color: #800000;"># Web Application settings</span><br />$WebAppName = "WebAppTest"<br />$WebAppPort = 100<br />$sp_webapp_url = "https://MACH-I-NE"&nbsp;<span style="color: #008000; background-color: #ffffff;"> #Machine name</span><br />$WebAppAppPool = "AppPoolTest"<br />$WebAppAppPoolAccount = "domain\user"<br />$WebAppDatabaseName = "WebAppTest_Content_Database"<br />$WebAppDatabaseServer = "MACH-I-NE\SP_SQLDBINSTANCE"&nbsp;</p>
<p><span style="color: #800000;"># Site collection settings</span><br />$SiteCollectionName = "TestSiteCollection" <br />$SiteCollectionURL =&nbsp; $sp_webapp_url + ":" + $WebAppPort<br />$SiteCollectionLanguage = 1033 <br />$SiteCollectionOwner = "domain\user"<br />$SiteCollectionTemplate = "BICenterSite#0"&nbsp;&nbsp;&nbsp;<span style="color: #008000; background-color: #ffffff;"> #This is BI site template, you need to select as per your requirement</span></p>
<p><span style="color: #800000; background-color: #ffffff;">#Solution settings</span><br />$SolutionName = "Demo.Project.wsp"</p>
<p><span style="color: #000080;">Write-Host </span><br /><span style="color: #000080;">Write-Host "-------------------------------------" -foregroundcolor Green</span><br /><span style="color: #000080;">Write-Host "Creating WebApp using Classic authentication..." -foregroundcolor Green</span><br /><span style="color: #000080;">Write-Host "-------------------------------------" -foregroundcolor Green</span></p>
<p>$sp = Get-SPWebApplication | Where {$_.DisplayName -eq $WebAppName} <br />if($sp -eq $null) <br />{<br />&nbsp;&nbsp; New-SPWebApplication -Name $WebAppName -Port $WebAppPort -URL ($sp_webapp_url) -ApplicationPool $WebAppAppPool -ApplicationPoolAccount (Get-SPManagedAccount $WebAppAppPoolAccount) -DatabaseName $WebAppDatabaseName -DatabaseServer $WebAppDatabaseServer</p>
<p>&nbsp;# display site info<br /><span style="color: #000080;">&nbsp;Write-Host </span><br /><span style="color: #000080;">&nbsp;Write-Host "Web App created" -foregroundcolor Green</span><br /><span style="color: #000080;">&nbsp;Write-Host "-------------------------------------" -foregroundcolor Green</span><br />} <br />else <br />{&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080;">Write-Host </span><br /><span style="color: #000080;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Write-Host "Web Application already exists, skipping this step" -foregroundcolor yellow</span><br />}</p>
<p><span style="color: #000080;">Write-Host </span><br /><span style="color: #000080;">Write-Host "-------------------------------------" -foregroundcolor Green</span><br /><span style="color: #000080;">Write-Host "Creating site collection..." -foregroundcolor Green</span></p>
<p><span style="color: #008000; background-color: #ffffff;">&nbsp;# Delete any existing site found at target URL&nbsp;</span></p>
<p>$targetUrl = Get-SPSite | Where-Object {$_.Url -eq $SiteCollectionURL}<br />&nbsp;if ($targetUrl -ne $null) <br />&nbsp;{<br />&nbsp;&nbsp; <span style="color: #000080;">Write-Host "Site already exist, Deleting existing site : " $SiteCollectionURL -foregroundcolor yellow</span></p>
<p>&nbsp;&nbsp; Remove-SPSite -Identity $SiteCollectionURL -Confirm:$false<br />&nbsp; <br />&nbsp;<span style="color: #000080;">&nbsp; Write-Host </span><br /><span style="color: #000080;">&nbsp;&nbsp; Write-Host "Existing site collection deleted..." -foregroundcolor yellow</span><br />&nbsp;}</p>
<p><span style="color: #008000; background-color: #ffffff;">&nbsp;#&nbsp;Create new site collection&nbsp;</span></p>
<p>New-SPSite -URL $SiteCollectionURL -OwnerAlias $SiteCollectionOwner -Language $SiteCollectionLanguage -Template $SiteCollectionTemplate -Name $SiteCollectionName</p>
<p><span style="color: #000080;">Write-Host </span><br /><span style="color: #000080;">Write-Host "Site collection created" -foregroundcolor Green</span><br /><span style="color: #000080;">Write-Host "-------------------------------------" -foregroundcolor Green</span></p>
<p><span style="color: #000080;">Write-Host </span><br /><span style="color: #000080;">Write-Host "-------------------------------------" -foregroundcolor Green</span><br /><span style="color: #000080;">Write-Host "Deploying WSP package..." -foregroundcolor Green</span><br /><span style="color: #000080;">Write-Host "-------------------------------------" -foregroundcolor Green</span></p>
<p><span style="color: #008000; background-color: #ffffff;">&nbsp;# If solution already exists, Retract, Remove old solution and Add, Deploy new solution </span></p>
<p>$solution = Get-SPSolution $SolutionName -ErrorAction SilentlyContinue<br />&nbsp;if ($solution -ne $null) <br />&nbsp;{<br />&nbsp;&nbsp; <span style="color: #000080;">Write-Host</span><br /><span style="color: #000080;">&nbsp;&nbsp; Write-Host "Solution already exists. " $solution -foregroundcolor Yellow</span><br />&nbsp; <br />&nbsp;&nbsp; $solution | Uninstall-SPSolution -AllWebApplications&nbsp; -confirm:$false&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp; <br />&nbsp;&nbsp; <span style="color: #000080;">Write-Host "Retracting solution..." -foregroundcolor Yellow</span></p>
<p><span style="color: #000080;"><span style="background-color: #ccffff;"><span style="color: #008000; background-color: #ffffff;">&nbsp;# Retracting job is assigned to timer job, so we need to wait for it to complete before removing solution</span>.</span>&nbsp;</span></p>
<p>&nbsp;&nbsp;&nbsp; while ( $solution.JobExists )<br />&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; sleep 3<br />&nbsp;&nbsp;&nbsp; <span style="color: #000080;">write-host "."</span><br />&nbsp;&nbsp; }<br />&nbsp;&nbsp; <span style="color: #000080;">write-host "solution retracted" -foregroundcolor yellow</span><br /><span style="color: #000080;">&nbsp;&nbsp; Write-Host</span><br /><span style="color: #000080;">&nbsp;&nbsp; Write-Host "Removing solution " $solution -foregroundcolor Yellow</span><br />&nbsp;&nbsp; <br />&nbsp;&nbsp; $solution | Remove-SPSolution -confirm:$false</p>
<p>&nbsp;&nbsp; <span style="color: #000080;">Write-Host "Removed"</span></p>
<p>&nbsp; }</p>
<p>&nbsp;&nbsp; <span style="color: #000080;">Write-Host </span><br /><span style="color: #000080;">&nbsp; &nbsp;Write-Host "Adding solution " $solution -foregroundcolor Green</span><br />&nbsp; <br />&nbsp; Add-SPSolution $SolutionName<br />&nbsp; <br /><span style="color: #000080;">&nbsp; &nbsp;Write-Host </span><br /><span style="color: #000080;">&nbsp; &nbsp;Write-Host "Solution Added. Now Installing WSP solution..." -foregroundcolor Green</span></p>
<p>&nbsp; $SolutionName | Install-SPSolution &ndash;WebApplication $WebAppName -language 0 -GACDeployment</p>
<p><span style="color: #008000; background-color: #ffffff;">&nbsp;# Wait for timer job to complete&nbsp;</span>&nbsp;&nbsp;<br />&nbsp; $solution.JobExists</p>
<p>&nbsp;&nbsp; while ( $solution.JobExists )<br />&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; sleep&nbsp;3<br />&nbsp;&nbsp;&nbsp;<span style="color: #000080;"> write-host "."</span><br />&nbsp;&nbsp; }</p>
<p>&nbsp;<span style="color: #000080;">write-host "Deployment complete" -foregroundcolor Green</span><br /><span style="color: #000080;">&nbsp;Write-Host "-------------------------------------" -foregroundcolor Green</span><br />Remove-PsSnapin Microsoft.SharePoint.PowerShell</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;Please note that this script does not have all the steps or commands that might be needed for a generic project, but it will give a clear idea about the approach and you can add or remove commands as per your requirements.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Handling ASP .NET session expired message in SharePoint 2010 through javascript</title>
      <link>https://docs.microsoft.com/archive/blogs/gauravbadhan/handling-asp-net-session-expired-message-in-sharepoint-2010-through-javascript</link>
      <pubDate>Tue, 20 Sep 2011 08:14:00 GMT</pubDate>
      <dc:creator><![CDATA[Gaurav Badhan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/gauravbadhan/2011/09/20/handling-asp-net-session-expired-message-in-sharepoint-2010-through-javascript/</guid>
      <description><![CDATA[There are situations when one needs to handle session expiring in SharePoint solution. This error...]]></description>
      <content:encoded><![CDATA[<p>There are situations when one needs to handle session expiring in SharePoint solution. This error can occur either because of Session time out after some time as specified in Web.Config, or due to some external control that is being used in the SharePoint site.</p>
<p>An example is using SQL Server 2008 Reporting Services report viewer web part to display SSRS reports. The default timeout of report server is 10 minutes. So if you try to view the report second time after being idle for 10 minutes, it will return you a message &ldquo;<strong>ASP.NET session has expired or could not be found</strong>&rdquo;. This is a more &lsquo;Technical&rsquo; message that business users might find unusual.</p>
<p>In order to handle this we might want to either: Give a more specific message and tell user to refresh the page, or redirect to a login or error page. That can be customized as per your requirement; I will just show an<br />error message with a button to refresh the page.</p>
<p>To handle this situation I will be using JavaScript and apply it to master page so that it will be applicable to all the pages in the application.</p>
<p><strong>Step 1:</strong> Open your master page in SharePoint designer and start editing.</p>
<p><strong>Step 2</strong>: Add the div that will appear as popup. You can add it anywhere in the page, I will add it just before the div containing &lt;SharePoint:SPRibbon&gt;</p>
<p>&lt;div id="SessionTimeMessageDiv" style="height:0px; display:none;"&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp; &lt;div id="SessionTimeOutDiv" style=" position:relative; display:none; top: 0px; height: 100%; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; background-color: White; opacity: 0.75; filter: alpha(opacity=75); vertical-align: middle;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; left: 0px; z-index: 99998; width: 100%; position: absolute;&nbsp; text-align:center;"&gt;&lt;/div&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp; &lt;div style="width:400px; text-align:center; position:relative;&nbsp; filter: alpha(opacity=100);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vertical-align:middle; top:200px; left:40%; height:80px; border:thin lightBlue solid;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; background-color:white; z-index:99999;"&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br/&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:Label ID="lblSessionTimeOut" runat="server"&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Text="You session has expired, please press Refresh button or refresh the page"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/asp:Label&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br /&gt;&lt;br /&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:Button ID="Button1" runat="server" Text="Refresh" OnClientClick="refreshPage();"/&gt; <br />&nbsp;&nbsp;&nbsp; &lt;/div&gt; <br />&lt;/div&gt;</p>
<p>I have added 3 &lt;div&gt;s to have the effect of grayed out disabled page and Refresh message on top of that. Please note that on click of Refresh button, I am calling another JavaScript function to refresh the page.</p>
<p>&nbsp;</p>
<p><strong>Step 3:</strong> Add JavaScript functions to the master page</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Global variable to hold the timeout time <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var sessionTimeout; <br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Reset the timeout to a static value. Will get this from web config later<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function resetTimer() <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sessionTimeout=5; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // function to refresh the page <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function refreshPage()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; location.reload(true); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Counter function. It is a recursive function that will keep calling itself each minute, you can reduce the time to few seconds for debugging<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function countTimeout() <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sessionTimeout = sessionTimeout - 1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(sessionTimeout &gt;= 0)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //call the function again after 1 minute delay&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; window.setTimeout("countTimeout()", 60000); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //show message box<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById("SessionTimeOutDiv").style.display = "block";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById("SessionTimeMessageDiv").style.display = "block";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;</p>
<p>Now we need to initialize the timer on page load and reset it whenever user is doing some activity on the page. We will reset the timer each time user clicks anywhere or presses some key. For this we need to call javascript on body load.</p>
<p>&nbsp;<strong>Step 4:</strong> Handle Body onload event:&nbsp;</p>
<p>Usually body load event of master page is already handled in SharePoint master page, so now we need to call multiple functions on body load. There is a crack for this. Taking example of NightAndDay.master:</p>
<p><em>&lt;body scroll="no" onload="if(typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();" class="nightandday"&gt;</em></p>
<p>Change this to:&nbsp;</p>
<p><em>&lt;body scroll="no" onload=&rdquo;BodyLoad();"class="nightandday"&gt;</em></p>
<p>Move old code to bodyLoad() function.</p>
<p>function bodyLoad() <br />{ <br />&nbsp;&nbsp;&nbsp;&nbsp; if (typeof(_spBodyOnLoadWrapper)!= 'undefined') _spBodyOnLoadWrapper(); <br />}&nbsp;</p>
<p>Now we can call our timer from this function. So the final function should look like:</p>
<p>function bodyLoad()<br />{ <br />&nbsp;&nbsp;&nbsp; if (typeof(_spBodyOnLoadWrapper)!= 'undefined') _spBodyOnLoadWrapper(); <br />&nbsp;&nbsp;&nbsp; resetTimer(); <br />&nbsp;&nbsp;&nbsp; countTimeout(); <br />}&nbsp;</p>
<p>Reset the timer when a user clicks on the screen or press any key. For this, add 2 more events on &lt;body&gt;: onclick="resetTimer()" and onkeypress="resetTimer()"&nbsp;</p>
<p><strong>Step 5</strong>: Read the session timeout:&nbsp;</p>
<p>Now everything is ready except that the timeout is hardcoded. We will get it from Session.Timeout property. session timeout property&nbsp;can be fetched from following web.config entry:</p>
<p>&lt;<span style="color: #a31515; font-family: Consolas; font-size: x-small;" size="2" color="#a31515" face="Consolas"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" size="2" color="#a31515" face="Consolas"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" size="2" color="#a31515" face="Consolas">sessionState</span></span></span><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"> </span></span></span><span style="color: #ff0000; font-family: Consolas; font-size: x-small;" size="2" color="#ff0000" face="Consolas"><span style="color: #ff0000; font-family: Consolas; font-size: x-small;" size="2" color="#ff0000" face="Consolas"><span style="color: #ff0000; font-family: Consolas; font-size: x-small;" size="2" color="#ff0000" face="Consolas">mode</span></span></span><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas">=</span></span></span><span style="font-family: Consolas; font-size: x-small;" size="2" face="Consolas"><span style="font-family: Consolas; font-size: x-small;" size="2" face="Consolas">"</span></span><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas">InProc</span></span></span><span style="font-family: Consolas; font-size: x-small;" size="2" face="Consolas"><span style="font-family: Consolas; font-size: x-small;" size="2" face="Consolas">"</span></span><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"> </span></span></span><span style="color: #ff0000; font-family: Consolas; font-size: x-small;" size="2" color="#ff0000" face="Consolas"><span style="color: #ff0000; font-family: Consolas; font-size: x-small;" size="2" color="#ff0000" face="Consolas"><span style="color: #ff0000; font-family: Consolas; font-size: x-small;" size="2" color="#ff0000" face="Consolas">timeout</span></span></span><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas">=</span></span></span><span style="font-family: Consolas; font-size: x-small;" size="2" face="Consolas"><span style="font-family: Consolas; font-size: x-small;" size="2" face="Consolas">"</span></span><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas">10</span></span></span><span style="font-family: Consolas; font-size: x-small;" size="2" face="Consolas"><span style="font-family: Consolas; font-size: x-small;" size="2" face="Consolas">"</span></span><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" size="2" color="#0000ff" face="Consolas"> /&gt;</span></span></span></p>
<p>Try&nbsp;reading sessionTimeout using code block in master page&nbsp;as:&nbsp;&lt;%=Session.Timeout%&gt;. This will throw an exception saying: <strong>&ldquo;Code blocks are not allowed in this file&rdquo;</strong>.</p>
<p>So I will write a custom control, add it to the master page and read the value in javascript.</p>
<p><strong>Note:</strong> There can be other ways to read this value but I have not explored them.&nbsp;</p>
<p><strong>Add user control:</strong></p>
<p>Create a new SharePoint solution in visual studio.</p>
<ul>
<li>Add SharePoint mapped &ldquo;ControlTemplates&rdquo; folder.</li>
<li>Add a new User control &ndash; SessionTimeOut.ascx.</li>
<li>Add following code to the ascx file: <br />&lt;div id ="timeout"&gt;&lt;%=Session.Timeout%&gt;&lt;/div&gt;</li>
<li>Deploy the solution.&nbsp;</li>
</ul>
<p>Include the user control in master page:&nbsp;</p>
<p>Register the TagPrefix. Add following line before &lt;html&gt; tag:</p>
<p><em>&lt;%@ Register TagPrefix="useruc" TagName="SessionTimeOut" src="~/_CONTROLTEMPLATES/Sharepoint.UI.Webparts/SessionTimeOut.ascx"%&gt;</em></p>
<p>Add following &lt;div&gt; in the master page body:</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div style="display:none;" id="SessionDetails"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;useruc: SessionTimeOut id="Idsession" runat="server" EnableViewState="false"&gt; &lt;/useruc:AdminUser&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/div&gt;&nbsp;</p>
<p>Now we will have the session timeout available on the master page inside a hidden div named "timeout". This is what we added in the user control and can be read as:</p>
<p><em>document.getElementById("timeout").innerText;</em>&nbsp;</p>
<p>&nbsp;</p>
<p>Now we have everything in place. The final JavaScript will look like:&nbsp;</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="798">
<p>&lt;script type="text/javascript"&gt;<br />&nbsp; <br />&nbsp; var sessionTimeout; <br />&nbsp; <br />&nbsp; function bodyLoad() <br />&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp; if(typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper(); <br />&nbsp;&nbsp;&nbsp;&nbsp; resetTimer(); <br />&nbsp;&nbsp;&nbsp;&nbsp; countTimeout(); <br />&nbsp; }<br />&nbsp; <br />&nbsp; function resetTimer()<br />&nbsp; {<br />&nbsp;&nbsp; //Read timeout from custom control <br />&nbsp;&nbsp; sessionTimeout=document.getElementById("timeout").innerText; <br />&nbsp; } <br />&nbsp;<br />&nbsp; function refreshPage()&nbsp; <br />&nbsp; {&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp; location.reload(true);<br />&nbsp; } <br />&nbsp;<br />&nbsp; function countTimeout()<br />&nbsp; {<br />&nbsp;&nbsp;&nbsp; sessionTimeout = sessionTimeout - 1; <br />&nbsp;&nbsp;&nbsp; if(sessionTimeout &gt;= 0) <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //call the function again after 1 minute delay&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; window.setTimeout("countTimeout()", 60000); <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; else <br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //show message box<br />&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById("SessionTimeOutDiv").style.display = "block"; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById("SessionTimeMessageDiv").style.display = "block";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; } <br />} <br />&lt;/script&gt;&nbsp;</p>
<p>&nbsp;</p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;&nbsp;</p>
<p>The &lt;body&gt; tag of master page should look like:</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="798">
<p>&lt;body scroll="no"&nbsp; onload="bodyLoad()" onclick="resetTimer()"&nbsp; onkeypress="resetTimer()" class="nightandday"&gt;</p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>And the code to add in the &lt;body&gt; of master page:&nbsp;</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="798">
<p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;div style="display:none;" id="SessionDetails"&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;useruc: SessionTimeOut id="Idsession" runat="server" EnableViewState="false"&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/useruc:AdminUser&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp; &lt;/div&gt; <br />&nbsp; <br />&nbsp; &lt;div id="SessionTimeMessageDiv" style="height:0px; display:none;"&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div id="SessionTimeOutDiv" style=" position:relative;display:none; top: 0px; height: 100%;background-color: White; opacity: 0.75;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filter: alpha(opacity=75); vertical-align: middle;left: 0px; z-index: 99998; width: 100%; position: absolute;&nbsp; text-align: center;"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/div&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div style="width:400px; text-align:center; position:relative; filter:alpha(opacity=100); vertical-align:middle; top:200px; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; left:40%; height:80px; border:thin lightBlue solid; background-color:white; z-index:99999;"&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br/&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:Label ID="lblSessionTimeOut" runat="server" Text="You session has expired, please press Refresh button or refresh the page"&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/asp:Label&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;br /&gt;&lt;br /&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:Button ID="Button1" runat="server" Text="Refresh" OnClientClick="refreshPage();" /&gt; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/div&gt; <br />&nbsp; &lt;/div&gt;</p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;&nbsp;</p>
<p>Thats all the coding.&nbsp;For debugging,&nbsp;try reducing the timeout in web.config and reduce the time from 60000 to 15000&nbsp;in window.setTimeout("countTimeout()", 60000).</p>
<p>Important note: If you are using some external control in your pages that has its own timeout, then we need to make sure that the timeout mentioned in web.config should be less than or equal to that of enternal.</p>
<p>For example, you are using SQL Server Reporting Services ReportViewer to show SSRS reports that are hosted on a report server. Now the default time out of report server is 10 minutes, and if you set timeout in web.config as 30 minutes, then this approach will not work as we are reading from web.config.</p>
<p>In this case, there are 2 options:</p>
<ol>
<li>Decrease the timeout in web.config to match to report server.</li>
<li>Increase the timeout in report server to have timeout more than or equal to that of web.config.</li>
</ol>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
  </channel>
</rss>