网站问题总结

 1      < h3 >< span > 词典查询 </ span ></ h3 >
 2              < div id = " dicSearch " >
 3                  < form action = " auto_search.aspx "  method = " post " >
 4                      < dl >
 5                          < dt > 请输入要检索的中文或英文: </ dt >
 6                          < dd  class = " dic_img " >< img src = " images/dic_img.gif "  width = " 175 "  height = " 136 "  border = " 0 "  alt = " 汽配词典 "   /></ dd >
 7                          < dd  class = " inputKey " >< input maxlength = " 50 "  size = " 30 "  id = " searchkey "  name = " searchkey " /></ dd >
 8                          < dd  class = " subtn " >< input type = " submit "  value = " 提交 "  name = " Submit " /></ dd >
 9                          < dd  class = " radioBtn " >< label > 模糊检索 </ label >< input type = " radio "   checked = " checked "  value = " 1 "  name = " Sort1 " /></ dd >
10                          < dd  class = " radioBtn " >< label > 精确检索 </ label >< input type = " radio "  value = " 2 "  name = " Sort1 " /></ dd >
11                      </ dl >
12                  </ form >
13              </ div >

页面 一代码如上
 

模糊检索
精确检索
1 < script language = " javascript " >
2             function SubmitForm()
3              {
4                frmSearch.action="auto_search.aspx";
5                frmSearch.submit();
6            }

7              </ script >
页面二代码如上
 1 < form id = " frmSearch "  method = " post "  runat = " server " >
 2                              < class = " nowplace " > 您好!您现在的位置: < A title = " 首页 "  href = " / " > 首页 </ A >   & gt;  < A title = " 商业服务 "  href = " /serv/default.html " >
 3                                     商业服务 </ A >   & gt;  < A title = " 汽配词典 "  href = " dictionary.htm " > 汽配词典 </ A >   & gt;
 4                                  < span > 查询结果 </ span ></ p >
 5                              < div id = " dicSearch " >
 6                                  < dl >
 7                                      < dt > 请输入要检索的中文或英文 :  </ dt >
 8                                      < dd  class = " dic_img " >
 9                                          < IMG height = " 136 "  alt = " 汽配词典 "  src = " images/dic_img.gif "  width = " 175 "  border = " 0 " >
10                                      </ dd >
11                                      < dd  class = " inputKey " >
12                                          <%--< input maxlength = " 50 "  size = " 30 "  id = " dictionary "  name = " dictionary " >--%>
13                                          < asp:textbox id = " SearchKey "  runat = " server "  MaxLength = " 50 " ></ asp:textbox ></ dd >
14                                      < dd  class = " subtn " >
15                                          <%--< asp:button id = " BtnSearch "  runat = " server "  Text = " 提交 " ></ asp:button >--%>
16                                          < input type = " button "  value = " 提交 "  name = " Submit "  onclick = " JavaScript:SubmitForm(); " >
17                                          <%--< dd  class = " radioBtn " >
18                                          < label > 模糊检索 </ label >< asp:radiobutton id = " rbtBlurSearch "  runat = " server " ></ asp:radiobutton >
19                                      </ dd >
20                                      < dd  class = " radioBtn " >
21                                          < label > 精确检索 </ label >< asp:radiobutton id = " rbtExactSearch "  runat = " server " ></ asp:radiobutton >
22                                      </ dd >--%>
23                                          < asp:radiobuttonlist id = " Sort1 "  runat = " server "  RepeatDirection = " Horizontal " >
24                                              < asp:ListItem Value = " 2 " > 精确查找 </ asp:ListItem >
25                                              < asp:ListItem Value = " 1 "  Selected = " True " > 模糊查找 </ asp:ListItem >
26                                          </ asp:radiobuttonlist ></ dd ></ dl >
27                              </ div >
28                              < div id = " searchResult " >
29                                  < h3 > 查询结果 </ h3 >
30                                  < asp:literal id = " MainList "  runat = " server " ></ asp:literal >
31                                  <%--< span > 首页 </ span >   < span > 上一页 </ span >   < a href = " # "  title = " 下一页 " > 下一页 </ a >      < a href = " # "  title = " 尾页 " > 尾页 </ a >  页次: < em > 1 </ em >/ 6页 共 < em > 161 </ em > 条信息 每页 < em > 10 </ em > 条 转到  < input name = " go2map "  size = " 5 "  maxlength = " 5 "  id = " go2page "   class = " input2 " />   < input  class = " goBtn "  type = " submit "  align = " bottom "  onclick = " javascript:location.href('128_'+document.all.go2page.value+'.html'); "  id = " btn1 "  value = " Go>> " />--%>
32                                 共有 < span >< asp:literal id = " LtlRCount "  runat = " server " ></ asp:literal >
33                                  </ span > 条记录 共计 < span >< asp:literal id = " LtlPCount "  runat = " server " ></ asp:literal >
34                                  </ span > 个页面 当前页数为: < span >< asp:literal id = " LtlCCPage "  runat = " server " ></ asp:literal >
35                                  </ span ></ div >
36                          </ form >
  1 namespace  serv
  2 {
  3    /**//// <summary>
  4    /// auto_search 的摘要说明。
  5    /// </summary>

  6    public class auto_search : System.Web.UI.Page
  7    {
  8        protected System.Web.UI.WebControls.TextBox SearchKey;
  9        protected System.Web.UI.WebControls.RadioButtonList Sort1;
 10        protected System.Web.UI.WebControls.Literal MainList;
 11        protected System.Web.UI.WebControls.Literal LtlRCount;
 12        protected System.Web.UI.WebControls.Literal LtlPCount;
 13        protected System.Web.UI.WebControls.Literal LtlCCPage;
 14        protected System.Web.UI.HtmlControls.HtmlForm frmSearch;
 15        protected System.Web.UI.WebControls.Literal Ltlpage;
 16    
 17        private void Page_Load(object sender, System.EventArgs e)
 18        {
 19            // 在此处放置用户代码以初始化页面
 20            string searchkey="",SerchKey2="";
 21            int RecordCount = 0,CurrentPage=1;
 22            int PageCount = 0;
 23    
 24            if(Request.Params["searchkey"]!=null&&Request.Params["sort1"]!=null)
 25            {
 26                SearchKey.Text=Request.Params["searchkey"].ToString();
 27                Sort1.SelectedValue=Request.Params["sort1"].ToString();
 28                SerchKey2=Request.Params["searchkey"].ToString();
 29            }

 30            else if(Request.QueryString["Page"]!=null&&Request.QueryString["KeyWords"]!=null)
 31            {
 32                SerchKey2=Request.QueryString["KeyWords"].ToString().Trim();
 33            }

 34            else
 35            {
 36                SerchKey2=SearchKey.Text.Trim();
 37            }

 38            
 39            if(SerchKey2.Trim().Length!=0)
 40            {
 41                if(Request.QueryString["Page"]!=null)
 42                {
 43                    try
 44                    {
 45                        CurrentPage=int.Parse(Request.QueryString["Page"].ToString());
 46                    }

 47                    catch
 48                    {
 49                        Response.Write("参数错误!");
 50                        Response.End();
 51                    }

 52                }

 53                else
 54                {
 55                    CurrentPage=1;
 56                }

 57                searchkey=SerchKey2.Replace("'","").Replace(";","");
 58                string SearchQual="";
 59                if(Sort1.SelectedValue=="1")
 60                {
 61                    SearchQual=" en like '%"+searchkey+"%' or cn like '%"+searchkey+"%' ";
 62                }

 63                else
 64                {
 65                    SearchQual=" en = '"+searchkey+"' or cn = '"+searchkey+"'   ";
 66                }

 67                            
 68
 69                SqlConnection conn = new SqlConnection(main.connstr);
 70                
 71            
 72                SqlDataAdapter da=new SqlDataAdapter("pagination",conn);
 73                da.SelectCommand.CommandType=CommandType.StoredProcedure;
 74                da.SelectCommand.Parameters.Add(new SqlParameter("@tblName",SqlDbType.NVarChar,128));
 75                da.SelectCommand.Parameters["@tblName"].Value="Serv_dic";
 76                da.SelectCommand.Parameters.Add(new SqlParameter("@strGetFields",SqlDbType.NVarChar,1000));
 77                da.SelectCommand.Parameters["@strGetFields"].Value="  en,cn  ";
 78                da.SelectCommand.Parameters.Add(new SqlParameter("@fldName",SqlDbType.NVarChar,128));
 79                da.SelectCommand.Parameters["@fldName"].Value=" id desc";
 80                da.SelectCommand.Parameters.Add(new SqlParameter("@KeyName",SqlDbType.NVarChar,255));
 81                da.SelectCommand.Parameters["@KeyName"].Value=" id ";
 82                da.SelectCommand.Parameters.Add(new SqlParameter("@PageSize",SqlDbType.Int));
 83                da.SelectCommand.Parameters["@PageSize"].Value=10;
 84                da.SelectCommand.Parameters.Add(new SqlParameter("@PageIndex",SqlDbType.Int));
 85                da.SelectCommand.Parameters["@PageIndex"].Value=CurrentPage;
 86                da.SelectCommand.Parameters.Add(new SqlParameter("@strWhere",SqlDbType.NVarChar,1500));
 87                da.SelectCommand.Parameters["@strWhere"].Value= SearchQual ;
 88
 89
 90                DataSet ds=new DataSet();
 91                da.Fill(ds,"Serv_dic");
 92                
 93                da.Dispose();
 94
 95                StringBuilder Sb=new StringBuilder();
 96                Sb.Append("<dl>\n");
 97                foreach(DataRow dr in ds.Tables["Serv_dic"].Rows)
 98                {
 99                    Sb.Append("<dt>"+dr["en"].ToString().Replace(searchkey,"<span>"+searchkey+"</span>")+"</dt>\n");
100                    Sb.Append("<dd>"+dr["cn"].ToString().Replace(searchkey,"<span>"+searchkey+"</span>")+"</dd>\n");
101                }

102                Sb.Append("</dl>\n");
103
104                ds.Clear();
105                ds.Dispose();
106
107                MainList.Text=Sb.ToString();
108            
109
110                SqlCommand Ccmd=new SqlCommand("select count(*) as ASD from Serv_dic where   "+SearchQual,conn);
111
112                conn.Open();
113                SqlDataReader Cdr=Ccmd.ExecuteReader();
114                Cdr.Read();
115                RecordCount=int.Parse(Cdr["ASD"].ToString());
116                
117                if ((RecordCount /10!=0)
118                {
119                    PageCount = (RecordCount / 10+ 1;
120                }

121                else
122                {
123                    PageCount = RecordCount / 10;
124                }

125
126                LtlRCount.Text = RecordCount.ToString();
127                LtlPCount.Text = PageCount.ToString();
128                LtlCCPage.Text = CurrentPage.ToString();
129
130                //生成页数导航
131                int pp =CurrentPage;
132                string ptemp="";
133                string pssort="list";
134
135                if (pp>1)
136                {
137                    int Prepp = pp - 1;
138                    ptemp = "【<a href=\"/Serv/Auto_Search.aspx?Page=1&KeyWords="+searchkey+"\">第一页</a>】【<a href=\"/Serv/Auto_Search.aspx?Page="+Prepp.ToString()+"&KeyWords="+searchkey+"\">上一页</a>】";
139                }

140                else
141                {
142                    ptemp = "【第一页】【上一页】";
143                }

144                if (pp<PageCount)
145                {
146                    int Nextpp=pp+1;
147                    ptemp = ptemp + "【<a href=\"/Serv/Auto_Search.aspx?Page="+Nextpp.ToString()+"&KeyWords="+searchkey+"\">下一页</a>】【<a href=\"/Serv/Auto_Search.aspx?Page="+PageCount.ToString()+"&KeyWords="+searchkey+"\">最后一页</a>】";
148                }

149                else
150                {
151                    ptemp = ptemp + "【下一页】【最后一页】";
152                }

153
154
155                ptemp=ptemp+" 直接到 ";
156                ptemp=ptemp+"       <input type=\"text\" name=\"go2page\" id=\"go2page\" maxlength=\"5\" size=\"3\"";
157                ptemp=ptemp+"       <input type=\"submit\"  align=\"top\" id=\"btn1\"  value=\"GO>>\" οnclick=\"javascript:window.location='/Serv/Auto_Search.aspx?KeyWords="+searchkey+"&Page='+document.getElementById(\'go2page\').value+''\">";
158                Ltlpage.Text=ptemp;
159                    
160                Cdr.Close();
161                conn.Close();
162            }

163            else
164            {
165                MainList.Text="<font style=\"color:red;font-size:16px;\"><br><br><br>搜索的关键字不能为空,请先填写要搜索的内容!<br><br><br></font>";
166            }

167            //            }
168        }
字典查询完成
3.参数传递,政策法规和行业标准连个模块并列
   
 1 if (Bname == "" )
 2     {
 3    Response.Write("<script language=javascript>alert('错误的链接地址!');history.go(-1);</script>");
 4    Response.End();
 5   }

 6     if (Bid == 106   &&  Sid != 0 )
 7     {
 8    //<!-- 标准法规-->
 9    if(Sid==127)//政策法规
10    {
11     NavUrl.Text = "<li class=\"Selected\">行业标准</li>";
12     NavUrl.Text += "<li class=\"NoSelected\"><a href=\"128_1.html\">政策法规</a></li>";
13    }

14    else//行业指示
15    {
16     NavUrl.Text = "<li class=\"NoSelected\"><a href=\"127_1.html\">行业标准</a></li>";
17     NavUrl.Text += "<li class=\"Selected\">政策法规</li>"
18    }

19   }

20     else
21     {
22    if(Bname!="" && Sname!="")
23    {
24
25     Ltlnav.Text=" <a href=\"default_1.html\">"+Bname+"</a> > "+Sname;
26     NavUrl.Text="<div id=\"Mhead\">&nbsp;<img src=\"../images/trigon.gif\" width=\"26\" height=\"13\""+Sname+"</div>";
27    }

28    else
29    {
30     Ltlnav.Text=" "+Bname;
31     if(Bid!=104)
32     {
33     NavUrl.Text="<div id=\"Mhead\">&nbsp;<img src=\"../images/trigon.gif\" width=\"26\" height=\"13\""+Bname+"</div>";
34     }

35     else
36     {
37      NavUrl.Text="<div id=\"standard\"><div id=\"standard2\"><a href=\"127_1.html\">行业标准</a></div><div id=\"standard2\"><a href=\"128_1.html\">政策法规</a></div></div>";
38     }

39    }

40    
41   }

42

转载于:https://www.cnblogs.com/hudielan/archive/2008/04/26/1172400.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值