SmallSearchInputBox 기본 텍스트 사용자 정의
-
09-12-2019 - |
문제
내 SharePoint 사이트의 검색 창에 표시된 텍스트를 사용자 정의하려고합니다.기본값은 "이 사이트 검색 ..."입니다.
나는 그것을하는 방법을 설명하는 여러 기사를 발견했으며, (낮은 시퀀스 번호로 대리인 제어를 무시하고) 잘 작동합니다.
내 XML은 다음과 같습니다 :
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control
Id="SmallSearchInputBox"
Sequence="10"
ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx" ControlAssembly="Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<Property Name="GoImageUrl">/_layouts/images/gosearch15.png</Property>
<Property Name="GoImageUrlRTL">/_layouts/images/gosearchrtl15.png</Property>
<Property Name="GoImageActiveUrl">/_layouts/images/gosearchhover15.png</Property>
<Property Name="GoImageActiveUrlRTL">/_layouts/images/gosearchrtlhover15.png</Property>
<Property Name="DropDownMode">ShowDD</Property>
<Property Name="SearchResultPageURL">/_layouts/osssearchresults.aspx</Property>
<Property Name="ScopeDisplayGroupName"></Property>
<Property Name="FrameType">None</Property>
<Property Name="QueryPromptString">DO A SEARCH!</Property>
</Control>
</Elements>
.
이 작업이 잘 작동하므로 검색 상자에 "검색해라!"예상대로.그러나이 문자열을 현지화하고 싶습니다.내가 할 때
<Property Name="QueryPromptString">$Resources:MyResourceFile,CustomText;</Property>
.
검색 상자에는 $ 리소스가 표시됩니다. MyResourceFile, CustomEtext;그것을 평가하는 대신에 깔끔하게.
현지화 된 문자열을 어떻게 넣으려면?
감사합니다!
해결책
Line <Property Name="QueryPromptString">$Resources:MyResourceFile,ResourceKey</Property>
Wokrs는 나를 위해 괜찮습니다.
리소스 파일을 확인해야한다고 생각합니다.이 파일에는이 속성에서 사용할 ResourceKey가 포함되어야합니다.
올바른 자원 파일과 키를 사용하면 검색 제어에 텍스트가 사이트 언어에 따라 다릅니다.아래 그림에서 볼 때이 텍스트를 동적으로 변경하려면 몇 가지 복잡한 단계를 수행해야합니다.
단계 :
- 사용자 정의 클래스를 만들고 SearchBoxEx 에서 상속받습니다.
- 새로운 QueryPromptString 속성 만들기
- 안전 제어 정의
- 대리인 컨트롤 만들기
단계 코드 :
.public class SearchBox : SearchBoxEx { [Browsable(false)] public new string QueryPromptString { get { return base.QueryPromptString; } set { string fullKey = string.Format("$Resources:{0}", value); base.QueryPromptString = SPUtility.GetLocalizedString(fullKey, null, (uint)Thread.CurrentThread.CurrentUICulture.LCID); } } } <Control Id="SmallSearchInputBox" Sequence="10" ControlClass="LocalizedSearch.SearchBox" ControlAssembly="LocalizedSearch, Version=1.0.0.0, Culture=neutral, PublicKeyToken=71df3f77c17b7c69"> <Property Name="GoImageUrl">/_layouts/images/gosearch15.png</Property> <Property Name="GoImageUrlRTL">/_layouts/images/gosearchrtl15.png</Property> <Property Name="GoImageActiveUrl">/_layouts/images/gosearchhover15.png</Property> <Property Name="GoImageActiveUrlRTL">/_layouts/images/gosearchrtlhover15.png</Property> <Property Name="DropDownMode">ShowDD</Property> <Property Name="SearchResultPageURL">/_layouts/osssearchresults.aspx</Property> <Property Name="ScopeDisplayGroupName"></Property> <Property Name="FrameType">None</Property> <Property Name="QueryPromptString">filename,key</Property> </Control>
제휴하지 않습니다 sharepoint.stackexchange