我是新人`最近在学写搜索 `因为petshop象圣物一般 我对里面的所有东西都感兴趣 但我却读着读着 就跟踪不下去了`从OnClick="btnSearch_Click" 开始`
接着看到:
protected void btnSearch_Click(object sender, EventArgs e) {
            WebUtility.SearchRedirect(txtSearch.Text); }
找到WebUtility文件 看到:
public static void SearchRedirect(string key) {
            HttpContext.Current.Response.Redirect(string.Format(REDIRECT_URL, InputText(key, 255)));
跟着InputText调用到了:
public static string InputText(string text, int maxLength) {
            text = text.Trim();
            if (string.IsNullOrEmpty(text))
                return string.Empty;
            if (text.Length > maxLength)
                text = text.Substring(0, maxLength);
            text = Regex.Replace(text, "[\\s]{2,}", " "); //two or more spaces
            text = Regex.Replace(text, "(<[b|B][r|R]/*>)+|(<[p|P](.|\\n)*?>)", "\n"); //<br>
            text = Regex.Replace(text, "(\\s*&[n|N][b|B][s|S][p|P];\\s*)+", " "); //&nbsp;
            text = Regex.Replace(text, "<(.|\\n)*?>", string.Empty); //any other tags
            text = text.Replace("'", "''");
            return text;}到了这 最后的一句return 后`我就不知道要去看哪了`?
刚刚看的这些都是对用户输入的搜索关键词进行处理`?
怎么也没看到检索数据库?而在search.aspx中就一句
<uc1:SearchControl ID="SearchControl1" runat="server"/>
我转到了SearchControl.ascx中看到了又一个ui控件PetShopControl 但怎么也找不到定义他的ascx文件`我这样就看头和尾 `完全不懂 `petshop的搜索到底是什么原理?个人感觉应该是数据库的搜索吧?!那有专门建立一张索引表吗?Petshop对我来说真的好复杂 请高人带个路 `` 

解决方案 »

  1.   

    有啊`
    private const string REDIRECT_URL = "~/Search.aspx?keywords={0}";页面重定向到search.aspx
    但后面的keywords={0}不太理解...
      

  2.   

    private const string REDIRECT_URL = "~/Search.aspx?keywords={0}";string.Format(REDIRECT_URL, InputText(key, 255))以上的含义就是把输入的字符串过滤掉敏感字符,
    然后转到 /Search.aspx?keywords=输入的字符 .keywords={0} 不明白的话就看一下String.Format函数
      

  3.   

    String.Format 过滤{0} {1} {2} 等
      

  4.   

    关键字处理完`petshop到底是怎么利用关键字到数据库中查找出符合的字段呢?利用的又是哪个文件?帮帮帮