Wednesday, March 21, 2012

Search box disappears on search result page. - SharePoint 2010 Custom Master page 
[How to Stop That]

we are using our own master pages specially when it comes to the commercial system development (even sometimes we use V4 master page most of the tie we changed it or configure it according to the requirement). so we use search box with in our master page and it works fine. the problem here is when it comes to the search result page. The upper search box got disappear.

[In other pages search box is there]

[In Result page it disappear form the top]


I was wondering what happen there and it took about an hour to figure it out, what happen inside that.

What connection with PlaceHolderSearchArea
it's all stick with content place holder named or got id as "PlaceHolderSearchArea". search box placed inside that .

<!-- ------------| SEARCH BOX  |------------ -->
       <!-- search box loads from delegate, style with CSS -->
       <div class="s4-notdlg">
    <asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server"> 
<SPSWC:SearchBoxEx id="SearchBox" RegisterStyles="false" TextBeforeTextBox="" TextBoxWidth="50" GoImageUrl="<% $SPUrl:~sitecollection/Style Library/Images/search_icn.gif %>"
GoImageActiveUrl="<% $SPUrl:~sitecollection/Style Library/Images/search_icn.gif %>" GoImageUrlRTL="<% $SPUrl:~sitecollection/Style Library/Images/search_icn.gif %>"
GoImageActiveUrlRTL="<% $SPUrl:~sitecollection/Style Library/Images/search_icn.gif %>" UseSiteDefaults="false" DropDownMode="HideScopeDD" SuppressWebPartChrome="true"
runat="server" WebPart="true" __WebPartId="{0043945F-2D2B-4A02-8510-CED13B6F04DF}" SearchResultPageURL="<% $SPUrl:~sitecollection/pages/searchresult.aspx %>"  QueryPromptString="Search here..."/>

   </asp:ContentPlaceHolder>   
       
       </div>
       <!-- ------------| SEARCH BOX  |------------ -->



So You would need to remove the search box from the PlaceHolderSearchArea as that is the control that is replaced or disappears, when the search result page renders. but you need to make sure that you don't delete it (if you do that It'll get error when load result page)

so all you need to do is just create new place holder with different name Eg: PlaceHolderSearchArea1 and make previous one visible false using it's property and place your search box inside the newly created placeholder.


<!-- ------------| SEARCH BOX  |------------ -->
       <!-- search box loads from delegate, style with CSS -->
       <div class="s4-notdlg">
    <asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server" Visible="false"></asp:ContentPlaceHolder>

    <asp:ContentPlaceHolder id="PlaceHolderSearchArea1" runat="server">

<SPSWC:SearchBoxEx id="SearchBox" RegisterStyles="false" TextBeforeTextBox="" TextBoxWidth="50" GoImageUrl="<% $SPUrl:~sitecollection/Style Library/Images/search_icn.gif %>"
GoImageActiveUrl="<% $SPUrl:~sitecollection/Style Library/Images/search_icn.gif %>" GoImageUrlRTL="<% $SPUrl:~sitecollection/Style Library/Images/search_icn.gif %>"
GoImageActiveUrlRTL="<% $SPUrl:~sitecollection/Style Library/Images/search_icn.gif %>" UseSiteDefaults="false" DropDownMode="HideScopeDD" SuppressWebPartChrome="true"
runat="server" WebPart="true" __WebPartId="{0043945F-2D2B-4A02-8510-CED13B6F04DF}" SearchResultPageURL="<% $SPUrl:~sitecollection/pages/searchresult.aspx %>"  QueryPromptString="Search here..."/>

  </asp:ContentPlaceHolder>
       
       </div>
       <!-- ------------| SEARCH BOX  |------------ -->


then it will work fine.


ok That's It ... 
HAPPY CODING




No comments:

Post a Comment