Visual Studio 2010 replacement parameters for SharePoint projects




March 21, 2012 —  (Page 1 of 2)
When building custom artifacts for SharePoint 2010, developers often need to reference post-project data at design time. A good example of this would be a reference to a fully qualified class name when developing a Web Part: When the “Web Part” Project Item is selected from Visual Studio’s “Add New Item” menu, a .webpart file is automatically generated:

<?xml version="1.0" encoding="utf-8"?>
<webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
      <type name="MastSPTechCon.WebPart1, $SharePoint.Project.AssemblyFullName$" />
      <importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="Title" type="string">WebPart1</property>
        <property name="Description" type="string">My WebPart</property>
      </properties>
    </data>
  </webPart>
</webParts>

Specifically, notice the token found between the two dollar signs: $SharePoint.Project.AssemblyFullName$. When the project goes through the packaging process, Visual Studio actually parses all of the files in the packaging folder, searches for files with specific file extensions, and replaces this token with the project’s fully qualified assembly name. This is convenient since it effectively allows developers to safely rename projects and assemblies without having to worry about refactoring all of the markup contained within the projects.

Pages 1 2 


Share this link: http://www.sptechweb.com/link/36460


Comments


04/22/2012 03:04:48 PM EST

Yes, there is a work around.If you add gmarin-right:10px;' to the .ms-standardheader.ms-WPTitle class, the right corner will be round if the action arrow isn't visible. The trick you have to pull is find out when the arrow isn't shown. To accomplish this, you have to write some javascript that looks in the page to find if the right corner of webparts is there. Here it is://find all WPHeaders in IE (DIV)var arr = document.getElementsByTagName( DIV );var str = 0;for (i = 0; i < arr.length; i++) { if(arr[i].className == ms-HoverCellInActive') str = str + 1;}In Mozilla the right corner is not rendered as DIV, so you need to look for the IMG elements with the same className. So you need to look at the browser in javascript code and then write separate codes for IE and other browsers.Next, you have to build a separate stylesheet for the no action arrow scenario and use javascript again to switch between stylesheets based on the value of str.There it is. They say it's robot labor, but it really isn't.

Wallis and FutunaAmy


04/22/2012 08:58:07 PM EST

Hi,Great Post!. But i have one query.The scenario is : I have creetad one MOSS 2007 publishing site. In this site i have creetad few Custom Web Parts. Now in each webpart i want the same output as u have described here.And i am able to get the same output when user is logged in as Administrative. Now when user is having anonymous access at that time the dropdown will not display and cause of that the right side corner is not going to be display. I want to display that right side curve image when user is having anonymous access. Can u help me for this.

YemenMiszsosy


 
 
This site's content Copyright © 1999 - 2014 by BZ Media LLC, All rights reserved.
Legal and Privacy
Phone: +1 (631) 421-4158 • E-mail: info@bzmedia.com