首页 > Web开发 > 详细

DirectEvents EXT.NET

时间:2019-06-19 09:49:44      阅读:119      评论:0      收藏:0      [点我收藏+]

HTML:

                                <ext:Button ID="UploadButton" runat="server" Text="文件上传" Icon="TableColumnAdd" >
                                    <DirectEvents>
                                        <Click
                                            OnEvent="UploadClick"
                                            Before="Ext.MessageBox.wait(‘‘, ‘上传中,请稍等...‘,
                                                                               {
                                                                                   interval: 1000, 
                                                                                   duration: 50000,
                                                                                   increment: 10,
                                                                                   text: ‘上传中...‘,
                                                                                   scope: this

                                                                               }); "
                                            Failure="Ext.Msg.show({
                                                                                    title   : ‘错误‘,
                                                                                    msg     : ‘上传失败
                                                                                    minWidth: 200,
                                                                                    modal   : true,
                                                                                    icon    : Ext.Msg.WARNING,
                                                                                    buttons : Ext.Msg.OK
                                                                                });"
                                            Timeout="30000">
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
或者

<ext:Button 
      ID="Button1" 
      runat="server" 
      Text="Click Me" 
      OnDirectClick="ButtonClick" />


 

C#:

protected void UploadClick(object sender, DirectEventArgs e) //函数是包含 object sender, DirectEventArgs e 两个参数的。
{ }

 

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
    protected void TestDirectEventHandler(object sender, DirectEventArgs e)
    {
        X.Msg.Alert("DirectEvent", e.ExtraParams.Count).Show();
    }

    protected void AddParameter(object sender, DirectEventArgs e)
    {
        object p = new { 
            name = "newParam",
            value = "newParam",
        };

        X.Js.Call("addParameter", new JRawValue(Button1.ClientID), p);
    }
</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 runat="server">
    <title>Ext.Net Example</title>

    <script type="text/javascript">
        var onBefore = function (button, extraParams) {
            if (button.clickExtraParam) {
                extraParams[button.clickExtraParam.name] = button.clickExtraParam.value;
            } 
        };

        var addParameter = function (button, p) {
            if (!button.clickExtraParam) {
                button.clickExtraParam = {};
            }
            button.clickExtraParam.name = p.name;
            button.clickExtraParam.value = p.value;   
        };
    </script>
</head>
<body>
    <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:Button ID="Button1" runat="server" Text="DirectEvent with ExtraParams">
            <DirectEvents>
                <Click OnEvent="TestDirectEventHandler" Before="onBefore(this, extraParams)">
                    <ExtraParams>
                        <ext:Parameter Name="someParam" Value="someParam" Mode="Value" />
                    </ExtraParams>    
                </Click>
            </DirectEvents>
        </ext:Button>
        <ext:Button runat="server" Text="Add an extra parameter" OnDirectClick="AddParameter" />
    </form>
</body>
</html>

 

DirectEvents EXT.NET

原文:https://www.cnblogs.com/BinBinGo/p/11049497.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!