Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity 3.x: 3.x Pre-release forums (retired) > Setting the index of search module at runtime

Setting the index of search module at runtime

  • puneet avatar

    Posted on Mar 17, 2008 (permalink)


    I made 4 index for search module and i want to set the index at runtime based on the value selected in the dropdown box.

    How i can do that.....

    Reply

  • Pepi Pepi admin's avatar

    Posted on Mar 17, 2008 (permalink)

    Hi puneet,

    Here is a simple example how to achieve this with a User Control wrapping the SearchBox control that is shipped with Sitefinity:

    .ascx
    <%@ Register Assembly="Telerik.Search" Namespace="Telerik.Search.WebControls" TagPrefix="sitefinity" %> 
     
    <div> 
        <asp:DropDownList ID="IndexCatalogue" runat="server" AutoPostBack="true" OnSelectedIndexChanged="SearchIndexes_SelectedIndexChanged"></asp:DropDownList> 
    </div> 
    <div> 
        <sitefinity:SearchBox ID="SearchBox1" runat="server" ResultUrl="~/ResultUrlPage.aspx"></sitefinity:SearchBox> 
    </div> 

    .ascx.cs
        protected void Page_Load(object sender, EventArgs e) 
        { 
            if (!IsPostBack) 
            { 
                this.BindIndexCatalogue(); 
            } 
        } 
     
        protected void SearchIndexes_SelectedIndexChanged(object sender, EventArgs e) 
        { 
            this.SearchBox1.IndexCatalogue = ((ListControl)sender).SelectedValue; 
        } 
     
        void BindIndexCatalogue() 
        { 
            this.IndexCatalogue.DataSource = IndexingManager.IndexingServices.Values; 
            this.IndexCatalogue.DataTextField = "Name"
            this.IndexCatalogue.DataValueField = "Name"
            this.IndexCatalogue.DataBind(); 
     
            this.IndexCatalogue.Items.Insert(0, new ListItem("Please, select an index"string.Empty)); 
        } 

    After creating the control you need to upload it in the "Add Controls" toolbox. For more information, please, refer to the User Manual -> Working with Controls.

    Hope this is helpful for you.

    Greetings,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

    Reply

  • puneet avatar

    Posted on Mar 17, 2008 (permalink)

    i made user control containg the code u specified but when i am building the web site than it is showing the error that "IndexingManager is not defined"
    Do i need toinclude any telerik framework in my cs class of the user control?

    Other than that r u understanding my problem completely or not .I want to tell u once again the exact problem

    Problem is:

    In sitefinty serah control there is a textbox in which we will eneter some string right?
    i already made four indexes to search

    Now i want user to enable to select one of the search index for search module
    So i place a dropdown right beneath the textbox of search module to have the user entry..

    Based on the user entry i have to select one of the index made by me for searching 

    this is my problem
    i am
    Suppose we place search module on our page and than we are editing 

    Reply

  • puneet avatar

    Posted on Mar 18, 2008 (permalink)

    I made user control as you specified .but after uploading the user control ,No control gets added in sitefinty control section..

    Reply

  • puneet avatar

    Posted on Mar 18, 2008 (permalink)

    there is also one more problem in the.ascx page.that if i move to the design tab of the .ascx page than dropdown shown fine but <Sitefinity:SearchBox1 ......
      > does not render but it sends the exception that "Unhandeled exception has occured. Object reference not set to an instance of an object.

    I uses the

    <sitefinity:SearchBox id=SearchBox1 __designer:dtid="1407383473487872" runat="server" ResultUrl="~/SearchResult.aspx">

    Reply

  • puneet avatar

    Posted on Mar 18, 2008 (permalink)

    there is also one more problem in the.ascx page.that if i move to the design tab of the .ascx page than dropdown shown fine but <Sitefinity:SearchBox1 ......
      > does not render but it sends the exception that "Unhandeled exception has occured. Object reference not set to an instance of an object.

    I uses the exactly same

    <sitefinity:SearchBox id=SearchBox1 __designer:dtid="1407383473487872" runat="server" ResultUrl="~/SearchResult.aspx">

    Reply

  • puneet avatar

    Posted on Mar 18, 2008 (permalink)

    there is also one more problem in the.ascx page.that if i move to the design tab of the .ascx page than dropdown shown fine but <Sitefinity:SearchBox1 ......
      > does not render but it sends the exception that "Unhandeled exception has occured. Object reference not set to an instance of an object.

    I uses the exactly same html for my

    <sitefinity:SearchBox id=SearchBox1 __designer:dtid="1407383473487872" runat="server" ResultUrl="~/SearchResult.aspx">

    Reply

  • puneet avatar

    Posted on Mar 18, 2008 (permalink)

    there is also one more problem in the.ascx page.that if i move to the design tab of the .ascx page than dropdown shown fine but <Sitefinity:SearchBox1 ......
      > does not render but it sends the exception that "Unhandeled exception has occured. Object reference not set to an instance of an object.

    I uses the exactly same html for my >ascx

    <sitefinity:SearchBox id=SearchBox1 __designer:dtid="1407383473487872" runat="server" ResultUrl="~/SearchResult.aspx">

    Reply

  • puneet avatar

    Posted on Mar 18, 2008 (permalink)

    Now i want to replace the search button of search module of sitefinity with the image?

    Reply

  • Georgi Georgi admin's avatar

    Posted on Mar 20, 2008 (permalink)

    Hi puneet,

    Now i want to replace the search button of search module of sitefinity with the image?

    Reading this question, I assume that you have solved your other problems with the custom control that we have provided earlier.

    You can change the search button with an image very easily. You just need to edit the template of SearchBox, because as Pepi said earlier, the custom control inherits the functionality of the SearchBox control.
    The template is located in <your project>\Sitefinity\ControlTemplates\Search. I am attaching a new template with ImageButton instead a regular button. Take a look at this, it should change the button with a clickable Telerik logo.

    Regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

    Reply

  • Zubair Intermediate avatar

    Posted on Apr 2, 2008 (permalink)

    Hi,

    My issue is with the default paging mechanism in Search Results,

    I want to show the pager

    < Goto Page 1               [Page 1 of 1]         Goto Page 2 >

    Please tell me how to do this.

    Thanks

    Reply

  • Georgi Georgi admin's avatar

    Posted on Apr 7, 2008 (permalink)

    Hello Zubair,

    The template you should edit is SearchResult.ascx located in \[YourProject]\Sitefinity\ControlTemplates\Search.

    Following your questions, I think it's worth mentioning that all templates that are applied to the public controls are in the ControlTemplates directory.

    Kind regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

    Reply

  • Zubair Intermediate avatar

    Posted on Apr 7, 2008 (permalink)

    Sorry for not being clear, I do know which control I need to edit, but what I don't know is how to read total page number as well as previous and next page numbers to make my pager look like above.

    Reply

  • Georgi Georgi admin's avatar

    Posted on Apr 11, 2008 (permalink)

    Hi Zubair,

    Here's how you can read the current page number and the total page number :
    // Total Pages 
    <asp:Literal ID="PageNumberLiteral"  
         runat="server"  
         Text='<%# pager1.PageCount.ToString() %>' /> 
    // Currently selected page 
    <asp:Literal ID="LiteralCurrentPage" 
         runat="server"  
         Text='<%# pager1.SelectedPage.ToString() %>' /> 

    SelectedPage is from type "int", so if you would like to take the next page or the previous page, just add or substract one :
    <asp:LinkButton ID="next" runat="server"
               text
    ='<%#(pager1.SelectedPage+1).ToString() %>'/> 

    I hope you find this answer helpful.

    Greetings,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

    Reply

  • Zubair Intermediate avatar

    Posted on Apr 12, 2008 (permalink)

    yes, looks like this is what I wanted. I'll try it and give you the feedback.

    Thanks.

    Reply

  • Zubair Intermediate avatar

    Posted on Apr 13, 2008 (permalink)

    Can you please tell me how to wire the <Goto Page 1 and Goto Page 2> buttons to their respective events just as Previous/Next buttons.

    Thanks.

    Reply

  • Zubair Intermediate avatar

    Posted on Apr 13, 2008 (permalink)

    Nevermind, I set the controls ID to the old IDs and it works. Thanks :)

    Reply

  • Register for webinar
Skip Navigation LinksHome / Developer Network / Forums / Sitefinity 3.x: 3.x Pre-release forums (retired) > Setting the index of search module at runtime