Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
    
Put your solution as an answer and mark it as the accepted answer. –  Mike Jun 18 '13 at 18:12
    
Ok @Mike done !!! –  Tito Jun 18 '13 at 18:15

1 Answer 1

up vote 0 down vote accepted

The problem was:

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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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