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

编辑器/阅读器

开发平台:

C#

  1. <%@ Page language="c#" AutoEventWireup="true" Inherits="DotNetTextBox.PageCode" %>
  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 language="JavaScript" type="text/javascript">
  13. Request = {
  14.  QueryString : function(item){
  15.   var svalue = location.search.match(new RegExp("[?&]" + item + "=([^&]*)(&?)","i"));
  16.   return svalue ? svalue[1] : svalue;
  17.  }
  18. }
  19. var userAgent = navigator.userAgent.toLowerCase();
  20. var is_ie = (userAgent.indexOf('msie') != -1);
  21. if(is_ie)
  22. {
  23. var oSelection=parent.document.getElementById(Request.QueryString("name")).contentWindow.document.selection.createRange();
  24. }
  25. function searchtype(){
  26. var retval = 0;
  27. var matchcase = 0;
  28. var matchword = 0;
  29. if (document.frmSearch.blnMatchCase.checked) matchcase = 4;
  30. if (document.frmSearch.blnMatchWord.checked) matchword = 2;
  31. retval = matchcase + matchword;
  32. return(retval);
  33. }
  34. function checkInput(){
  35. if (document.frmSearch.strSearch.value.length < 1) {
  36. alert('<%=ResourceManager.GetString("pleaseinput")%>');
  37. return false;
  38. } else {
  39. return true;
  40. }
  41. }
  42. function findtext(){
  43. if (checkInput()) {
  44. var searchval = document.frmSearch.strSearch.value;
  45. oSelection.collapse(false);
  46. if (oSelection.findText(searchval, 1000000000, searchtype())) {
  47. oSelection.select();
  48. } else {
  49. var startfromtop = confirm('<%=ResourceManager.GetString("findfinal")%>');
  50. if (startfromtop) {
  51. oSelection.expand("textedit");
  52. oSelection.collapse();
  53. oSelection.select();
  54. findtext();
  55. }
  56. }
  57. }
  58. }
  59. function replacetext(){
  60. if (checkInput()) {
  61. if (document.frmSearch.blnMatchCase.checked){
  62. if (oSelection.text == document.frmSearch.strSearch.value) oSelection.text = document.frmSearch.strReplace.value
  63. } else {
  64. if (oSelection.text.toLowerCase() == document.frmSearch.strSearch.value.toLowerCase()) oSelection.text = document.frmSearch.strReplace.value
  65. }
  66. findtext();
  67. }
  68. }
  69. function replacealltext(){
  70. if (checkInput()) {
  71. var searchval = document.frmSearch.strSearch.value;
  72. var wordcount = 0;
  73. var msg = "";
  74. oSelection.expand("textedit");
  75. oSelection.collapse();
  76. oSelection.select();
  77. while (oSelection.findText(searchval, 1000000000, searchtype())){
  78. oSelection.select();
  79. oSelection.text = document.frmSearch.strReplace.value;
  80. wordcount++;
  81. }
  82. if (wordcount == 0) msg = '<%=ResourceManager.GetString("notfound")%>'
  83. else msg = wordcount + ' <%=ResourceManager.GetString("replaceresult")%>';
  84. alert(msg);
  85. }
  86. }
  87. function search(type)
  88. {
  89. var up=document.getElementById("searchup").checked;
  90. if(type=="find")
  91. {
  92. if (document.getElementById("strSearch").value != "")
  93. {
  94. window.opener.findandreplace(document.getElementById("strSearch").value,"",type,document.frmSearch.blnMatchCase.checked,up);
  95. }
  96. }
  97. else
  98. {
  99. if (document.getElementById("strSearch").value != ""&document.getElementById("strReplace").value!="")
  100. {
  101. window.opener.findandreplace(document.getElementById("strSearch").value,document.getElementById("strReplace").value,type,document.frmSearch.blnMatchCase.checked,up);
  102. }
  103. }
  104. window.close();
  105. }
  106. //window.focus();
  107. </script>
  108. <body bgcolor="#f9f8f7">
  109. <form id="frmSearch" runat="server"  class="alertbgc">
  110. <div  class="alertbgc">
  111. <TABLE CELLSPACING="0" cellpadding="5" border="0"  class="alertbgc">
  112. <TR><TD VALIGN="top" align="left">
  113. <label for="strSearch"><%=ResourceManager.GetString("findcontent")%></label><br>
  114. <INPUT TYPE=TEXT SIZE=40 NAME=strSearch id="strSearch" style="width : 200px;"><br>
  115. <label for="strReplace"><%=ResourceManager.GetString("replacecontent")%></label><br>
  116. <INPUT TYPE=TEXT SIZE=40 NAME=strReplace id="strReplace" style="width : 200px;"><br>
  117. <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>
  118. </td>
  119. <td rowspan="2" valign="top">
  120. <input type=button style="width:80px;margin-top:15px" name="btnFind" onClick="if(is_ie){findtext();}else{search('find');}" value='<%=ResourceManager.GetString("findnext")%>'><br>
  121. <input type=button style="width:80px;margin-top:5px" name="btnCancel" onClick="parent.popupmenu.hide();parent.rcmenu.hide();" value='<%=ResourceManager.GetString("close")%>'><br>
  122. <input type=button style="width:80px;margin-top:5px" name="btnReplace" onClick="if(is_ie){replacetext();}else{search('replace');}" value='<%=ResourceManager.GetString("replace")%>'><br>
  123. <div id='replaceall'><input type=button style="width:80px;margin-top:5px" name="btnReplaceall" onClick="replacealltext();" value='<%=ResourceManager.GetString("replaceall")%>'><br></div>
  124. </td>
  125. </tr>
  126. </table>
  127. </div>
  128. </form>
  129. </body>
  130. <script language=javascript>
  131. if(is_ie)
  132. {
  133. document.getElementById("backwards").style.visibility="hidden";
  134. }
  135. else
  136. {
  137. document.getElementById("matchword").style.visibility="hidden";
  138. document.getElementById("replaceall").style.visibility="hidden";
  139. }
  140. function Checkbox1_onclick(chk)
  141. {
  142. if(document.getElementById("searchup").checked)
  143. {
  144. document.getElementById("searchdown").checked=false;
  145. }
  146. }
  147. function searchdown_onclick()
  148. {
  149. if(document.getElementById("searchdown").checked)
  150. {
  151. document.getElementById("searchup").checked=false;
  152. }
  153. }
  154. </script>
  155. </html>