0

We have a sharepoint site where the main home page is branded using our custom masterpage. Some of the subsites don't use the custom masterpage and instead use seattle.

Initially when I created the custom masterpage, i over-rode the "smallSearchInputBox" so that we could use our own magnifying-glass image and properly format the searchbox. This worked but it caused a problem with the smallSearchInputBox on the Seattle page which i don't want branded.

Because of that I created a brand new custom delegate control that draws a searchbox. That way i can use my new delegate control on the custom masterpage and OOTB searchbox can be used on the Seattle pages.

My delegate control works and injects the following code where i want it on the custom masterpage.

Unfortunately the new searchbox just doesn't work. That is, hitting enter or clicking on the search image doesn't search anything.

I'm looking for information on what i need to do to create a working searchbox. Everything i've found so far only refers to overriding the OOTB searchbox and not creating a brand new one.

<div id="SearchBox" name="Control">
        <div class="ms-srch-sb" id="ctl00_SmallSearchInputBox_csr_sboxdiv">
            <input type="text" value=" " maxlength="2048" class="ms-textSmall"
                accessKey="S"
                title="Search this site"
                id="ctl00_SmallSearchInputBox_csr_sbox" autocomplete="off" autocorrect="off" 
                onkeypress="if (Srch.U.isEnterKey(String.fromCharCode(event.keyCode))) { $getClientControl(this).search(this.value);return Srch.U.cancelEvent(event); }" 
                onkeydown="var ctl = $getClientControl(this);ctl.activateDefaultQuerySuggestionBehavior();"
                onfocus="var ctl = $getClientControl(this);ctl.hidePrompt();ctl.setBorder(false);" 
                onblur="var ctl = $getClientControl(this);ctl.showPrompt();ctl.setBorder(false);" />

        <a title="Search" class="ms-srch-sb-searchLink" id="ctl00_SmallSearchInputBox_csr_SearchLink" 
                onclick="$getClientControl(this).search($get('ctl00_SmallSearchInputBox_csr_sbox').value);" href="javascript: {}">
                <img src="/_layouts/15/DRDC.Sharepoint.Branding/images/magnifying-glass.png" class="drdc-navImg" id="DRDCnavImg" alt="Navigation" />
                </a>

        </div>

  • If the problem is just that you don't want your custom styling to apply when not using your custom master page, couldn't you just add another wrapper div around the smallSearchInputBox on your custom master page that would help you target the CSS more precisely? – Dylan Cristy Nov 23 '15 at 20:08
  • Thanks. I'm not sure why i didn't think of that. :-/ Probably the best & easiest way to go at this point. – C. Poulain Nov 24 '15 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.