search.aspx
上传用户:lanchensha
上传日期:2022-02-27
资源大小:7530k
文件大小:7k
源码类别:

编辑器/阅读器

开发平台:

C#

  1. <%@ Page language="c#" AutoEventWireup="true" %>
  2. <%@ Import Namespace="DotNetTextBox" %>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" >
  5. <head>
  6. <title><%=ResourceManager.GetString("search")%></title>
  7. <meta http-equiv="pragma" content="no-cache" />
  8. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  9. <base target="_self" />
  10. <link href="stylesheet.css" rel="stylesheet" type="text/css" />
  11. </head>
  12. <script runat="server" language="C#">
  13. private void Page_Load(object sender, System.EventArgs e)
  14. {
  15.     if (Request.Cookies["languages"] != null)
  16.     {
  17.         ResourceManager.SiteLanguageKey = Request.Cookies["languages"].Value;
  18.     }
  19.     else
  20.     {
  21.         ResourceManager.SiteLanguageKey = HttpContext.Current.Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"].ToLower().Split(',')[0];
  22.     }
  23. }
  24. </script>
  25. <script language="JavaScript" type="text/javascript">
  26. var userAgent = navigator.userAgent.toLowerCase();
  27. var is_ie = (userAgent.indexOf('msie') != -1);
  28. if(is_ie)
  29. {
  30. var oSelection;
  31. oSelection = dialogArguments.document.selection.createRange();
  32. }
  33. function searchtype(){
  34.     var retval = 0;
  35.     var matchcase = 0;
  36.     var matchword = 0;
  37.     if (document.frmSearch.blnMatchCase.checked) matchcase = 4;
  38.     if (document.frmSearch.blnMatchWord.checked) matchword = 2;
  39.     retval = matchcase + matchword;
  40.     return(retval);
  41. }
  42. function checkInput(){
  43.     if (document.frmSearch.strSearch.value.length < 1) {
  44.         alert('<%=ResourceManager.GetString("pleaseinput")%>');
  45.         return false;
  46.     } else {
  47.         return true;
  48.     }
  49. }
  50. function findtext(){
  51.     if (checkInput()) {
  52.         var searchval = document.frmSearch.strSearch.value;
  53.         oSelection.collapse(false);
  54.         if (oSelection.findText(searchval, 1000000000, searchtype())) {
  55.             oSelection.select();
  56.         } else {
  57.             var startfromtop = confirm('<%=ResourceManager.GetString("findfinal")%>');
  58.             if (startfromtop) {
  59.                 oSelection.expand("textedit");
  60.                 oSelection.collapse();
  61.                 oSelection.select();
  62.                 findtext();
  63.             }
  64.         }
  65.     }
  66. }
  67. function replacetext(){
  68.     if (checkInput()) {
  69.         if (document.frmSearch.blnMatchCase.checked){
  70.             if (oSelection.text == document.frmSearch.strSearch.value) oSelection.text = document.frmSearch.strReplace.value
  71.         } else {
  72.             if (oSelection.text.toLowerCase() == document.frmSearch.strSearch.value.toLowerCase()) oSelection.text = document.frmSearch.strReplace.value
  73.         }
  74.         findtext();
  75.     }
  76. }
  77. function replacealltext(){
  78.     if (checkInput()) {
  79.         var searchval = document.frmSearch.strSearch.value;
  80.         var wordcount = 0;
  81.         var msg = "";
  82.         oSelection.expand("textedit");
  83.         oSelection.collapse();
  84.         oSelection.select();
  85.         while (oSelection.findText(searchval, 1000000000, searchtype())){
  86.             oSelection.select();
  87.             oSelection.text = document.frmSearch.strReplace.value;
  88.             wordcount++;
  89.         }
  90.         if (wordcount == 0) msg = '<%=ResourceManager.GetString("notfound")%>'
  91.         else msg = wordcount + ' <%=ResourceManager.GetString("replaceresult")%>';
  92.         alert(msg);
  93.     }
  94. }
  95. function search(type) 
  96. {
  97. var up=document.getElementById("searchup").checked;
  98. if(type=="find")
  99. {
  100. if (document.getElementById("strSearch").value != "")
  101. {
  102. window.opener.findandreplace(document.getElementById("strSearch").value,"",type,document.frmSearch.blnMatchCase.checked,up);
  103. }
  104. }
  105. else
  106. {
  107. if (document.getElementById("strSearch").value != ""&document.getElementById("strReplace").value!="")
  108. {
  109. window.opener.findandreplace(document.getElementById("strSearch").value,document.getElementById("strReplace").value,type,document.frmSearch.blnMatchCase.checked,up);
  110. }
  111. }
  112. window.close();
  113. }
  114. window.focus();
  115. </script>
  116. <body>
  117.     <form id="frmSearch" runat="server"  class="alertbgc">
  118.     <div  class="alertbgc">
  119. <TABLE CELLSPACING="0" cellpadding="5" border="0"  class="alertbgc">
  120. <TR><TD VALIGN="top" align="left">
  121.     <label for="strSearch"><%=ResourceManager.GetString("findcontent")%></label><br>
  122.     <INPUT TYPE=TEXT SIZE=40 NAME=strSearch id="strSearch" style="width : 200px;"><br>
  123.     <label for="strReplace"><%=ResourceManager.GetString("replacecontent")%></label><br>
  124.     <INPUT TYPE=TEXT SIZE=40 NAME=strReplace id="strReplace" style="width : 200px;"><br>
  125.     <INPUT TYPE=Checkbox SIZE=40 NAME=blnMatchCase ID="blnMatchCase"><label for="blnMatchCase"><%=ResourceManager.GetString("casesensitive")%></label><label id='backwards'><INPUT TYPE=Checkbox SIZE=40 NAME=searchup ID="searchup"  language="javascript"  onclick="Checkbox1_onclick()"><label for="searchup"><%=ResourceManager.GetString("upwards")%></label> <INPUT TYPE=Checkbox SIZE=40 NAME=searchdown checked=checked ID="searchdown" language="javascript" onclick="return searchdown_onclick()"><label for="searchdown"><%=ResourceManager.GetString("downwards")%></label></label><div id='matchword'><INPUT TYPE=Checkbox SIZE=40 NAME=blnMatchWord ID="blnMatchWord"><label for="blnMatchWord"><%=ResourceManager.GetString("wholeword")%></label></div>
  126. </td>
  127. <td rowspan="2" valign="top">
  128.     <input type=button style="width:80px;margin-top:15px" name="btnFind" onClick="if(is_ie){findtext();}else{search('find');}" value='<%=ResourceManager.GetString("findnext")%>'><br>
  129.     <input type=button style="width:80px;margin-top:5px" name="btnCancel" onClick="window.close();" value='<%=ResourceManager.GetString("close")%>'><br>
  130.     <input type=button style="width:80px;margin-top:5px" name="btnReplace" onClick="if(is_ie){replacetext();}else{search('replace');}" value='<%=ResourceManager.GetString("replace")%>'><br>
  131.     <div id='replaceall'><input type=button style="width:80px;margin-top:5px" name="btnReplaceall" onClick="replacealltext();" value='<%=ResourceManager.GetString("replaceall")%>'><br></div>
  132. </td>
  133. </tr>
  134. </table>
  135.     </div>
  136.     </form>
  137. </body>
  138. <script language=javascript>
  139. if(is_ie)
  140. {
  141. document.body.bgColor="ButtonFace";
  142. document.getElementById("backwards").style.visibility="hidden";
  143. }
  144. else
  145. {
  146. document.body.bgColor="#E0E0E0";
  147. document.getElementById("matchword").style.visibility="hidden";
  148. document.getElementById("replaceall").style.visibility="hidden";
  149. }
  150. function Checkbox1_onclick(chk) 
  151. {
  152. if(document.getElementById("searchup").checked)
  153. {
  154. document.getElementById("searchdown").checked=false;
  155. }
  156. }
  157. function searchdown_onclick() 
  158. {
  159. if(document.getElementById("searchdown").checked)
  160. {
  161. document.getElementById("searchup").checked=false;
  162. }
  163. }
  164. </script>
  165. </html>