洛阳中航光电项目,为12年项目,此处使用反编译工具恢复源码,恢复为.netframe4.0版本,但仍需使用ie8访问; 数据库使用oracle,现再192.168.8.3服务器,访问账户scott,密码800100

JScript.cs 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. using System;
  2. using System.Web;
  3. using System.Web.UI;
  4. namespace Common
  5. {
  6. public class JScript
  7. {
  8. public static void AlertAndRedirect(string message, string toURL)
  9. {
  10. string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>";
  11. HttpContext.Current.Response.Write(string.Format(js, message, toURL));
  12. }
  13. public static void AlertAndReturnValueToParent(string message, string jsStr)
  14. {
  15. string js = "<script language=javascript>alert('{0}');{1}</script>";
  16. HttpContext.Current.Response.Write(string.Format(js, message, jsStr));
  17. }
  18. public void JscriptSender(Page page)
  19. {
  20. page.ClientScript.RegisterHiddenField("__EVENTTARGET", "");
  21. page.ClientScript.RegisterHiddenField("__EVENTARGUMENT", "");
  22. string s = "\t\t\r\n<script language=Javascript>\r\n function KendoPostBack(eventTarget, eventArgument) \r\n {\r\n\t\t\t\tvar theform = document.forms[0];\r\n\t\t\t\ttheform.__EVENTTARGET.value = eventTarget;\r\n\t\t\t\ttheform.__EVENTARGUMENT.value = eventArgument;\r\n\t\t\t\ttheform.submit();\r\n\t\t\t}\r\n</script>";
  23. page.ClientScript.RegisterStartupScript(base.GetType(), "sds", s);
  24. }
  25. public static void Alert(string message)
  26. {
  27. message = StringUtil.DeleteUnVisibleChar(message);
  28. string js = "<Script language='JavaScript'>\r\n alert('" + message + "');</Script>";
  29. HttpContext.Current.Response.Write(js);
  30. }
  31. public static void Alert(object message)
  32. {
  33. string js = "<Script language='JavaScript'>\r\n alert('{0}'); \r\n </Script>";
  34. HttpContext.Current.Response.Write(string.Format(js, message.ToString()));
  35. }
  36. public static void RtnRltMsgbox(object message, string strWinCtrl)
  37. {
  38. string js = "<Script language='JavaScript'>\r\n\t\t\t\t\t strWinCtrl = true;\r\n strWinCtrl = if(!confirm('" + message + "'))return false;</Script>";
  39. HttpContext.Current.Response.Write(string.Format(js, message.ToString()));
  40. }
  41. public static void GoHistory(int value)
  42. {
  43. string js = "<Script language='JavaScript'>\r\n history.go({0}); \r\n </Script>";
  44. HttpContext.Current.Response.Write(string.Format(js, value));
  45. }
  46. public static void CloseWindow()
  47. {
  48. string js = "<Script language='JavaScript'>\r\n window.close(); \r\n </Script>";
  49. HttpContext.Current.Response.Write(js);
  50. HttpContext.Current.Response.End();
  51. }
  52. public static void RefreshParent()
  53. {
  54. string js = "<Script language='JavaScript'>\r\n parent.location.reload();\r\n </Script>";
  55. HttpContext.Current.Response.Write(js);
  56. }
  57. public static string JSStringFormat(string s)
  58. {
  59. return s.Replace("\r", "\\r").Replace("\n", "\\n").Replace("'", "\\'").Replace("\"", "\\\"");
  60. }
  61. public static void RefreshOpener()
  62. {
  63. string js = "<Script language='JavaScript'>\r\n opener.location.reload();\r\n </Script>";
  64. HttpContext.Current.Response.Write(js);
  65. }
  66. public static void OpenWebForm(string url)
  67. {
  68. string js = string.Concat(new string[]
  69. {
  70. "<Script language='JavaScript'>\r\n\t\t\t//window.open('",
  71. url,
  72. "');\r\n\t\t\twindow.open('",
  73. url,
  74. "','','height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');\r\n\t\t\t</Script>"
  75. });
  76. HttpContext.Current.Response.Write(js);
  77. }
  78. public static void OpenWebForm(string url, string name, string future)
  79. {
  80. string js = string.Concat(new string[]
  81. {
  82. "<Script language='JavaScript'>\r\n window.open('",
  83. url,
  84. "','",
  85. name,
  86. "','",
  87. future,
  88. "')\r\n </Script>"
  89. });
  90. HttpContext.Current.Response.Write(js);
  91. }
  92. public static void OpenWebForm(string url, string formName)
  93. {
  94. string js = string.Concat(new string[]
  95. {
  96. "<Script language='JavaScript'>\r\n\t\t\t//window.open('",
  97. url,
  98. "','",
  99. formName,
  100. "');\r\n\t\t\twindow.open('",
  101. url,
  102. "','",
  103. formName,
  104. "','height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');\r\n\t\t\t</Script>"
  105. });
  106. HttpContext.Current.Response.Write(js);
  107. }
  108. public static void OpenWebForm(string url, bool isFullScreen)
  109. {
  110. string js = "<Script language='JavaScript'>";
  111. if (isFullScreen)
  112. {
  113. js += "var iWidth = 0;";
  114. js += "var iHeight = 0;";
  115. js += "iWidth=window.screen.availWidth-10;";
  116. js += "iHeight=window.screen.availHeight-50;";
  117. js += "var szFeatures ='width=' + iWidth + ',height=' + iHeight + ',top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no';";
  118. js = js + "window.open('" + url + "','',szFeatures);";
  119. }
  120. else
  121. {
  122. js = js + "window.open('" + url + "','','height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no');";
  123. }
  124. js += "</Script>";
  125. HttpContext.Current.Response.Write(js);
  126. }
  127. public static void JavaScriptLocationHref(string url)
  128. {
  129. string js = "<Script language='JavaScript'>\r\n window.location.replace('{0}');\r\n </Script>";
  130. js = string.Format(js, url);
  131. HttpContext.Current.Response.Write(js);
  132. }
  133. public static void JavaScriptFrameHref(string FrameName, string url)
  134. {
  135. string js = "<Script language='JavaScript'>\r\n\t\t\t\t\t\r\n @obj.location.replace(\"{0}\");\r\n </Script>";
  136. js = js.Replace("@obj", FrameName);
  137. js = string.Format(js, url);
  138. HttpContext.Current.Response.Write(js);
  139. }
  140. public static void JavaScriptResetPage(string strRows)
  141. {
  142. string js = "<Script language='JavaScript'>\r\n window.parent.CenterFrame.rows='" + strRows + "';</Script>";
  143. HttpContext.Current.Response.Write(js);
  144. }
  145. public static void JavaScriptSetCookie(string strName, string strValue)
  146. {
  147. string js = string.Concat(new string[]
  148. {
  149. "<script language=Javascript>\r\n\t\t\tvar the_cookie = '",
  150. strName,
  151. "=",
  152. strValue,
  153. "'\r\n\t\t\tvar dateexpire = 'Tuesday, 01-Dec-2020 12:00:00 GMT';\r\n\t\t\t//document.cookie = the_cookie;//写入Cookie<BR>} <BR>\r\n\t\t\tdocument.cookie = the_cookie + '; expires='+dateexpire;\t\t\t\r\n\t\t\t</script>"
  154. });
  155. HttpContext.Current.Response.Write(js);
  156. }
  157. public static void GotoParentWindow(string parentWindowUrl)
  158. {
  159. string js = "<Script language='JavaScript'>\r\n this.parent.location.replace('" + parentWindowUrl + "');</Script>";
  160. HttpContext.Current.Response.Write(js);
  161. }
  162. public static void ReplaceParentWindow(string parentWindowUrl, string caption, string future)
  163. {
  164. string js;
  165. if (future != null && future.Trim() != "")
  166. {
  167. js = string.Concat(new string[]
  168. {
  169. "<script language=javascript>this.parent.location.replace('",
  170. parentWindowUrl,
  171. "','",
  172. caption,
  173. "','",
  174. future,
  175. "');</script>"
  176. });
  177. }
  178. else
  179. {
  180. js = string.Concat(new string[]
  181. {
  182. "<script language=javascript>var iWidth = 0 ;var iHeight = 0 ;iWidth=window.screen.availWidth-10;iHeight=window.screen.availHeight-50;\r\n\t\t\t\t\t\t\tvar szFeatures = 'dialogWidth:'+iWidth+';dialogHeight:'+iHeight+';dialogLeft:0px;dialogTop:0px;center:yes;help=no;resizable:on;status:on;scroll=yes';this.parent.location.replace('",
  183. parentWindowUrl,
  184. "','",
  185. caption,
  186. "',szFeatures);</script>"
  187. });
  188. }
  189. HttpContext.Current.Response.Write(js);
  190. }
  191. public static void ReplaceOpenerWindow(string openerWindowUrl)
  192. {
  193. string js = "<Script language='JavaScript'>\r\n window.opener.location.replace('" + openerWindowUrl + "');</Script>";
  194. HttpContext.Current.Response.Write(js);
  195. }
  196. public static void ReplaceOpenerParentFrame(string frameName, string frameWindowUrl)
  197. {
  198. string js = string.Concat(new string[]
  199. {
  200. "<Script language='JavaScript'>\r\n window.opener.parent.",
  201. frameName,
  202. ".location.replace('",
  203. frameWindowUrl,
  204. "');</Script>"
  205. });
  206. HttpContext.Current.Response.Write(js);
  207. }
  208. public static void ReplaceOpenerParentWindow(string openerParentWindowUrl)
  209. {
  210. string js = "<Script language='JavaScript'>\r\n window.opener.parent.location.replace('" + openerParentWindowUrl + "');</Script>";
  211. HttpContext.Current.Response.Write(js);
  212. }
  213. public static void CloseParentWindow()
  214. {
  215. string js = "<Script language='JavaScript'>\r\n window.parent.close(); \r\n </Script>";
  216. HttpContext.Current.Response.Write(js);
  217. }
  218. public static void CloseOpenerWindow()
  219. {
  220. string js = "<Script language='JavaScript'>\r\n window.opener.close(); \r\n </Script>";
  221. HttpContext.Current.Response.Write(js);
  222. }
  223. public static string ShowModalDialogJavascript(string webFormUrl)
  224. {
  225. return "<script language=javascript>\r\n\t\t\t\t\t\t\tvar iWidth = 0 ;\r\n\t\t\t\t\t\t\tvar iHeight = 0 ;\r\n\t\t\t\t\t\t\tiWidth=window.screen.availWidth-10;\r\n\t\t\t\t\t\t\tiHeight=window.screen.availHeight-50;\r\n\t\t\t\t\t\t\tvar szFeatures = 'dialogWidth:'+iWidth+';dialogHeight:'+iHeight+';dialogLeft:0px;dialogTop:0px;center:yes;help=no;resizable:on;status:on;scroll=yes';\r\n\t\t\t\t\t\t\tshowModalDialog('" + webFormUrl + "','',szFeatures);</script>";
  226. }
  227. public static string ShowModalDialogJavascript(string webFormUrl, string features)
  228. {
  229. return string.Concat(new string[]
  230. {
  231. "<script language=javascript>\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tshowModalDialog('",
  232. webFormUrl,
  233. "','','",
  234. features,
  235. "');</script>"
  236. });
  237. }
  238. public static void ShowModalDialogWindow(string webFormUrl)
  239. {
  240. string js = JScript.ShowModalDialogJavascript(webFormUrl);
  241. HttpContext.Current.Response.Write(js);
  242. }
  243. public static void ShowModalDialogWindow(string webFormUrl, string features)
  244. {
  245. string js = JScript.ShowModalDialogJavascript(webFormUrl, features);
  246. HttpContext.Current.Response.Write(js);
  247. }
  248. public static void ShowModalDialogWindow(string webFormUrl, int width, int height, int top, int left)
  249. {
  250. string features = string.Concat(new string[]
  251. {
  252. "dialogWidth:",
  253. width.ToString(),
  254. "px;dialogHeight:",
  255. height.ToString(),
  256. "px;dialogLeft:",
  257. left.ToString(),
  258. "px;dialogTop:",
  259. top.ToString(),
  260. "px;center:yes;help=no;resizable:no;status:no;scroll=no"
  261. });
  262. JScript.ShowModalDialogWindow(webFormUrl, features);
  263. }
  264. public static void SetHtmlElementValue(string formName, string elementName, string elementValue)
  265. {
  266. string js = string.Concat(new string[]
  267. {
  268. "<Script language='JavaScript'>if(document.",
  269. formName,
  270. ".",
  271. elementName,
  272. "!=null){document.",
  273. formName,
  274. ".",
  275. elementName,
  276. ".value =",
  277. elementValue,
  278. ";}</Script>"
  279. });
  280. HttpContext.Current.Response.Write(js);
  281. }
  282. }
  283. }