As p_net中可直接使用的Javascript的Js类.doc_第1页
As p_net中可直接使用的Javascript的Js类.doc_第2页
As p_net中可直接使用的Javascript的Js类.doc_第3页
As p_net中可直接使用的Javascript的Js类.doc_第4页
As p_net中可直接使用的Javascript的Js类.doc_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

A中的可直接使用Javascript的Js类using System;using System.Web;using System.Web.UI.HtmlControls ;using System.Web.UI;namespace Web.JScript / / 提供向页面输出客户端代码实现特殊功能的方法 / / / public class JScript public static void AlertAndRedirect(string message,string toURL) string js = alert(0);window.location.replace(1); HttpContext.Current.Response.Write(string.Format(js,message ,toURL); / / 向客户端发送函数KendoPostBack(eventTarget, eventArgument) / 服务器端可接收_EVENTTARGET,_EVENTARGUMENT的值 / / System.Web.UI.Page 一般为this public static void JscriptSender(System.Web.UI.Page page) page.RegisterHiddenField(_EVENTTARGET,); page.RegisterHiddenField(_EVENTARGUMENT,); string s = function KendoPostBack(eventTarget, eventArgument) var theform = document.forms0; theform._EVENTTARGET.value = eventTarget; theform._EVENTARGUMENT.value = eventArgument; theform.submit(); ; page.RegisterStartupScript(sds,s); / / 弹出JavaScript小窗口 / / 窗口信息 public static void Alert(string message) message = StringUtil.DeleteUnVisibleChar(message); string js= alert(+ message +); HttpContext.Current.Response.Write(js); public static void Alert(object message) string js= alert(0); ; HttpContext.Current.Response.Write(string.Format(js,message.ToString(); public static void RtnRltMsgbox(object message,string strWinCtrl) string js = strWinCtrl = true; strWinCtrl = if(!confirm(+ message +)return false; HttpContext.Current.Response.Write(string.Format(js,message.ToString(); / / 回到历史页面 / / -1/1 public static void GoHistory(int value) string js= history.go(0); ; HttpContext.Current.Response.Write(string.Format(js,value); / / 关闭当前窗口 / public static void CloseWindow() string js= window.close(); ; HttpContext.Current.Response.Write(js); HttpContext.Current.Response.End(); / / 刷新父窗口 / public static void RefreshParent() string js= parent.location.reload(); ; HttpContext.Current.Response.Write(js); / / 格式化为JS可解释的字符串 / / / public static string JSStringFormat(string s) return s.Replace(r,r).Replace(n,n).Replace(,).Replace(,); / / 刷新打开窗口 / public static void RefreshOpener() string js= opener.location.reload(); ; HttpContext.Current.Response.Write(js); / / 打开窗口 / / public static void OpenWebForm(string url) /*/ /*修改目的: 新开页面去掉ie的菜单。 */ string js= /window.open(+url+); 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); ; /*结束*/ /*/ HttpContext.Current.Response.Write(js); public static void OpenWebForm(string url,string name,string future) string js= window.open(+url+,+name+,+future+) ; HttpContext.Current.Response.Write(js); public static void OpenWebForm(string url,string formName) /*/ /*修改目的: 新开页面去掉ie的菜单。 */ /*注释内容: */ /*开始*/ string js= window.open(+url+,+formName+,height=0,width=0,top=0,left=0,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no,directories=no); ; /*结束*/ /*/ HttpContext.Current.Response.Write(js); / / 函数名:OpenWebForm / 功能描述:打开WEB窗口 / / WEB窗口 / 是否全屏幕 public static void OpenWebForm(string url,bool isFullScreen) string js=; if(isFullScreen) js+=var iWidth = 0; js+=var iHeight = 0; js+=iWidth=window.screen.availWidth-10; js+=iHeight=window.screen.availHeight-50; 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; js+=window.open(+url+,szFeatures); else 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); js+=; HttpContext.Current.Response.Write(js); / / 转向Url制定的页面 / / public static void JavaScriptLocationHref(string url) string js= window.location.replace(0); ; js=string.Format(js,url); HttpContext.Current.Response.Write(js); / / 指定的框架页面转换 / / / public static void JavaScriptFrameHref(string FrameName,string url) string js= obj.location.replace(0); ; js = js.Replace(obj,FrameName ); js=string.Format(js,url); HttpContext.Current.Response.Write(js); / /重置页面 / public static void JavaScriptResetPage(string strRows) string js= window.parent.CenterFrame.rows=+strRows+; HttpContext.Current.Response.Write(js); / / 函数名:JavaScriptSetCookie / 功能描述:客户端方法设置Cookie / / Cookie名 / Cookie值 public static void JavaScriptSetCookie(string strName,string strValue) string js= var the_cookie = +strName+=+strValue+ var dateexpire = Tuesday, 01-Dec-2020 12:00:00 GMT; /document.cookie = the_cookie;/写入Cookie document.cookie = the_cookie + ; expires=+dateexpire; ; HttpContext.Current.Response.Write(js); / / 函数名:GotoParentWindow / 功能描述:返回父窗口 / / 父窗口 public static void GotoParentWindow(string parentWindowUrl) string js= this.parent.location.replace(+parentWindowUrl+); HttpContext.Current.Response.Write(js); / / 函数名:ReplaceParentWindow / 功能描述:替换父窗口 / / 父窗口 / 窗口提示 / 窗口特征参数 public static void ReplaceParentWindow(string parentWindowUrl,string caption,string future) string js=; if(future!=null&future.Trim()!=) js=this.parent.location.replace(+parentWindowUrl+,+caption+,+future+); else js=var iWidth = 0 ;var iHeight = 0 ;iWidth=window.screen.availWidth-10;iHeight=window.screen.availHeight-50; var szFeatures = dialogWidth:+iWidth+;dialogHeight:+iHeight+;dialogLeft:0px;dialogTop:0px;center:yes;help=no;resizable:on;status:on;scroll=yes;this.parent.location.replace(+parentWindowUrl+,+caption+,szFeatures); HttpContext.Current.Response.Write(js); / / 函数名:ReplaceOpenerWindow / 功能描述:替换当前窗体的打开窗口 / / 当前窗体的打开窗口 public static void ReplaceOpenerWindow(string openerWindowUrl) string js= window.opener.location.replace(+openerWindowUrl+); HttpContext.Current.Response.Write(js); / / 函数名:ReplaceOpenerParentWindow / 功能描述:替换当前窗体的打开窗口的父窗口 / / 当前窗体的打开窗口的父窗口 public static void ReplaceOpenerParentFrame(string frameName,string frameWindowUrl) string js= window.opener.parent. + frameName + .location.replace(+frameWindowUrl+); HttpContext.Current.Response.Write(js); / / 函数名:ReplaceOpenerParentWindow / 功能描述:替换当前窗体的打开窗口的父窗口 / / 当前窗体的打开窗口的父窗口 public static void ReplaceOpenerParentWindow(string openerParentWindowUrl) string js= window.opener.parent.location.replace(+openerParentWindowUrl+); HttpContext.Current.Response.Write(js); / / 函数名:CloseParentWindow / 功能描述:关闭窗口 / public static void CloseParentWindow() string js= window.parent.close(); ; HttpContext.Current.Response.Write(js); public static void CloseOpenerWindow() string js= window.opener.close(); ; HttpContext.Current.Response.Write(js); / / 函数名:ShowModalDialogJavascript / 功能描述:返回打开模式窗口的脚本 / / / public static string ShowModalDialogJavascript(string webFormUrl) string js= var iWidth = 0 ; var iHeight = 0 ; iWidth=window.screen.availWidth-10; iHeight=window.screen.availHeight-50; var szFeatures = dialogWidth:+iWidth+;dialogHeight:+iHeight+;dialogLeft:0px;dialogTop:0px;center:yes;help=no;resizable:on;status:on;scroll=yes; showModalDialog(+webFormUrl+,szFeatures); return js; public static string ShowModalDialogJavascript(string webFormUrl,string features) string js= showModalDialog(+webFormUrl+,+features+); return js; / / 函数名:ShowModalDialogWindow / 功能描述:打开模式窗口 / / / public static void ShowModalDialogWindow(string webFormUrl) string js=ShowModalDialogJavascript(webFormUrl); HttpContext.Current.Response.Wr

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论