Strange issue with Application Page and Two Button Presses

Okay, this one was weird. The symptom is this – I had a custom Application page that was being used as the New and Edit forms for a particular custom list in my solution. One of the customisations was that it had an ‘Address Search’ button that, when you pressed, searched for an address based on the first line of the address, or the postcode.

That’s fine, but here’s where things got weird.

  • If you were using the form as a New form, then search worked just fine the first time you clicked it.
  • If you were using the form as an Edit form, the the search button didn’t work the first time you use it – but did the second time you clicked on it.

Bizarre, and I had to fix it… Continue reading “Strange issue with Application Page and Two Button Presses”

Advertisement
Strange issue with Application Page and Two Button Presses

Declaratively Point a Site Collection at a Search Center

Yesterday I wrote about the SmallSearchInputBox, how scopes only appear if you set a search center for the site collection, and how to set the Search Center in code.

Well, as is typically the way with CAML, I figured out how to do this declaratively later. Or, more specifically, I found that there is a feature I could call declaratively that would do what I want:

search-center-url-feature

<!-- SearchCenter Url feature -->
<Feature ID="7AC8CC56-D28E-41f5-AD04-D95109EB987A" >
<Properties xmlns="http://schemas.microsoft.com/sharepoint/">
<Property Key="SearchCenterUrl" Value="~SiteCollection/Search/" />
</Properties>
</Feature>

Yup, all I need to do is put that into my site definition…

Declaratively Point a Site Collection at a Search Center

Programmatically configure the Small Search Box to show scopes

Sharepoint’s ‘ordinary’ sites, such as Team Sites or Blank Sites, have a small search box (the SmallSearchInputBox) at the top which does not show search scopes, as we would be used to in a Collaboration Portal, for example…

search-blank-site-default

The reason for this is that they are not, by default, pointed at a particular Search Center – so they don’t have any idea what scopes to show. However, you can set this through the Site collection Search Settings…

search-site-collection-settings

And suddenly, your search scopes appear! Hurrah!

search-blank-site-now-with-scopespng

Now, what if we are creating a bunch of site collections? (Our current project could create quite a lot of site collections. And we need them created automatically, as required). Can we point them to a specific search center automatically? Continue reading “Programmatically configure the Small Search Box to show scopes”

Programmatically configure the Small Search Box to show scopes

Changing the SmallSearchInputBox delegate control

A colleague of mine was wanting to make some changes to the SmallSearchInputBox delegate control in SharePoint 2007. That’s the control that appears on most pages, looking like:

SmallSearchInputBox

This control is a ‘Delegate control’ – that is, you can create features to override the currently used control. What my colleague wanted to do was not display the ‘Scope’ drop down list, the Advanced Search link, and to include prompt text (something like ‘Enter Search…’). A quick dig into the FEATURES folder in 12 Hive showed that the control had a number of properties.

(The features that this information applies to are the OSearchBasicFeature and OSearchEnhancedFeature. Both contain files called ‘SearchArea.xml’, and that contains the code below. I found the folders with this in:

%12 Hive%TemplateFeaturesOSearchBasicFeature

%12 Hive%TemplateFeaturesOSearchEnhancedFeature )

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control
Id="SmallSearchInputBox"
Sequence="25"
ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx" ControlAssembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<Property Name="GoImageUrl">/_layouts/images/gosearch.gif</Property>
<Property Name="GoImageUrlRTL">/_layouts/images/goRTL.gif</Property>
<Property Name="GoImageActiveUrl">/_layouts/images/gosearch.gif</Property>
<Property Name="GoImageActiveUrlRTL">/_layouts/images/goRTL.gif</Property>
<Property Name="UseSiteDefaults">true</Property>
<Property Name="FrameType">None</Property>
<Property Name="ShowAdvancedSearch">true</Property>
</Control>
</Elements>

This shows a property ShowAdvancedSearch which sounded pretty promising for turning off the Advanced Search link. We decided to see what other properties were available, and found a good article by Clint Cherry about the SmallSearchInputBox control, and the MSDN docs. The Property tags in the XML for the delegate control set the properties of the web control class – e.g. GoImageUrl matches the GoImageUrl property on the class. Much to our pleasure, we found the QueryPromptString displays text in the search control which vanishes when it receives focus, and the DropDownMode property allows us to turn off the scope dropdown list. Hurrah!

For the values that you can set the drop down mode to, see the MSDN docs again

Changing the SmallSearchInputBox delegate control