WSS3SDK之如何定制一个委托控件2010-11-14 博客园 Sunmoonfire步骤通过拷贝默认的 TEMPLATEFEATURESContentLightup文件夹,在 Local_Drive:/Program Files/Common Files/Microsoft Shared/web server extensions/12/TEMPLATE/FEATURES 下创建一个名为 NewSearchBox 的文件夹。XML<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="GUID"
Title="New Search Image"
Description="Points at which third partIEs light up in content pages"
Version="12.0.0.0"
Scope="WebApplication"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="controlssearcharea.xml" />
</ElementManifests>
</Feature>
在 NewSearchBox 文件夹中,修改已有的 Feature.xml 文件,通过运行 guidgen.exe (位于 Local_Drive:Program FilesMicrosoft Visual Studio 8Common7Tools)来生成新的GUID。在Controls子文件中,修改searcharea.xml文件,它引用了一个可替换的.ascx文件,如下。XML<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control
Id="SmallSearchInputBox"
Sequence="100"
ControlSrc="~/_controltemplates/mySearchArea.ascx">
<Property Name="SearchTextToolTip">Search this site</Property>
<Property Name="SearchImageToolTip">Go</Property>
</Control>
</Elements>
在 TEMPLATECONTROLTEMPLATES下, 拷贝SearchArea.ascx 文件 , 并重命名拷贝得到的文件为mySearchArea.ascx。在您拷贝得到的.ascx文件末尾,找到<img>标签,修改其src属性指向替换后的图片文件。为了测试,您可以使用安装在TEMPLATEIMAGES下的默认图片文件,下面的例子中,简单的用FOLDER.GIF替换了原来的gosearch.gif。<INPUT Type=TEXT id="idSearchString" size=25 style="vertical-align: 2" name="SearchString" display="inline" maxlength=255 ACCESSKEY=S class="ms-searchbox" onKeyDown="return SearchKeyDown(event, <%=strEncodedUrl%>);" title=<%SPHttpUtility.AddQuote(SPHttpUtility.HTMLEncode(SearchTextToolTip),Response.Output);%>>
<IMG SRC="/_layouts/images/blank.gif" width=4 height=1 alt="">
<a target="_self" href="javascript:" onClick="javascript:SubmitSearchRedirect(<%=strEncodedUrl%>);javascript:return false;" title=<%SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SearchImageToolTip),Response.Output);%> ACCESSKEY=O ID=onetIDGoSearch>
<img border="0" src="/_layouts/images/FOLDER.GIF" style="vertical-align: 1"alt=<%SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SearchImageToolTip),Response.Output);%>></a>
</span>
</nobr>
在命令行中,输入下列命令来安装并在特定子网站上激活该Feature。a. stsadm -o installfeature -filename NewSearchBoxfeature.xmlb. stsadm -o activatefeature -filename NewSearchBoxfeature.xml -url http://Server/Site/Subsite导航到该子网站中来查看对搜索框右侧图片的变更。