Ext.Net.button 和其他控件,实现不同点击事件效果(包括调用自定义控件)

(近期会连续更新有关Ext.Net 控件的一些资料,与大家分享,有兴趣或者最近也在研究这方面知识的朋友可以加关注!!!)

主页面:

头部先引用自定义控件:

<%@ Register Src="MyUserControl.ascx" TagName="MyUserControl" TagPrefix="uc" %>

 

<ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="CompanyX">

            <CustomDirectEvents>

                <ext:DirectEvent Target="Button3" OnEvent="UpdateTimeStamp" />

                <ext:DirectEvent Target="Button4" OnEvent="UpdateTimeStamp" />

                <ext:DirectEvent Target="Span1" OnEvent="UpdateTimeStamp" />

                <ext:DirectEvent Target="${div.box:not(div.red)}" OnEvent="UpdateTimeStamp" />

            </CustomDirectEvents>

        </ext:ResourceManager>

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

        <ext:Button ID="Button2" runat="server" Text="Click Me 2">

            <DirectEvents>

                <Click OnEvent="UpdateTimeStamp">

                    <Confirmation ConfirmRequest="true" Title="Title" Message="这是一个提示框,点击“是”,出现信息框" />

                </Click>

            </DirectEvents>

        </ext:Button>

        <asp:Button ID="Button3" runat="server" Text="Click Me 3" />

        <br />

        <input id="Button4" type="button" value="Click Me 4" />

        <br />

        <span id="Span1" style="cursor: pointer;">Click Me Span1</span>

        <br />

        <ext:Button ID="Button5" runat="server" Text="Unhandled Exception">

            <Listeners>

                <Click Handler="CompanyX.UnhandledException();" />

            </Listeners>

        </ext:Button>

        <ext:Button ID="Button6" runat="server" Text="Click Me" Icon="Lightning">

            <Listeners>

                <Click Handler="

                    CompanyX.GetCustomer({

                        success : function (customer) {

                            var template = 'ID : {0}{6} Name : {1} {2}{6} Company : {3}{6} Country : {4}{6} Premium Member : {5}',

                                msg = Ext.String.format(template, 

                                        customer.ID, 

                                        customer.FirstName, 

                                        customer.LastName, 

                                        customer.Company, 

                                        customer.Country.Name, 

                                        customer.Premium, 

                                        '&lt;br /&gt;&lt;br /&gt;');

                            

                            Ext.Msg.alert('Customer', msg);

                        }

                    });" />

            </Listeners>

        </ext:Button>

        <uc:MyUserControl ID="UserControl1" runat="server" Name="Bob" />

        <br />

        <uc:MyUserControl ID="UserControl2" runat="server" Name="Billy" />

后台代码:

 protected void UpdateTimeStamp(object sender, DirectEventArgs e)

        {

            X.Msg.Notify("The Server Time is: ", DateTime.Now.ToLongTimeString()).Show();

        }



        [DirectMethod]

        public void UnhandledException()

        {

            X.Msg.Notify("text", "DirectMethod 方法的事件调用").Show();

        }



        public class Customer

        {

            public int ID { get; set; }

            public string FirstName { get; set; }

            public string LastName { get; set; }

            public string Company { get; set; }

            public Country Country { get; set; }

            public bool Premium { get; set; }

        }



        public class Country

        {

            public string Name { get; set; }

        }



        [DirectMethod]

        public static Customer GetCustomer()

        {



            return new Customer()

            {

                ID = 99,

                FirstName = "Peter",

                LastName = "Smith",

                Company = "CompanyX, LLC.",

                Premium = true,

                Country = new Country { Name = "Canada" }

            };

        }

自定义控件,页面代码:

页面名称:MyUserControl.ascx

<ext:Button ID="Button1" runat="server">

    <Listeners>

        <Click Handler="#{DirectMethods}.GetName();" />

    </Listeners>

</ext:Button>

后台代码:

  protected void Page_Load(object sender, EventArgs e)

        {

            if (!X.IsAjaxRequest)

            {

                this.Button1.Text = string.Concat("UserControl (", this.Name, ")");

            }

        }



        [DirectMethod]

        public void GetName()

        {

            X.Msg.Alert("Name", this.Name).Show();

        }



        public string Name { get; set; }

 

你可能感兴趣的:(button)