[CLOSED] MessageBox Confirm - Using DirectMethod and CodeBehind

  1. #1

    [CLOSED] MessageBox Confirm - Using DirectMethod and CodeBehind

    Ext.Net 2.x Question:

    Hello - I am trying to ask the user a question using the MessageBox, and depending on his/her answer, I want to take two different paths. So far, according to previous posts, I have written the code listed below. I don't get any syntax or run-time errors. When I run in debug, it runs this code, and continues to the next lines, but nothing happens.

    //  Code in the CodeBehind, which calls the DoYes or DoNo functions
    
                ext.X.MessageBox.Confirm("Test", "Are you sure?", new ext.MessageBoxButtonsConfig
                {
                  Yes = new ext.MessageBoxButtonConfig
                  {
                    Handler = "Assignments.DoYes()",
                    Text = "Yes I'm sure"
                  },
                  No = new ext.MessageBoxButtonConfig
                  {
                    Handler = "Assignments.DoNo()",
                    Text = "No Thanks"
                  }
                }).Show(); 
    
    //Beginning of markup:
    
    <script runat="server">
        [DirectMethod]
        public void DeleteYes()
        {
          this.ExtHiddenDeleteConfirm.Text = "yes";
        }
    
        [DirectMethod]
        public void DeleteNo()
        {
          this.ExtHiddenDeleteConfirm.Text = "yes";
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head runat="server">
        <title></title>
            <link rel="stylesheet" href="VAStyle.css" />
    </head>
    <body>
    
        <form id="frmExtAssignmentsSummary" runat="server">
        <ext:ResourceManager 
            ID="rmExtAssignmentsSummary" 
            runat="server"
                    DirectMethodNamespace="Assignments" 
        >
        </ext:ResourceManager>
    
        <%--Hidden Fields - ViewState --%>
        <ext:Hidden ID="ExtHidden_AddorModify" runat="server"></ext:Hidden>
        <ext:Hidden ID="ExtHidden_ID" runat="server"></ext:Hidden>
        <ext:Hidden ID="ExtHidden_Student_People_ID" runat="server"></ext:Hidden>
        <ext:Hidden ID="ExtHidden_Teacher_People_ID" runat="server"></ext:Hidden>
        <ext:Hidden ID="ExtHidden_sFilterCategory" runat="server"></ext:Hidden>
           <ext:Hidden ID="ExtHidden_sFilterStatus" runat="server"></ext:Hidden>
           <ext:Hidden ID="ExtHiddenDeleteConfirm" runat="server"></ext:Hidden>
    Last edited by Daniil; Sep 17, 2013 at 5:28 AM. Reason: [CLOSED]
  2. #2

    Correction:

    Sorry - in the original question I had names that disagree: ie DoYes and DeleteYes. In the actual code, however, the names do agree! So that's not the problem.
  3. #3
    Hi @VirtualArtists,

    Seems the following test case works as expected.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Confirm(object sender, DirectEventArgs e)
        {
            X.MessageBox.Confirm("Test", "Are you sure?", new MessageBoxButtonsConfig
            {
                Yes = new MessageBoxButtonConfig
                {
                    Handler = "Assignments.DoYes()",
                    Text = "Yes I'm sure"
                },
                No = new MessageBoxButtonConfig
                {
                    Handler = "Assignments.DoNo()",
                    Text = "No Thanks"
                }
            }).Show();
        }
    
        [DirectMethod]
        public void DoYes()
        {
            X.Msg.Alert("DirectMethod", "DoYes").Show();
        }
    
        [DirectMethod]
        public void DoNo()
        {
            X.Msg.Alert("DirectMethod", "DoNo").Show();
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" DirectMethodNamespace="Assignments" />
            <ext:Button runat="server" Text="Confirm" OnDirectClick="Confirm" />
        </form>
    </body>
    </html>
    Please provide your full and runnable test case.
  4. #4

    Thanks - your example does work - How to change the colors?

    Thanks Daniil - I followed your example and it does work well, so I may just go that direction rather than trying to have the Confirm function in CodeBehind. Putting the Confirm in the markup script is definitely a solution, but I don't seem to be able to use my css class for the confirm Messagebox.

    Is there a way to point to css classes with the Confirm example you sent me? ... OR ....

    Is there a way to code the Confirm in the CodeBehind and have it call the DirectionMethod functions?

    This little section of code is part of a huge application, and it would be very time consuming to create a working test case.
  5. #5
    Sorry, I don't quite understand both the questions.

    Quote Originally Posted by VirtualArtists View Post
    Is there a way to point to css classes with the Confirm example you sent me? ... OR ....
    Do you want to stylize a confirmation dialog?

    Quote Originally Posted by VirtualArtists View Post
    Is there a way to code the Confirm in the CodeBehind and have it call the DirectionMethod functions?
    It looks like a confirmation dialog appears in my example due to code behind calls. So, please elaborate the requirement.
  6. #6

    MessageBox. Confirm CSS styling

    Yes, I want to Stylize a Confirmation Box - how can I do that?
  7. #7
    Is it an option for you to apply the styles globally? As here:

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        protected void Confirm(object sender, DirectEventArgs e)
        {
            X.MessageBox.Confirm("Test", "Are you sure?").Show();
        }
     
    </script>
     
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <style>
            .x-message-box div.x-form-display-field {
                color: red;
            }
        </style>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Button runat="server" Text="Confirm" OnDirectClick="Confirm" />
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] V2.0 Confirm MessageBox with ButtonsConfig
    By Aurelio in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 06, 2012, 4:40 PM
  2. Replies: 1
    Last Post: Mar 08, 2011, 6:48 PM
  3. [CLOSED] Confirm messagebox from codebehind
    By CarWise in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 30, 2010, 1:20 PM
  4. Call method in the MessageBox.Confirm
    By flaviodamaia in forum 1.x Help
    Replies: 0
    Last Post: Mar 10, 2010, 10:35 AM
  5. [CLOSED] Confirm MessageBox
    By gokcemutlu in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 13, 2009, 12:47 PM

Tags for this Thread

Posting Permissions