+1-888-365-2779
Try Now
More in this section

Forums / 3.x Pre-release forums (retired) / Setting the index of search module at runtime

Setting the index of search module at runtime

17 posts, 0 answered
  1. puneet
    puneet avatar
    14 posts
    Registered:
    12 Mar 2008
    17 Mar 2008
    Link to this post


    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.....

  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    16 Sep 2016
    17 Mar 2008
    Link to this post
    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
  3. puneet
    puneet avatar
    14 posts
    Registered:
    12 Mar 2008
    17 Mar 2008
    Link to this post
    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 
  4. puneet
    puneet avatar
    14 posts
    Registered:
    12 Mar 2008
    18 Mar 2008
    Link to this post
    I made user control as you specified .but after uploading the user control ,No control gets added in sitefinty control section..
  5. puneet
    puneet avatar
    14 posts
    Registered:
    12 Mar 2008
    18 Mar 2008
    Link to this post

    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">
  6. puneet
    puneet avatar
    14 posts
    Registered:
    12 Mar 2008
    18 Mar 2008
    Link to this post

    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">
  7. puneet
    puneet avatar
    14 posts
    Registered:
    12 Mar 2008
    18 Mar 2008
    Link to this post

    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">
  8. puneet
    puneet avatar
    14 posts
    Registered:
    12 Mar 2008
    18 Mar 2008
    Link to this post

    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">
  9. puneet
    puneet avatar
    14 posts
    Registered:
    12 Mar 2008
    18 Mar 2008
    Link to this post
    Now i want to replace the search button of search module of sitefinity with the image?
  10. Georgi
    Georgi avatar
    3583 posts
    Registered:
    20 Sep 2016
    20 Mar 2008
    Link to this post
    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
  11. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    02 Apr 2008
    Link to this post
    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
  12. Georgi
    Georgi avatar
    3583 posts
    Registered:
    20 Sep 2016
    07 Apr 2008
    Link to this post
    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
  13. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    07 Apr 2008
    Link to this post
    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.
  14. Georgi
    Georgi avatar
    3583 posts
    Registered:
    20 Sep 2016
    11 Apr 2008
    Link to this post
    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
  15. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    13 Apr 2008
    Link to this post
    yes, looks like this is what I wanted. I'll try it and give you the feedback.

    Thanks.
  16. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    13 Apr 2008
    Link to this post
    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.
  17. Zubair
    Zubair avatar
    142 posts
    Registered:
    26 Dec 2007
    13 Apr 2008
    Link to this post
    Nevermind, I set the controls ID to the old IDs and it works. Thanks :)
Register for webinar
17 posts, 0 answered