1

I am trying to search using the default search control from sharepoint.

<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">  
    <SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox"/>    
</asp:ContentPlaceHolder>

But when using the search button it calls the Js function defined in core.js as bellow:

function SubmitSearchRedirect(strUrl)
{
        var frm=document.forms["frmSiteSearch"];

        if (frm==null)
        {
            if (typeof(MSOWebPartPageFormName) !="undefined")
                frm=document.forms[MSOWebPartPageFormName];
        }
        if (frm !=null)
        {
            var searchText=frm.elements["SearchString"].value; //ERROR IN HERE
            strUrl=strUrl+"?k="+escapeProperly(searchText);
            var searchScope=frm.elements["SearchScope"];
            if (searchScope !=null)
            {
                var searchScopeUrl=searchScope.value;
                if (searchScopeUrl)
                {
                    strUrl=strUrl+"&u="+escapeProperly(searchScopeUrl);
                }
            }
            frm.action=strUrl;
            frm.submit();
        }
} 

It passes the 3 first ifs and generates an error on the line:

  var searchText=frm.elements["SearchString"].value;

with the error message:

TypeError: frm.elements.SearchString is undefined

This method is concatenating the queryString for the url bellow (if I access the method it works correctly), is a simple POST.

http://www.siteName/_layouts/searchresults.aspx?k=SEARCHINHERE&u=SCOPEADDRESS

Where k => query and u=> scope.

If somebody knows a workaround or how to solve this problem, please let me know.

  • Ok @Mike done !!! – Tito Jun 18 '13 at 18:15
0

The problem was:

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

was not inside a form. I just added a form and it worked.

Your Answer

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

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