MessageBoxButtonsConfig

  1. #1

    MessageBoxButtonsConfig

    Hi,

    This is my code:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test8.aspx.cs" Inherits="test8" %>
    <%@ 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>Test8</title>
    </head>
    <body>
        
        <form id="form1" runat="server">
        <div>
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <ext:Label ID="Label1" runat="server" FieldLabel="Here: " />
            
            <ext:Button ID="btnExit" runat="server" Text="Exit" Icon="LockGo">
               <DirectEvents>
                  <Click OnEvent="btnExit_Click" />            
               </DirectEvents>   
            </ext:Button>
        </div>
        </form>
        
    </body>
    </html>
    protected void btnExit_Click(object sender, EventArgs e)
        {        
            
            MessageBoxButtonConfig buttonYes = new MessageBoxButtonConfig();
            buttonYes.Text = "opcion yes";
            buttonYes.Handler = "ClickedYES();";
    
            MessageBoxButtonConfig buttonNo = new MessageBoxButtonConfig();
            buttonNo.Text = "opcion no";
            buttonNo.Handler = "ClickedNO";
    
            MessageBoxButtonsConfig buttons = new MessageBoxButtonsConfig();
            buttons.Yes = buttonYes;
            buttons.No = buttonNo;
    
            X.Msg.Confirm("Exit", "Sure?", buttons).Show();
            
        }
    
    
        protected void ClickedYES()
        {
            Label1.Text = "You clicked YES";
        }
    
    
        protected void ClickedNO(object sender, EventArgs e)
        {
            Label1.Text = "You clicked NO";
        }
    The issue is 'Label1' is always empty.

    How can i solve it?

    Thanks.
  2. #2
    Hi,

    Well, this is a client side handler:
    buttonYes.Handler
    You can make the ClickedYES and ClickedNO methods DirectMethods and call them from client side.
  3. #3
    Hi Daniil,

    I canĀ“t understand you.

    Can you show me an example?

    Thanks.
    Last edited by walle; Jul 31, 2011 at 8:54 PM.
  4. #4
    Here you are.

    Example
    buttonYes.Handler = "Ext.net.DirectMethods.ClickedYES();";
    
    [DirectMethod]
    public void ClickedYES(){
    
        Label1.Text = "You clicked YES";
    
    }
  5. #5
    Hi Daniil,

    This code does not work fine:

    protected void btnExit_Click(object sender, EventArgs e)
        {        
            
            MessageBoxButtonConfig buttonYes = new MessageBoxButtonConfig();
            buttonYes.Text = "opcion yes";
            buttonYes.Handler = "Ext.net.DirectMethods.ClickedYES();";
    
            MessageBoxButtonConfig buttonNo = new MessageBoxButtonConfig();
            buttonNo.Text = "opcion no";
            buttonNo.Handler = "Ext.net.DirectMethods.ClickedNO();";
    
            MessageBoxButtonsConfig botones = new MessageBoxButtonsConfig();
            botones.Yes = buttonYes;
            botones.No = buttonNo;
    
            X.Msg.Confirm("Exit", "Sure?", botones).Show();
            
        }
    
        [DirectMethod]
        protected void ClickedYES()
        {
            Label1.Text = "You clicked YES";
        }
    
        [DirectMethod]
        protected void ClickedNO()
        {
            Label1.Text = "You clicked NO";
        }
    Label1 is not shown.
  6. #6
    DirectMethods must be "public", not "protected".
  7. #7
    Hi Daniil,

    Perfect, now it works fine. !!

    Thanks.

Posting Permissions