1

Is it possible to change the watermark in Search box input? How can I do it?

Actually I want to redirect all my search to the searchcenter,at the same time i need dropdown(people,Conversation,Everything).If I use dropdown I couldnt rediredt to the searchcenter,and If I redirect to the exact Page I couldnt get the dropdown.How to solve this issue.

1
  • Hi and welcome to SP.SE @nit. I'm not really sure I understand what you want to accomplish. Can you edit the question and give a little more detail to the question?
    – Benny Skogberg
    Commented Nov 22, 2013 at 15:57

4 Answers 4

1

In 2013 the Search Box in the Search Center is a Display Template. You alter or add display templates through Design Manager for the Site Collection. The template for the Search Box is Control_SearchBox.html in that file there is a variable "prompt" that is used to set the value of the watermark. You can create a copy of the control template and then assign the Search box web part to use your modified control template.

If you are using the control in a Master page you can change the Render Template ID or try the Initial Prompt attribute, but this has not always been successful in Design Manager.

5
  • Hi Thanks for ur answer. it was working fine in search center and other default searchbox controls.But in masterpage I Couldnt make the change since Im using delegate control in master page.
    – nit
    Commented Nov 27, 2013 at 5:25
  • OK, you did not specify which search box. Did Alexanders approach work for you? Is it working? Commented Nov 27, 2013 at 12:39
  • After changing initial prompt attribute its working fyn in master page.but its not reflected in my site.
    – nit
    Commented Nov 27, 2013 at 13:37
  • Have you changed Sequence attribute? See explanation here
    – Alexander
    Commented Nov 27, 2013 at 14:07
  • ya I have changed it.For master page i have no prob now and for other pages it is working fine when i make change in Control_SearchBox.html but its not working in My site
    – nit
    Commented Nov 27, 2013 at 14:11
0

I'm not sure how it works in SP2013, but in SP2010 the text box is delegate control.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Control Id="SmallSearchInputBox" Sequence="50" 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>
    </Control>   
</Elements>

You can simply modify its definition (add <Property Name="QueryPromptString">New default text</Property>) and add it to a new feature. I hope it works for SP2013 :)

2
  • Hi thanks for the reply.Its not working for SP2013.
    – nit
    Commented Nov 27, 2013 at 5:26
  • Hi its not QueryPromptString its initial prompt attribute.
    – nit
    Commented Nov 27, 2013 at 13:39
0

For SharePoint 2013 here is what worked for me:

Use DesignManager to generate the correct snippet for the search box. Add it to your html file and regenerate the master page. You'll see the code as follows. At the top of the master page this reference is generated.

<%@Register TagPrefix="SearchWC" Namespace="Microsoft.Office.Server.Search.WebControls" Assembly="Microsoft.Office.Server.Search, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>

And in the body of the page where you added the search box, you'll see this code. Match the settings below, with your text in the property of InitialPrompt.

<div data-name="SearchBox">
<SearchWC:SearchBoxScriptWebPart 
      UseSiteCollectionSettings="false" 
      InitialPrompt="Custom Message" 
      EmitStyleReference="false" 
      ShowQuerySuggestions="false" 
      ChromeType="None" 
      UseSharedSettings="false" 
      TryInplaceQuery="false" 
      ServerInitialRender="true" 
      runat="server"  />
</div>

If you are using the Seattle or Olso master page, just add the reference at the top and replace the existing search box with the one above.

-1

Below function is working . you can put either in master page or in .js file that is reference in master page.

$(function () {
    var theSearchBox = $('ctl00_PlaceHolderSearchArea_ctl00_S3031AEBA_InputKeywords');
    var ctl00_PlaceHolderSearchArea_ctl00_ctl04 = '0';
    var preferredSearchText = "Enter Search Term";
    document.getElementById('ctl00_PlaceHolderSearchArea_ctl00_S3031AEBA_InputKeywords').value = preferredSearchText;

    $("#ctl00_PlaceHolderSearchArea_ctl00_S3031AEBA_InputKeywords").bind("focus", function (e) {
        if (ctl00_PlaceHolderSearchArea_ctl00_ctl04 == '0') {
            this.value = '';
            if (this.className == 's4-searchbox-QueryPrompt') {
                this.className = '';
            }
            else this.className = this.className.replace(' s4-searchbox-QueryPrompt', '');

            //document.getElementById('ctl00_PlaceHolderSearchArea_ctl00_ctl04').value = 1;
            ctl00_PlaceHolderSearchArea_ctl00_ctl04 = 1;
        }

    });
    $("#ctl00_PlaceHolderSearchArea_ctl00_S3031AEBA_InputKeywords").bind("blur", function (e) {
          if (this.value == '') {
            this.value = preferredSearchText;
            if (this.className.indexOf('s4-searchbox-QueryPrompt') == -1)
                this.className += this.className ? ' s4-searchbox-QueryPrompt' : 's4-searchbox-QueryPrompt';
           ctl00_PlaceHolderSearchArea_ctl00_ctl04 = '0';
        }
        else {
           ctl00_PlaceHolderSearchArea_ctl00_ctl04 = '1';
        }

    });


});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.