Ext.net 往后台传递参数

了解过ext.net的朋友们应该知道 ext中有两种函数调用方式 1为Listeners 2为DirectEvents 两种函数使用都是比较灵活的 本文主要说明这两种函数如何向后台传递参数


1. Listeners

<!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 id="Head1" runat="server">
    <title>参数传递</title>
    <script type="text/javascript">

        function Test(arg1) {
            Ext.net.DirectMethods.GetNodeInfo(arg1, {
                success: function () { },
                failure: function (errorMsg) { }
            });
        }
    </script>
</head>
<body>
    <form id="Form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:Button ID="btnSave" runat="server" Text="Test" Icon="Disk">
        <Listeners>
            <Click Handler="Test('1')" />
        </Listeners>
    </ext:Button>
    </form>
</body>
</html>

2.DirectEvents 

<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    protected void Test(object sender, DirectEventArgs e)
    {
        var arg = e.ExtraParams["arg1"].ToString();
    }
</script>
<!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 id="Head1" runat="server">
    <title>参数传递</title>
</head>
<body>
    <form id="Form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:Button ID="btnSave" runat="server" Text="Test" Icon="Disk">
        <DirectEvents>
            <Click OnEvent="Test" Timeout="300000">
                <EventMask ShowMask="true" Target="This" />
                <ExtraParams>
                    <ext:Parameter Name="arg1" Value="1" Mode="Raw" />
                </ExtraParams>
            </Click>
        </DirectEvents>
    </ext:Button>
    </form>
</body>
</html>


发布了24 篇原创文章 · 获赞 1 · 访问量 2万+
展开阅读全文

Ext.Net1.7 后台操作页面超时 并 实现进度条的问题

10-01

![](https://img-ask.csdn.net/upload/201510/01/1443698718_356785.png) 需要达到如图样式 protected void Page_Load(object sender, EventArgs e) { } private static string TableName; //要修改的表名 [DirectMethod(Timeout = 900000)] protected void btnOK_DirectClick(object sender, Ext.Net.DirectEventArgs e) { UpHouse(); } [DirectMethod(Timeout=900000)] public void UpHouse() { try { TableName = this.txtTable.Text.Trim(); DataTable dt = GetDataReader("select distinct HouseCode from " + TableName + " order by HouseCode"); //获取非重复的数据 foreach (DataRow dr in dt.Rows) { string HouseCode = dr["HouseCode"].ToString(); string strSql = "select Id,HouseCode,HouseNo from " + TableName + " where HouseCode = '" + HouseCode + "' order by HouseCode"; DataTable dtr = GetDataReader(strSql); for (int i = 0; i < dtr.Rows.Count; i++) { string HouseCode_new = dtr.Rows[i]["HouseCode"].ToString().Trim(); string HouseNo = dtr.Rows[i]["HouseNo"].ToString().Trim(); string HouseId = dtr.Rows[i]["Id"].ToString().Trim(); if (HouseCode_new != HouseNo) { string UdSql = "Update " + TableName + " set HouseNo = '" + HouseCode_new + "' where Id = " + HouseId; UpdateDataReader(UdSql); break; } } } X.Msg.Alert("提示", "修改成功!").Show(); } catch (Exception e) { X.Msg.Alert("提示", "修改失败!" + e.Message).Show(); } } #region 数据处理 public static string strConn = "Data source=localhost;database=HH;user id=sa;pwd=sa;"; public static DataTable GetDataReader(string strSql) { using (SqlConnection connection = new SqlConnection(strConn)) { DataTable dt = new DataTable(); try { SqlDataAdapter command = new SqlDataAdapter(strSql, strConn); connection.Open(); command.Fill(dt); } catch (Exception ex) { connection.Close(); throw new Exception(ex.Message); } finally { connection.Close(); } return dt; } } public static int UpdateDataReader(string strSql) { using (SqlConnection connection = new SqlConnection(strConn)) { DataSet ds = new DataSet(); try { SqlCommand command = new SqlCommand(strSql, connection); connection.Open(); if (command.ExecuteNonQuery() > 0) { return 1; } else { return 0; } } catch (Exception ex) { connection.Close(); throw new Exception(ex.Message); } finally { connection.Close(); } } } #endregion } } 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览