[CLOSED] [1.0] Ext.Msg.Show Code behind

  1. #1

    [CLOSED] [1.0] Ext.Msg.Show Code behind

    I have a Window that pops up with a Accept and Decline button. When the Decline button is clicked, it does some processing and database updating on the backend.

    If the database fails to update, I want to show a MessageBox with the error. However, no matter what I have tired, I've had no luck showing the MessageBox.

    .aspx:

    <ext:Window ID="wDecline" runat="server" Title="Decline?" Icon="Delete" Modal="true" Resizable="false" Layout="Fit" Width="300" Height="250">
        <Items>
            <ext:Label runat="server" Text="Stuff here" />
        </Items>
        <Buttons>
            <ext:Button ID="bDecline" runat="server" Text="Decline" Icon="Delete">
                <DirectEvents>
                    <Click OnEvent="bDecline_Click" />
                </DirectEvents>
            </ext:Button>
            <ext:Button ID="bAbort" runat="server" Text="Abort" Icon="Reload">
                <Listeners>
                    <Click Handler="wDecline.hide();" />
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
    .aspx.cs:

    protected void bDecline_Click(object sender, DirectEventArgs e)
    {
        Exception error = null;
    
        try
        {
            // Do database stuff here
        }
        catch(Exception ex)
        {
            error = ex;
        }
            
        if (error != null)
        {
            // TODO: Want to show Ext.Messagebox from here with the error.
            // I have tried AddScript, etc. with no luck
        }
        else
        {
            Response.Redirect("default.aspx");
        }
    }
    Thanks.
  2. #2

    RE: [CLOSED] [1.0] Ext.Msg.Show Code behind

    Hi,

    Did you try X.Msg class?


    Please see examples from Examples Explorer


    Ext.Net.Examples\Examples\MessageBox\Basic\
  3. #3

    RE: [CLOSED] [1.0] Ext.Msg.Show Code behind

    Here's a full X.Msg.Alert sample.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <script runat="server">
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Server Time", DateTime.Now.ToString()).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" />
            
            <ext:Button runat="server" Text="Submit" OnDirectClick="Button1_Click" />
        </form>
    </body>
    </html>
    X.Msg.Notify is also a handy option to play with.

    Geoffrey McGill
    Founder
  4. #4

    RE: [CLOSED] [1.0] Ext.Msg.Show Code behind

    The key point to remember with the X.Msg related Methods is to ensure you call .Show().

    Geoffrey McGill
    Founder
  5. #5

    RE: [CLOSED] [1.0] Ext.Msg.Show Code behind

    Hey, this worked!

    Thanks guys!
  6. #6

    RE: [CLOSED] [1.0] Ext.Msg.Show Code behind

    As well, the X.Msg is just an alias for the full MessageBox class, which you can instantiate an instance of directly if you wish.

    Example

    protected void Button1_Click(object sender, DirectEventArgs e)
    {
        var msg = new MessageBox();
        
        // do something....
        
        msg.Alert("Server Time", DateTime.Now.ToString());
        
        // do something else...
        
        
        msg.Show();
    }
    Hope this helps.

    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] problem show TableLayout from code behind
    By tactime10 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 05, 2011, 1:15 PM
  2. [CLOSED] Window Created in Code Behind does not show
    By sisa in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 09, 2011, 3:13 PM
  3. Replies: 3
    Last Post: May 26, 2011, 8:02 AM
  4. Which control can show html code?
    By nixjojo in forum 1.x Help
    Replies: 2
    Last Post: Sep 30, 2010, 10:36 AM
  5. ext:window.Show from VB code behind
    By Groovepoets in forum 1.x Help
    Replies: 1
    Last Post: Jun 22, 2009, 3:43 PM

Posting Permissions