<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SharePointBlog.nl &#187; SearchBoxEx</title>
	<atom:link href="http://www.sharepointblog.nl/tag/searchboxex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sharepointblog.nl</link>
	<description>Michiel Lankamp</description>
	<lastBuildDate>Wed, 26 May 2010 09:37:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>SearchBox changed in October Cumulative Update</title>
		<link>http://www.sharepointblog.nl/2010/01/28/searchbox-changed-in-october-cumulative-update/</link>
		<comments>http://www.sharepointblog.nl/2010/01/28/searchbox-changed-in-october-cumulative-update/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 16:48:15 +0000</pubDate>
		<dc:creator>Michiel</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[Multilingual]]></category>
		<category><![CDATA[October update]]></category>
		<category><![CDATA[ScopeDisplayGroupName]]></category>
		<category><![CDATA[SearchBoxEx]]></category>

		<guid isPermaLink="false">http://www.sharepointblog.nl/2010/01/28/searchbox-changed-in-october-cumulative-update/</guid>
		<description><![CDATA[The problem With the introduction of the October Cumulative Update for SharePoint 2007 I encountered a problem with the search box on multilingual sites. After the installation of the update the scopes dropdown list always uses the same scope display group. After investigation I found that the language of the root web is used to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.sharepointblog.nl%2F2010%2F01%2F28%2Fsearchbox-changed-in-october-cumulative-update%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.sharepointblog.nl%2F2010%2F01%2F28%2Fsearchbox-changed-in-october-cumulative-update%2F&amp;source=m_lampje&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<h3>The problem</h3>
<p>With the introduction of the October Cumulative Update for SharePoint 2007 I encountered a problem with the search box on multilingual sites. After the installation of the update the scopes dropdown list always uses the same scope display group. After investigation I found that the language of the root web is used to determine the scope display group.</p>
<h3>The cause</h3>
<p>This behavior was not present in the control prior to the October update, in the description of the update (KB975731) we found:</p>
<blockquote><p>&quot;All sites,&quot; &quot;People,&quot; and &quot;This site&quot; search scopes are available only for English language sites. Sites that are written in other languages show only the &quot;This site&quot; search scope.</p>
</blockquote>
<p>This explains that the control has been changed in this update.</p>
<h3>The reason</h3>
<p>Before the October Update the property ScopeDisplayGroupName is set in the constructor of the SearchBoxEx control:</p>
<pre class="csharpcode"><span class="kwrd">this</span>._ScopeDisplayGroupName =
    SearchCommon.GetLocResourceString(
        LocStringId.ScopeDisplayGroup_SearchDropdown_Name);</pre>
<p>In the October Update this line of code has been changed to:</p>
<pre class="csharpcode"><span class="kwrd">this</span>._ScopeDisplayGroupName = GetScopeDisplayGroupNameDefaultValue();</pre>
</p>
<p>This function uses the language from the root web is to determine the value for the ScopeDisplayGroupName property:</p>
<pre class="csharpcode"><span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">string</span> GetScopeDisplayGroupNameDefaultValue()
{
    <span class="kwrd">if</span> (SPContext.Current != <span class="kwrd">null</span>)
    {
        <span class="kwrd">while</span> (SPContext.Current.Site != <span class="kwrd">null</span>)
        {
            <span class="typ">CultureInfo</span> siteCollectionCulture = <span class="kwrd">null</span>;
            SPSecurity.RunWithElevatedPrivileges(<span class="kwrd">delegate</span> {
                siteCollectionCulture = <span class="kwrd">new</span> CultureInfo(
                    (<span class="kwrd">int</span>) SPContext.Current.Site.RootWeb.Language);
            });
            <span class="kwrd">return</span> StringResourceManager.GetString(
                LocStringId.ScopeDisplayGroup_SearchDropdown_Name,
                    siteCollectionCulture);
        }
    }

    <span class="kwrd">return</span> SearchCommon.GetLocResourceString(
            LocStringId.ScopeDisplayGroup_SearchDropdown_Name);
}</pre>
<h3>The solution</h3>
<p>For this website I want the value for the ScopeDisplayGroupName property to be based on the culture of the current web. To re-enable this functionality we updated our custom master page and added the following to the SearchBoxEx control:</p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">sharepoint:searchboxex</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> ...
 <span class="attr">ScopeDisplayGroupName</span><span class="kwrd">=&quot;&lt;%$Resources:searchfix,ScopeDisplayGroup_SearchDropdown_Name%&gt;&quot;</span> <span class="kwrd">/&gt;</span></pre>
<p>In the App_GlobalResources I added custom resource files with the correct translations for the resource key ScopeDisplayGroup_SearchDropdown_Name.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sharepointblog.nl/2010/01/28/searchbox-changed-in-october-cumulative-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customize SearchBoxEx</title>
		<link>http://www.sharepointblog.nl/2007/10/16/customize-searchboxex/</link>
		<comments>http://www.sharepointblog.nl/2007/10/16/customize-searchboxex/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 22:52:54 +0000</pubDate>
		<dc:creator>Michiel</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[SearchBoxEx]]></category>

		<guid isPermaLink="false">http://www.sharepointblog.nl/?p=29</guid>
		<description><![CDATA[A external company made a design for a Internet facing website, in the design the search control was made up in to rows. So my first idea was to create a new controltemplate for the SmallSearchInputBox, but then I realized that in moss the search-control isn&#8217;t a controltemplate anymore (in WSS it is). The searchbox [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.sharepointblog.nl%2F2007%2F10%2F16%2Fcustomize-searchboxex%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.sharepointblog.nl%2F2007%2F10%2F16%2Fcustomize-searchboxex%2F&amp;source=m_lampje&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>A external company made a design for a Internet facing website, in the design the search control was made up in to rows. So my first idea was to create a new controltemplate for the SmallSearchInputBox, but then I realized that in moss the search-control isn&#8217;t a controltemplate anymore (in WSS it is). The searchbox in MOSS is a control called <a href="http://msdn2.microsoft.com/ms518994.aspx" target="_blank">SearchBoxEx</a>, and this has some properties for the layout of the control. But is always renders the output as a table with 1 row, so my problem was how to render is in 2 rows using divs. Google didn&#8217;t provide me with an answer, so is started coding myself (I don&#8217;t want to create a new control with all logic, I just want reuse all the logic of SearchBoxEx and provide new render logic).</p>
<p>I finally found a way to do this, I just create an new control that inherits from SearchBoxEx. My custom look-and-feel can be done used an override of the CreateChildControls:<br />
<!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre class="csharpcode"><span class="kwrd">protected</span> <span class="kwrd">override</span> <span class="kwrd">void</span> CreateChildControls( )
{
    <span class="kwrd">base</span>.CreateChildControls( );

    <span class="kwrd">if</span> ( Controls.Count &lt; 2 )
    {
        <span class="kwrd">return</span>;
    }

    HyperLinkLoc hlink = <span class="kwrd">null</span>;
    <span class="kwrd">if</span> ( Controls[ 1 ].GetType( ) == <span class="kwrd">typeof</span> ( Table ) )
    {
        Table tabel = ( Table ) Controls[ 1 ];

        <span class="rem">// Loop through cells to find the go button</span>
        <span class="kwrd">foreach</span> ( TableCell cell <span class="kwrd">in</span> tabel.Rows[ 0 ].Cells )
        {
            <span class="kwrd">if</span> ( cell.Controls.Count &gt; 0 )
            {
                <span class="kwrd">if</span> ( cell.Controls[ 0 ].GetType( ) == <span class="kwrd">typeof</span> ( HyperLinkLoc ) )
                {
                    hlink = ( HyperLinkLoc ) cell.Controls[ 0 ];
                }
            }
        }
        tabel.Visible = <span class="kwrd">false</span>;</pre>
<p>I first call the base.CreateChildControls to have SearchBoxEx create all the controls based on the properties set. Then I start looping through the tablecells to find the Go-button, the other controls (textbox &amp; dropdownlist) are available as protected members. After the go-button has been found, I set the table to invisible. Now that I have a reference to the controls I can start building my own look-and-feel:<br />
<!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre class="csharpcode">        <span class="kwrd">if</span> ( m_searchKeyWordTextBox != <span class="kwrd">null</span> )
        {
            HtmlGenericControl div = <span class="kwrd">new</span> HtmlGenericControl( <span class="str">"div"</span> );
            div.Attributes.Add( <span class="str">"class"</span>, <span class="str">"ms-sbcell"</span> );
            m_searchKeyWordTextBox.Style.Clear( ); <span class="rem">// remove the width style, done in css</span>
            div.Controls.Add( m_searchKeyWordTextBox );
            Controls.Add( div );
        }

        <span class="kwrd">if</span> ( hlink != <span class="kwrd">null</span> )
        {
            HtmlGenericControl div3 = <span class="kwrd">new</span> HtmlGenericControl( <span class="str">"div"</span> );
            div3.Attributes.Add( <span class="str">"class"</span>, <span class="str">"ms-sbgo ms-sbcell"</span> );
            div3.Controls.Add( hlink );
            Controls.Add( div3 );
        }

        <span class="kwrd">if</span> ( m_ddlScopes != <span class="kwrd">null</span> )
        {
            HtmlGenericControl div2 = <span class="kwrd">new</span> HtmlGenericControl( <span class="str">"div"</span> );
            div2.Attributes.Add( <span class="str">"class"</span>, <span class="str">"ms-sbscopes ms-sbcell"</span> );
            div2.Controls.Add( m_ddlScopes );
            Controls.Add( div2 );
        }
    }
}</pre>
<p>Download source: <a href="http://www.sharepointblog.nl/wp-content/uploads/2007/10/searchbox.cs" target="_blank">searchbox</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sharepointblog.nl/2007/10/16/customize-searchboxex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
