EXT.NET_X.Js.Call方法
来源:互联网 发布:淘宝关键词优化工具 编辑:程序博客网 时间:2024/06/05 02:55
我们对在前台触发一个客户端事件,来操作界面元素,已经很熟悉,但这属于静态脚本范畴。往往有些时候,我们还需要动态脚本,也就是说,脚本在执行过程中需要的变量,是从服务器端获得的,那么X.Js.Call方法的作用,就是将服务器端变量传给客户端脚本,并执行脚本。
例子
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="AM.Web.Pages.Test" %> <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> var myAlert = function() { alert("警告"); } var myAlert2 = function(id, val) { var txtField = Ext.getCmp(id); txtField.setValue(val); alert(txtField.getValue()); } </script> </head> <body> <form id="form1" runat="server"> <ext:ResourceManager ID="ResourceManager1" runat="server" /> <ext:Button ID="Button1" runat="server" OnDirectClick="Button1_Click" Text="X.Js.Call一个参数的"> </ext:Button> <ext:Button ID="Button2" runat="server" OnDirectClick="Button2_Click" Text="X.Js.Call两个参数的"> </ext:Button> <ext:TextField ID="TextField1" runat="server" Text=""> </ext:TextField> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Ext.Net; namespace AM.Web.Pages { public partial class Test : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, DirectEventArgs e) { X.Js.Call("myAlert"); } protected void Button2_Click(object sender, DirectEventArgs e) { string[] paras = new string[] { this.TextField1.ClientID, "警告" }; X.Js.Call("myAlert2", paras); } } }
1,Button2将服务器端变量传给脚本方法“myAlert2”,脚本根据这个值设置页面控件,并显示。
- EXT.NET_X.Js.Call方法
- EXT.NET_X.Js.Call方法
- Ext call方法
- js call方法
- js中的call方法
- js call方法
- js方法 call 详解
- js call方法浅析
- JS中的call()方法
- js call方法
- Js中的call方法
- js call()方法!
- Js apply call方法
- js call 方法
- js call()方法
- js call()方法
- JS-call/apply 方法
- js call()方法
- cmake命令 安装、用法简介
- UBoot的Start.S分析
- Android Java 调用linux 命令
- 模式匹配
- linux 下安装gsl(GNU Scientific Library)
- EXT.NET_X.Js.Call方法
- Hibernate数据加载——Session.get/load
- C语言实现的插入排序
- Struts中使用 DynaActionForm
- 简述configure、pkg-config、pkg_config_path三者的关系
- C#对Dictionary的按Value排序
- servlet学习——分页实现(登录网站的完善)
- pku 3686
- eap-sim rfc4186摘要(1)