UserControl callback page

  1. #1

    UserControl callback page

    Is there a way that I can have a callback method on a page to be called as a result of some action like a button click on a user control in that page?

    Something like a callback delegate?

    Miguel.
  2. #2
    Hi Miguel,

    In Ext.NET v1 you can define a DirectMethod on a page, then call that DirectMethod via JavaScript in a user control.

    In Ext.NET v2 we presented the MessageBus feature.
    https://examples2.ext.net/#/MessageBus/Basic/Complex/
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi Miguel,

    In Ext.NET v1 you can define a DirectMethod on a page, then call that DirectMethod via JavaScript in a user control.

    In Ext.NET v2 we presented the MessageBus feature.
    https://examples2.ext.net/#/MessageBus/Basic/Complex/
    Thanks Daniil, do you have a sample code that shows how the javascript calls the direct method on the page?

    Miguel.
  4. #4
    Here you are.

    Page
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <%@ Register Src="~/TestUC.ascx" TagPrefix="uc" TagName="TestUC" %>
    
    <script runat="server">
        [DirectMethod]
        public void TestDirectMethod()
        {
            X.Msg.Alert("DirectMethod", "Hello from Page!").Show();
        }
    </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>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
           
            <uc:TestUC runat="server" />
        </form>
    </body>
    </html>
    User Control
    <%@ Control Language="C#" %>
    
    <ext:Button runat="server" Text="Call Page's DirectMethod">
        <Listeners>
            <Click Handler="Ext.net.DirectMethods.TestDirectMethod();" />
        </Listeners>
    </ext:Button>

Similar Threads

  1. Replies: 1
    Last Post: May 29, 2013, 6:00 PM
  2. Replies: 1
    Last Post: Jan 19, 2012, 4:20 PM
  3. Replies: 6
    Last Post: Mar 12, 2010, 12:34 AM
  4. [CLOSED] [1.0] DirectMethod - Page . UserControl . UserControl
    By Patrick in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 25, 2010, 9:33 AM
  5. Loading a UserControl (ascx) to a page
    By egodoy in forum 1.x Help
    Replies: 4
    Last Post: Dec 31, 2008, 11:40 AM

Tags for this Thread

Posting Permissions