知识大全 ASP.NET里常用的JS
Posted 函数
篇首语:要得惊人艺,须下苦功夫。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 ASP.NET里常用的JS相关的知识,希望对你有一定的参考价值。
ASP.NET里常用的JS 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
在整理一套OA发现的有些东西 我会陆续拿出给大家 希望对大家有用! ) using System; using System Web; using System Web UI HtmlControls ; using System Web UI; namespace Web JScript /// <summary> /// 提供向页面输出客户端代码实现特殊功能的方法 /// </summary> /// <remarks> /// </remarks> public class JScript public static void AlertAndRedirect(string message string toURL) string js = <script language=javascript>alert( ) window location replace( )</script> ; HttpContext Current Response Write(string Format(js message toURL)) /// <summary> /// 向客户端发送函数KendoPostBack(eventTarget eventArgument) /// 服务器端可接收__EVENTTARGET __EVENTARGUMENT的值 /// </summary> /// <param name= page >System Web UI Page 一般为this</param> public static void JscriptSender(System Web UI Page page) page RegisterHiddenField( __EVENTTARGET ) page RegisterHiddenField( __EVENTARGUMENT ) string s = @ <script language=Javascript> function KendoPostBack(eventTarget eventArgument) var theform = document forms[ ]; theform __EVENTTARGET value = eventTarget; theform __EVENTARGUMENT value = eventArgument; theform submit() </script> ; page RegisterStartupScript( sds s) /// <summary> /// 弹出JavaScript小窗口 /// </summary> /// <param name= js >窗口信息</param> public static void Alert(string message) message = StringUtil DeleteUnVisibleChar(message) string js=@ <Script language= JavaScript > alert( + message + ) </Script> ; HttpContext Current Response Write(js) public static void Alert(object message) string js=@ <Script language= JavaScript > alert( ) </Script> ; HttpContext Current Response Write(string Format(js message ToString())) public static void RtnRltMsgbox(object message string strWinCtrl) string js = @ <Script language= JavaScript > strWinCtrl = true; strWinCtrl = if(!confirm( + message + ))return false;</Script> ; HttpContext Current Response Write(string Format(js message ToString())) /// <summary> /// 回到历史页面 /// </summary> /// <param name= value > / </param> public static void GoHistory(int value) string js=@ <Script language= JavaScript > history go( ) </Script> ; HttpContext Current Response Write(string Format(js value)) /// <summary> /// 关闭当前窗口 /// </summary> public static void CloseWindow() string js=@ <Script language= JavaScript > window close() </Script> ; HttpContext Current Response Write(js) HttpContext Current Response End() /// <summary> /// 刷新父窗口 /// </summary> public static void RefreshParent() string js=@ <Script language= JavaScript > parent location reload() </Script> ; HttpContext Current Response Write(js) /// <summary> /// 格式化为JS可解释的字符串 /// </summary> /// <param name= s ></param> /// <returns></returns> public static string JSStringFormat(string s) return s Replace( \\r \\\\r ) Replace( \\n \\\\n ) Replace( \\\\ ) Replace( \\ \\\\\\ ) /// <summary> /// 刷新打开窗口 /// </summary> public static void RefreshOpener() string js=@ <Script language= JavaScript > opener location reload() </Script> ; HttpContext Current Response Write(js) /// <summary> /// 打开窗口 /// </summary> /// <param name= url ></param> public static void OpenWebForm(string url) /*……*/ /*修改目的 新开页面去掉ie的菜单… */ string js=@ <Script language= JavaScript > //window open( +url+@ ) window open( +url+@ height= width= top= left= location=no menubar=no resizable=yes scrollbars=yes status=yes titlebar=no toolbar=no directories=no ) </Script> ; /*结束*/ /*……*/ HttpContext Current Response Write(js) public static void OpenWebForm(string url string name string future) string js=@ <Script language= JavaScript > window open( +url+@ +name+@ +future+@ ) </Script> ; HttpContext Current Response Write(js) public static void OpenWebForm(string url string formName) /*……*/ /*修改目的 新开页面去掉ie的菜单… */ /*注释内容 */ /*开始*/ string js=@ <Script language= JavaScript > window open( +url+@ +formName+@ height= width= top= left= location=no menubar=no resizable=yes scrollbars=yes status=yes titlebar=no toolbar=no directories=no ) </Script> ; /*结束*/ /*……*/ HttpContext Current Response Write(js) /// <summary> /// 函数名 OpenWebForm /// 功能描述 打开WEB窗口 /// </summary> /// <param name= url >WEB窗口</param> /// <param name= isFullScreen >是否全屏幕</param> public static void OpenWebForm(string url bool isFullScreen) string js=@ <Script language= JavaScript > ; if(isFullScreen) js+= var iWidth = ; ; js+= var iHeight = ; ; js+= iWidth=window screen availWidth ; ; js+= iHeight=window screen availHeight ; ; js+= var szFeatures = width= + iWidth + height= + iHeight + top= left= 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= width= top= left= location=no menubar=no resizable=yes scrollbars=yes status=yes titlebar=no toolbar=no directories=no ) ; js+= </Script> ; HttpContext Current Response Write(js) /// <summary> /// 转向Url制定的页面 /// </summary> /// <param name= url ></param> public static void JavaScriptLocationHref(string url) string js=@ <Script language= JavaScript > window location replace( ) </Script> ; js=string Format(js url) HttpContext Current Response Write(js) /// <summary> /// 指定的框架页面转换 /// </summary> /// <param name= FrameName ></param> /// <param name= url ></param> public static void JavaScriptFrameHref(string FrameName string url) string js=@ <Script language= JavaScript > @obj location replace( ) </Script> ; js = js Replace( @obj FrameName ) js=string Format(js url) HttpContext Current Response Write(js) /// <summary> ///重置页面 /// </summary> public static void JavaScriptResetPage(string strRows) string js=@ <Script language= JavaScript > window parent CenterFrame rows= +strRows+ ;</Script> ; HttpContext Current Response Write(js) /// <summary> /// 函数名 JavaScriptSetCookie /// 功能描述 客户端方法设置Cookie /// </summary> /// <param name= strName >Cookie名</param> /// <param name= strValue >Cookie值</param> public static void JavaScriptSetCookie(string strName string strValue) string js=@ <script language=Javascript> var the_cookie = +strName+ = +strValue+@ var dateexpire = Tuesday Dec : : GMT ; //okie = the_cookie;//写入Cookie<BR> <BR> okie = the_cookie + ; expires= +dateexpire; </script> ; HttpContext Current Response Write(js) /// <summary> /// 函数名 GotoParentWindow /// 功能描述 返回父窗口 /// </summary> /// <param name= parentWindowUrl >父窗口</param> public static void GotoParentWindow(string parentWindowUrl) string js=@ <Script language= JavaScript > this parent location replace( +parentWindowUrl+ ) </Script> ; HttpContext Current Response Write(js) /// <summary> /// 函数名 ReplaceParentWindow /// 功能描述 替换父窗口 /// </summary> /// <param name= parentWindowUrl >父窗口</param> /// <param name= caption >窗口提示</param> /// <param name= future >窗口特征参数</param> public static void ReplaceParentWindow(string parentWindowUrl string caption string future) string js= ; if(future!=null&&future Trim()!= ) js=@ <script language=javascript>this parent location replace( +parentWindowUrl+ +caption+ +future+ ) </script> ; else js=@ <script language=javascript>var iWidth = ;var iHeight = ;iWidth=window screen availWidth ;iHeight=window screen availHeight ; var szFeatures = dialogWidth: +iWidth+ ;dialogHeight: +iHeight+ ;dialogLeft: px;dialogTop: px;center:yes;help=no;resizable:on;status:on;scroll=yes ;this parent location replace( +parentWindowUrl+ +caption+ szFeatures) </script> ; HttpContext Current Response Write(js) /// <summary> /// 函数名 ReplaceOpenerWindow /// 功能描述 替换当前窗体的打开窗口 /// </summary> /// <param name= openerWindowUrl >当前窗体的打开窗口</param> public static void ReplaceOpenerWindow(string openerWindowUrl) string js=@ <Script language= JavaScript > window opener location replace( +openerWindowUrl+ ) </Script> ; HttpContext Current Response Write(js) /// <summary> /// 函数名 ReplaceOpenerParentWindow /// 功能描述 替换当前窗体的打开窗口的父窗口 /// </summary> /// <param name= openerWindowUrl >当前窗体的打开窗口的父窗口</param> public static void ReplaceOpenerParentFrame(string frameName string frameWindowUrl) string js=@ <Script language= JavaScript > window opener parent + frameName + location replace( +frameWindowUrl+ ) </Script> ; HttpContext Current Response Write(js) /// <summary> /// 函数名 ReplaceOpenerParentWindow /// 功能描述 替换当前窗体的打开窗口的父窗口 /// </summary> /// <param name= openerWindowUrl >当前窗体的打开窗口的父窗口</param> public static void ReplaceOpenerParentWindow(string openerParentWindowUrl) string js=@ <Script language= JavaScript > window opener parent location replace( +openerParentWindowUrl+ ) </Script> ; HttpContext Current Response Write(js) /// <summary> /// 函数名 CloseParentWindow /// 功能描述 关闭窗口 /// </summary> public static void CloseParentWindow() string js=@ <Script language= JavaScript > window parent close() </Script> ; HttpContext Current Response Write(js) public static void CloSEOpenerWindow() string js=@ <Script language= JavaScript > window opener close() </Script> ; HttpContext Current Response Write(js) /// <summary> /// 函数名 ShowModalDialogJavascript /// 功能描述 返回打开模式窗口的脚本 /// </summary> /// <param name= webFormUrl ></param> /// <returns></returns> public static string ShowModalDialogJavascript(string webFormUrl) string js=@ <script language=javascript> var iWidth = ; var iHeight = ; iWidth=window screen availWidth ; iHeight=window screen availHeight ; var szFeatures = dialogWidth: +iWidth+ ;dialogHeight: +iHeight+ ;dialogLeft: px;dialogTop: px;center:yes;help=no;resizable:on;status:on;scroll=yes ; showModalDialog( +webFormUrl+ szFeatures) </script> ; return js; public static string ShowModalDialogJavascript(string webFormUrl string features) string js=@ <script language=javascript> showModalDialog( +webFormUrl+ +features+ ) </script> ; return js; /// <summary> /// 函数名 ShowModalDialogWindow /// 功能描述 打开模式窗口 /// </summary> /// <param name= webFormUrl ></param> /// <returns></returns> public static void ShowModalDialogWindow(string webFormUrl) string js=ShowModalDialogJavascript(webFormUrl) HttpContext Current Response Write(js) public static void ShowModalDialogWindow(string webFormUrl string features) string js=ShowModalDialogJavascript(webFormUrl features) HttpContext Current Response Write(js) public static void ShowModalDialogWindow(string webFormUrl int width int height int top int left) string features = dialogWidth: +width ToString() + px + ;dialogHeight: + height ToString() + px + ;dialogLeft: + left ToString() + px + ;dialogTop: + top ToString() + px + ;center:yes;help=no;resizable:no;status:no;scroll=no ; ShowModalDialogWindow(webFormUrl features) public static void SetHtmlElementValue(string formName string elementName string elementValue) string js=@ <Script language= JavaScript >if(document +formName+ + elementName + !=null)document +formName+ + elementName + value = + elementValue + ;</Script> ; HttpContext Current Response Write(js) cha138/Article/program/net/201311/13974相关参考
知识大全 ASP.NET中用js取CheckBoxList中值的方法实例
ASP.NET中用js取CheckBoxList中值的方法实例 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来
前台: 代码 <%@PageLanguage=C#AutoEventWireup=trueCodeFile=DefaultaspxcsInherits=_Default%>
利用JS在asp.net中实现左导航页的隐藏 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!&nbs
知识大全 asp.net后台cs中的JSON格式变量在前台Js中调用方法
asp.net后台cs中的JSON格式变量在前台Js中调用方法 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来
asp.NetJS取母板页控件值的简单方法 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!这篇文章介
这两天遇到一个需求就是在一个页面中浮动一张图片兼容浏览器那是默认需求鼠标悬停那也算是默认需求本来认为没什么麻烦的网上那么多随便搜一个再改吧改吧就哦了可是后来发现没有想象的那么简单 问题一网上DE
.Net课堂:ASP.NET常用的优化性能方法 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 数
支持入门—ASP.NET常用技巧 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 在上一篇《深入A
知识大全 asp.net中DataGridView的常用用法
asp.net中DataGridView的常用用法 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
ASP.NET常用6种验证控件介绍 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! Requi