tag:blogger.com,1999:blog-50337015758269032862024-03-05T11:11:21.448-08:00tech tipsfrom my learningsLaxmikanthttp://www.blogger.com/profile/05001791510755079172noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-5033701575826903286.post-87385038844110630792009-03-29T11:31:00.001-07:002009-03-29T12:27:39.498-07:00Show “Operation In Progress” spinning wheel in custom code<p><span style="color:#400080;">While doing custom coding in SharePoint if you have any long running operations(like creation of site) which take some significant time to complete then you always want to give a hint to the end user to be patient and that the operation is in progress and it is not in the hung state. </span></p><p><span style="color:#400080;">SharePoint does it smartly by showing the smart spinner. </span></p><p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgIlPDkZ0lkgRWVcmxAA4r4_ob_RQEQzbQOT0c711dtI9W-c76oTancvaE08_bX20G2sytv82-NuZsEyjB7Fb7BO9g1BsTokeM8Ka9N5Qg19kLYrM4S5VV88TS358YoGYCE6iANlsTHC7B/s1600-h/spin_wheel[3].jpg"><img title="spin_wheel" style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="124" alt="spin_wheel" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizbTgTuiDlsQpnpqduPTPInZKV5caFMG_g9khd78DMvd5QrwVjie7cIdEW5AZ41es33Dv1cvAP56cp638xoHi45PleLMjd9LYH7jirTJcXd6DHMATvj1Ga4aCEN-Jn-hc_RCfPLXZ5ZwH5/?imgmax=800" width="313" border="0" /></a> </p><p><span style="color:#400080;">While coding custom stuff I always wanted to show the same spinner as that would be consistent with the out of box SharePoint behavior. </span></p><p><span style="color:#400080;">Initially I used to(and saw many others too) doing it by embedding some JavaScript to load the image, until I stumbled upon </span><a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splongoperation.aspx"><span style="color:#400080;">this</span></a><span style="color:#400080;">. </span></p><p><span style="color:#400080;">It was exciting to see that this is there as a built in function - "SPLongOperation".<br />Below is the way we can use this in code : </span></p><p></p><div class="csharpcode"><pre class="alt"><span class="kwrd">using</span> (SPLongOperation longOperation = <span class="kwrd">new</span> SPLongOperation(<span class="kwrd">this</span>.Page)) </pre><pre>{ </pre><pre class="alt"> longOperation.LeadingHTML = <span class="str">"Put Leading HTML here"</span>;</pre><pre> longOperation.TrailingHTML = <span class="str">"Put Trailing HTML here"</span>;</pre><pre class="alt"> longOperation.Begin(); </pre><pre> <span class="rem">// Code that takes time to complete… </span><br /></pre><pre class="alt"> longOperation.End(strURL);</pre><pre>}<br /><style type="text/css"><br /><br /><br /><br /><br />.csharpcode, .csharpcode pre<br />{<br /> font-size: small;<br /> color: black;<br /> font-family: consolas, "Courier New", courier, monospace;<br /> background-color: #ffffff;<br /> /*white-space: pre;*/<br />}<br />.csharpcode pre { margin: 0em; }<br />.csharpcode .rem { color: #008000; }<br />.csharpcode .kwrd { color: #0000ff; }<br />.csharpcode .str { color: #006080; }<br />.csharpcode .op { color: #0000c0; }<br />.csharpcode .preproc { color: #cc6633; }<br />.csharpcode .asp { background-color: #ffff00; }<br />.csharpcode .html { color: #800000; }<br />.csharpcode .attr { color: #ff0000; }<br />.csharpcode .alt<br />{<br /> background-color: #f4f4f4;<br /> width: 100%;<br /> margin: 0em;<br />}<br />.csharpcode .lnum { color: #606060; }</style><br /><br /></pre></div><p><span style="color:#400080;">Nice little piece that Microsoft added :)</span></p>Laxmikanthttp://www.blogger.com/profile/05001791510755079172noreply@blogger.com5tag:blogger.com,1999:blog-5033701575826903286.post-9927599659878074202008-07-16T04:53:00.000-07:002008-07-25T04:45:38.807-07:00Photo Gallery In SharePoint<span style="font-family:times new roman;color:#333399;">Recently I had posted a query on how to build a photo gallery as a no code solution in SharePoint?<br /><br />Here is the solution!!!<br /><br /><strong>Functionality:</strong><br />Develop a WebPart to display the photo gallery as shown in figure below: </span><br /><br /><br /><br /><p><span style="font-family:times new roman;color:#333399;"><img id="BLOGGER_PHOTO_ID_5223579464201057938" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZhIYgM2FQspXDtmrOB_j5CbfKvFaMFfpvu0_FbgonH27tQmm8aYGgoP3CV9twEkXJTQ1C9RtZwXdMpkvMfAUcMy3A02vKXA52ekZmH20ysZohtDvJfDL3BlPBpI-KCPK_l9qpOmFVnKOJ/s400/gallery.bmp" border="0" /><br />Each of the Photos in the gallery will inturn be linked to some URL.<br /><br />I used the Content Query WebPart to do that. And it is not tough at all!!!<br /><br />Let me elaborate the steps:<br /><br /><strong>1) Create the list to store the url for the photos and the url where it should be hyperlinked to :<br /></strong></span><span style="font-family:times new roman;color:#333399;">Let’s call the list as PhotoList </span></p><br /><p><span style="font-family:Times New Roman;color:#333399;"></span></p><img id="BLOGGER_PHOTO_ID_5223581234087284386" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT7EMiMlR3w-mcB9BrDIHkLwyGwml83vQv0dENa0-BW22zWSJIO0VyI9onZdrOAxqiI4fe201jYl2Xh-dTOZT5D8GYBQxL8AfTOSJ0e2FS_GO4XxZ3atoNoxAwtsNGLohQvk87tIbfWfGw/s400/newitem.bmp" border="0" /><br /><p><span style="font-family:times new roman;color:#333399;">Title: Stores the url where click on that particular photo should redirect to.<br />ImageURL: Stores the image path. (Image description can be used as alternate text and as tool tip on hover.)<br /><br /><strong>2) Modify ItemStyle.xsl</strong><br />a) Navigate to the style library on the site(Go to View All site content -> Style Library)<br />b) Download a copy of ItemStyle.xsl<br />c) Add the following Custom Style template for our PhotoGallery<br /></p></span><pre class="csharpcode"><br /><span style="color:#333399;"><span style="font-size:85%;"><xsl:template name=<span class="str">"PhotoGallery"</span> match=<span class="str">"Row[@Style='PhotoGallery']"</span> mode=<span class="str">"itemstyle"</span>><br /><br /> <xsl:param name=<span class="str">"CurPos"</span> /><br /><br /> <xsl:param name=<span class="str">"Last"</span> /><br /><br /> <xsl:variable name=<span class="str">"SafeLinkUrl"</span>><br /><br /> <xsl:call-template name=<span class="str">"OuterTemplate.GetSafeLink"</span>><br /><br /> <xsl:with-param name=<span class="str">"UrlColumnName"</span> select=<span class="str">"'LinkUrl'"</span>/><br /><br /> </xsl:call-template><br /><br /> </xsl:variable><br /><br /> <xsl:variable name=<span class="str">"DisplayTitle"</span>><br /><br /> <xsl:call-template name=<span class="str">"OuterTemplate.GetTitle"</span>><br /><br /> <xsl:with-param name=<span class="str">"Title"</span> select=<span class="str">"@Title"</span>/><br /><br /> <xsl:with-param name=<span class="str">"UrlColumnName"</span> select=<span class="str">"'LinkUrl'"</span>/><br /><br /> </xsl:call-template><br /><br /> </xsl:variable><br /><br /> <xsl:variable name=<span class="str">"LinkTarget"</span>><br /><br /> <xsl:<span class="kwrd">if</span> test=<span class="str">"@OpenInNewWindow = 'True'"</span> >_blank</xsl:<span class="kwrd">if</span>><br /><br /> </xsl:variable><br /><br /> <xsl:variable name=<span class="str">"SafeImageURL"</span>><br /><br /> <xsl:<span class="kwrd">value</span>-of select=<span class="str">"@ImageURL"</span> /><br /><br /> </xsl:variable><br /><br /> <xsl:variable name=<span class="str">"tableStart"</span>><br /><br /> <xsl:<span class="kwrd">if</span> test=<span class="str">"$CurPos = 1"</span>><br /><br /> <![CDATA[<div id=<span class="str">"tablediv"</span> style=<span class="str">"overflow-x:scroll;width=550px;"</span>><table border=<span class="str">"0"</span> cellspacing=<span class="str">"5"</span><br /><br /><br /><br />style=<span class="str">"margin:0pt;padding:0pt;width:100%;"</span>><tr width=<span class="str">"100%"</span>>]]><br /><br /> </xsl:<span class="kwrd">if</span>><br /><br /> </xsl:variable><br /><br /> <xsl:variable name=<span class="str">"tableEnd"</span>><br /><br /> <xsl:<span class="kwrd">if</span> test=<span class="str">"$CurPos = $Last"</span>><br /><br /> <![CDATA[</tr></table></div>]]><br /><br /> </xsl:<span class="kwrd">if</span>><br /><br /> </xsl:variable><br /><br /> <div id=<span class="str">"linkitem"</span> <span class="kwrd">class</span>=<span class="str">"item"</span>><br /><br /> <xsl:<span class="kwrd">value</span>-of select=<span class="str">"$tableStart"</span> disable-output-escaping=<span class="str">"yes"</span>/><br /><br /> <xsl:<span class="kwrd">if</span> test=<span class="str">"string-length($SafeImageURL) != 0"</span>><br /><br /> <xsl:variable name=<span class="str">"trimmedImageUrl"</span>><br /><br /> <xsl:choose><br /><br /> <xsl:when test=<span class="str">"contains($SafeImageURL, ',')"</span>><br /><br /> <xsl:<span class="kwrd">value</span>-of select=<span class="str">"substring-before($SafeImageURL, ',')"</span>/><br /><br /> </xsl:when><br /><br /> <xsl:otherwise><br /><br /> <xsl:<span class="kwrd">value</span>-of select=<span class="str">"@ImageURL"</span>/><br /><br /> </xsl:otherwise><br /><br /> </xsl:choose><br /><br /> </xsl:variable><br /><br /> <td align=<span class="str">"left"</span>><br /><br /> <div <span class="kwrd">class</span>=<span class="str">"image-area-left"</span>><br /><br /> <a style=<span class="str">"border:1px solid #9D0E2D;"</span> href=<span class="str">"{$DisplayTitle}"</span> target=<span class="str">"_blank"</span><br /><br /><br /><br />title=<span class="str">"{@LinkToolTip}"</span>><br /><br /> <img <span class="kwrd">class</span>=<span class="str">"image"</span> height=<span class="str">"100"</span> src=<span class="str">"{$trimmedImageUrl}"</span> /><br /><br /> </a><br /><br /> </div><br /><br /> </td><br /><br /> </xsl:<span class="kwrd">if</span>><br /><br /><br /><br /> <xsl:<span class="kwrd">value</span>-of select=<span class="str">"$tableEnd"</span> disable-output-escaping=<span class="str">"yes"</span>/><br /><br /> </div><br /><br /></xsl:template></span><br /><br /><br /><br /></span><br /><br /></pre><br /><br /><br /><span style="color:#333399;">d) Save the changes and upload the ItemStyle.xsl in its original location. Check In the file.<br /><br /><strong>3) Modify ContentQueryMain.xsl</strong><br />a) Navigate to the style library on the site(Go to View All site content -> Style Library)<br />b) Download a copy of ContentQueryMain.xsl<br />c) Make the changes highlighted below.<br /></span><br /><p></p><span style="font-family:times new roman;color:#333399;"><pre class="csharpcode"><br /><span style="font-size:85%;"><span style="color:#333399;">Under <xsl:template name=<span class="str">"OuterTemplate.Body"</span>><br /><br /><br /><br /><br /><br /><br /><br /> <xsl:call-template name=<span class="str">"OuterTemplate.CallItemTemplate"</span>><br /><br /> <xsl:with-param name=<span class="str">"CurPosition"</span> select=<span class="str">"$CurPosition"</span> /><br /><br /> <strong><xsl:with-param name=<span class="str">"LastRow"</span> select=<span class="str">"$LastRow"</span> /></strong><br /><br /> </xsl:call-template></span><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><!-- code formatted by http://manoli.net/csharpformat/ --><br /><br /></span><pre class="csharpcode"><br /><br /><br /><br /><br /><br /><br /><span style="font-size:85%;"> <span style="color:#333399;">Under <xsl:template name=<span class="str">"OuterTemplate.CallItemTemplate"</span>></span><br /><br /><br /><br /><br /><br /><br /><br /> </span><span style="font-size:85%;"><span style="color:#333399;"><xsl:param name=<span class="str">"LastRow"</span> /><br /><br /> <xsl:choose></span><br /><br /> </span><span style="font-size:85%;"><span style="color:#333399;"><strong><xsl:when test=<span class="str">"@Style='PhotoGallery'"</span>><br /><br /> <xsl:apply-templates select=<span class="str">"."</span> mode=<span class="str">"itemstyle"</span>><br /><br /> <xsl:with-param name=<span class="str">"CurPos"</span> select=<span class="str">"$CurPosition"</span> /><br /><br /> <xsl:with-param name=<span class="str">"Last"</span> select=<span class="str">"$LastRow"</span> /><br /><br /> </xsl:apply-templates><br /><br /> </xsl:when></strong></span><br /><br /> </span></pre><br /><br /><br /><br /><br /><br /><span style="color:#333399;"><strong>4) Add the content by query WebPart:<br /><br /></strong>Add content by query WebPart and set the following properties for the WebPart:<br /><br />a) Query -> Source -> Select Show Items from the following list -> browse to the PhotoList created in step1.<br /><br />b) Query ->List type -> Show Items from this list type = Custom List<br /><br />c) Query-> Content Type -> Show Items of this content type group = List Content type<br /><br />d) Query -> Content Type -> Show Items of this content type = Item<br /><br />e) Presentation -> Sort Items By = Created<br /><br />f) Presentation -> Limit the number of items to display -> Item Limit : 100<br /><br />g) Presentation -> Styles -> Group Style -> Default<br /><br />h) Presentation -> Styles -> Item Style ->PhotoGallery</span><br /><br /><p></p><pre></pre><br /><br /><span style="font-family:times new roman;color:#333399;"></span><br /><br /><br /><br /><p><span style="font-family:times new roman;"><span style="color:#333399;"><strong>The WebPart would not display any data at this stage.</strong> It would work only after completing the step below. </span></span></p><span style="font-family:times new roman;color:#333399;"><br /><br /><br /><br /><p><br /><br /><span style="color:#333399;"><strong>5) Modify the Content Query WebPart to display the columns required :</strong><br /><br />a) Export the Content Editor WebPart and save the .WebPart file on desktop.<br /><br />b) Open the file locate and modify the following line :<br /><br /><br /><br /><br /><!-- code formatted by http://manoli.net/csharpformat/ --><br /><br /><pre class="csharpcode"><br /><property name=<span class="str">"CommonViewFields"</span> type=<span class="str">"string"</span>><strong>ImageURL</strong></property></pre><br /><br /><br /><br /><br /><p><span style="color:#333399;">Add the column name as shown in bold to include that in the view. Save the changes<br /><br />c) Upload the WebPart back to the site.</span><br /></p><p> </p><p><br /><br /><span style="color:#333399;">You should be able to get a photo gallery as shown at the top(Of course with an assumption that you have content in the PhotoList J)</span><br /><br /></span></p><br /><br /></span></pre><br /><br /><br /></span><span style="font-family:times new roman;color:#333399;"></span>Laxmikanthttp://www.blogger.com/profile/05001791510755079172noreply@blogger.com4tag:blogger.com,1999:blog-5033701575826903286.post-46355335951673573092008-06-13T01:44:00.000-07:002008-06-13T02:00:49.907-07:00The file manifest.xml does not exist in the solution package !!<span style="font-family:times new roman;font-size:130%;color:#333399;">While doing solution deployment was hit upon with an error message :<br />"The file manifest.xml does not exist in the solution package". </span><span style="font-family:times new roman;color:#333399;"><br /><br /></span><span style="font-family:times new roman;color:#333399;"><br /><span style="font-size:130%;">After several attempts to figure out what was going wrong, noticed that the package size was getting limited to 1400 KB irrespective of wether I removed or added several files.</span><br /><span style="font-size:130%;"></span><br /><span style="font-size:130%;">Could overcome this by adding following lines (thanks to </span><a href="http://ph-tom.blogspot.com/2008/04/file-manifestxml-does-not-exist-in.html"><span style="font-size:130%;">this</span></a><span style="font-size:130%;"> ref) at the start of cab.ddf file.<br /><br /></span><span style="font-size:100%;">.Set CabinetFileCountThreshold=0<br />.Set FolderFileCountThreshold=0<br />.Set FolderSizeThreshold=0<br />.Set MaxCabinetSize=0<br />.Set MaxDiskFileCount=0<br />.Set MaxDiskSize=0</span><br /></span><span style="font-family:times new roman;color:#333399;"><br /><span style="font-size:130%;">This removes the file size limitations.</span></span><br /></span>Laxmikanthttp://www.blogger.com/profile/05001791510755079172noreply@blogger.com1tag:blogger.com,1999:blog-5033701575826903286.post-50901677964230025152008-06-13T01:42:00.000-07:002008-06-13T01:59:50.734-07:00Special Characters in filename in .wsp file<span style="font-family:times new roman;font-size:130%;color:#333399;">Was bitten by a wierd issue while working on Solution deployment recently :</span><span style="font-family:times new roman;color:#333399;"><br /><br /></span><span style="font-family:times new roman;color:#333399;"><span style="font-size:130%;">Error : Failed to extract the cab file in the solution</span><br /><span style="font-size:130%;"></span><br /><span style="font-size:130%;">Some rounds of checks helped to locate the cause. One of the file packaged had "@" in the filename. </span><br /><span style="font-size:130%;"><br />Hence be sure not to use any special characters in filename while getting the solution package ready.</span></span><br /></span>Laxmikanthttp://www.blogger.com/profile/05001791510755079172noreply@blogger.com1tag:blogger.com,1999:blog-5033701575826903286.post-79078516958381839002008-06-13T01:37:00.000-07:002008-06-13T01:58:51.117-07:00Default RowLimit in SPQuery<span style="font-family:times new roman;font-size:130%;color:#333399;">Fumbled upon a strange behavior when using "SPQuery". Used SPQuery in one of the places and found that it is not returning all the results from the List queried !!!!</span><span style="font-family:times new roman;color:#333399;"><br /><br /></span><span style="font-family:times new roman;color:#333399;"><br /><span style="font-size:130%;">There was no way of debugging to locate the culprit until some SDK documentation came to rescue saying that the default resultset rowlimit for SPQuery is 100. </span><br /><span style="font-size:130%;"></span><br /><span style="font-size:130%;">So make it a point to explicitly set it to some higher number :<br /></span><span style="font-size:100%;">query.RowLimit = 500;</span><br /><span style="font-size:130%;"></span><br /><span style="font-size:130%;">When using "Lists" webService available in MOSS 2007, GetListItems has a parameter rowlimit which would allow to set this rowlimit.</span><br /><span style="font-size:130%;"></span><br /><span style="font-size:130%;">Also when using SPQuery it bydefault would search only the current folder in the List. WSS v3.0 allows to search all subfolders in the same query using :<br /></span><span style="font-size:100%;">query.ViewAttributes = "Scope=\"Recursive\"";</span><br /><span style="font-size:130%;"></span><br /><span style="font-size:130%;">This is especially important when querying Discussion Board list as it uses Folder hierarchy to store all the replies for a particular topic.</span></span><br /></span>Laxmikanthttp://www.blogger.com/profile/05001791510755079172noreply@blogger.com1tag:blogger.com,1999:blog-5033701575826903286.post-72913276266013944742008-06-13T00:46:00.000-07:002008-06-13T01:57:04.428-07:00Getting an "There has been an error while processing the form." error while submitting a browser based InfoPath form :<span style="font-family:times new roman;font-size:130%;color:#333399;">While working on a Browser based InfoPath error was struck by an error message while submitting the form. </span><span style="font-family:times new roman;color:#333399;"><br /><br /></span><span style="font-family:times new roman;color:#333399;"><br /><span style="font-size:130%;">The intresting part was that the form was working perfectly when run from InfoPath client.</span><br /><br /><br /><span style="font-size:130%;">Something in the form was preventing it from getting submitted.Could not locate the culprit even after thorough recheck of logic.</span><br /><br /><br /><span style="font-size:130%;">Thanks to </span></span><a href="http://www.infopathdev.com/forums/p/5546/25579.aspx"><span style="font-family:times new roman;font-size:130%;color:#333399;">this</span></a><span style="font-family:times new roman;font-size:130%;color:#333399;"> thread for helping me to find that the cause was a Secondary data connection<br />that was not getting used anywhere in the main datasource.</span><br /></span>Laxmikanthttp://www.blogger.com/profile/05001791510755079172noreply@blogger.com4tag:blogger.com,1999:blog-5033701575826903286.post-56969550110173710312008-06-13T00:41:00.000-07:002008-06-13T01:56:11.749-07:00Error While trying to access Sharepoint List in subsite using Lists Webservice ?<span style="font-family:times new roman;font-size:130%;color:#333399;">I wanted to access the data from SharePoint List present on remote server in an utility. As the site was pesent on remote server, I used Lists WebService to access the data. </span><br /><br /><br /><span style="font-family:times new roman;font-size:130%;color:#333399;">I added the WebReference as : http://mainsite/subsite/_vti_bin/Lists.asmx<br />and tried to run the code only to be hit with a Soap Exception. </span><br /><span style="font-family:Times New Roman;font-size:130%;color:#333399;"></span><br /><br /><span style="font-family:times new roman;font-size:130%;color:#333399;">Following are the error details I got : </span><span style="font-family:times new roman;font-size:130%;color:#333399;"><br /></span><span style="font-family:times new roman;font-size:130%;color:#333399;"><span style="font-size:100%;">System.Web.Services.Protocols.SoapException was unhandled by user code<br />Message="Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown."<br />Source="System.Web.Services"<br />Actor=""<br />Lang=""<br />Node=""<br />Role=""<br />StackTrace:<br />at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)<br />at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)<br />at ProdLists.Lists.GetListItems(String listName, String viewName, XmlNode query, XmlNode viewFields, String rowLimit, XmlNode queryOptions, String webID) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\utility\f0b09a93\a4ef1a67\App_WebReferences.3-c5ghn5.2.cs:line 496<br />at _Default.Page_Load(Object sender, EventArgs e) in d:\Projects\Utility\Default.aspx.cs:line 45<br />at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)<br />at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)<br />at System.Web.UI.Control.OnLoad(EventArgs e)<br />at System.Web.UI.Control.LoadRecursive()<br />at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)</span><br /><br />Was unable to find the reason for this bahavior, however figured out that eventhough the reference was added to the WebService under subsite, it bydeault points to the Lists under mainsite or the top level site.</span><br /><br /><span style="font-family:times new roman;font-size:130%;color:#333399;">To tackle this I had to set the URL property expicitly at runtime. </span><br /><br /><br /><span style="font-family:times new roman;font-size:130%;color:#333399;">Following are the lines you will have to add to be able to access the lists under any subsite :</span><br /><br /><br /><span style="font-family:times new roman;color:#333399;">ProdLists.Lists prodService = new ProdLists.Lists();<br />prodService.UseDefaultCredentials = true;<br />prodService.Url = "http://mainsite/subsite/_vti_bin/Lists.asmx";<br /></span>Laxmikanthttp://www.blogger.com/profile/05001791510755079172noreply@blogger.com6tag:blogger.com,1999:blog-5033701575826903286.post-3665035994641979112008-06-13T00:26:00.000-07:002008-06-13T01:54:21.036-07:00Working with data from different SharePoint Fields<span style="font-size:130%;"><span style="font-family:times new roman;color:#333399;">Many times we spend lots of time in small tasks like understanding the format in which SharePoint data is stored internally when using object model to retrieve/store data in SharePoint lists. So thought of getting all in one place.</span> </span><br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg49-Dtj6-O1pv_aeFpe-FaRqnyaqGr43aFe0WgOVffbtxYR-LGmLqRTcVGzwVQj2DoWa2YtDlUasZsmqMfk6yUEFhbDBcOUa5wvJf2vUqj1tx__2lskeIFxy9Dp6n0ViVSdLi8MbEDh1jS/s1600-h/DataFormatTable.JPG"><span style="font-family:times new roman;color:#333399;"><img id="BLOGGER_PHOTO_ID_5211266305551774978" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg49-Dtj6-O1pv_aeFpe-FaRqnyaqGr43aFe0WgOVffbtxYR-LGmLqRTcVGzwVQj2DoWa2YtDlUasZsmqMfk6yUEFhbDBcOUa5wvJf2vUqj1tx__2lskeIFxy9Dp6n0ViVSdLi8MbEDh1jS/s400/DataFormatTable.JPG" border="0" /></span></a><span style="font-family:times new roman;"><span style="color:#333399;"> </span><br /></span><br /><div><span style="font-family:times new roman;font-size:130%;color:#333399;">Many of the field types like text, Number etc are straightforward to get/set.<br />A cleaner and professional way of working with the data from Fields would be to make use of Field Value Classes provided.<br /><br />Following Field Value classes are available:<br />SPFieldURLValue<br />SPFieldLookupValue<br />SPFieldUserValue<br />SPFieldMultiChoiceValue<br />SPFieldRatingscaleValue<br />SPFieldMultiColumnValue<br /><br /><br />Ex:<br />1) To retrieve value from URL field :<br /><br />SPListItem linkItem = SPContext.Current.Web.Lists["Links"].Items[0];<br />SPFieldUrlValue val = new SPFieldUrlValue(linkItem[SPBuiltInFieldId.URL].ToString());<br />string linkURL = val.Url;<br />string linkText = val.Description;<br /><br />2) To Save value in URL field :<br /><br />string linkURL = "http://www.samplesite.com/sampleweb";<br />string linkText = "SampleWebsite";<br />SPFieldUrlValue val = new SPFieldUrlValue();<br />val.Description = linkText;<br />val.Url = linkURL;<br />SPListItem linkItem = SPContext.Current.Web.Lists["Links"].Items.Add();<br />linkItem[SPBuiltInFieldId.URL] = val;<br />linkItem.Update();<br /><br />Following are some more references on this :<br /></span><a href="http://spdevguy.com/blogs/spdev/archive/2007/11/16/reading-field-data-with-sharepoint-s-field-value-classes.aspx"><span style="font-family:times new roman;font-size:130%;color:#333399;">http://spdevguy.com/blogs/spdev/archive/2007/11/16/reading-field-data-with-sharepoint-s-field-value-classes.aspx</span></a><span style="font-family:times new roman;font-size:130%;"><br /></span><span style="color:#333399;"><br /></span><a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfieldurlvalue.aspx"><span style="font-family:times new roman;font-size:130%;color:#333399;">http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfieldurlvalue.aspx</span></a><span style="font-family:times new roman;font-size:130%;"> </span></div>Laxmikanthttp://www.blogger.com/profile/05001791510755079172noreply@blogger.com1