Need Help : MessageBox setIcon() not working on Alert()

  1. #1

    Need Help : MessageBox setIcon() not working on Alert()

    Hi,
    I have implemented ext.net MessageBox in my codes.
    Im wondering that SetIcon(MessageBox.Icon.Question) or SetIcon("Question") is not at all working for Alert() method. but working fine for Confirm() and Prompt() methods. (not only this, other icons also not working with Alert()).

    Below is my code.
    
    In aspx page:
    
     <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
    <asp:Button runat="server" ID="btnShowMsg" Text="Show Me Alert" OnClick="btnShowMsg_Click"  />
    
    In Code behind:
    protected void btnShowMsg_Click(object sender, EventArgs e)
     {
     Ext.Net.MessageBox msg = new MessageBox();
            msg.Alert("Message", "success");
            msg.SetIcon("WARNING");       
            //msg.SetIcon(MessageBox.Icon.WARNING);
            msg.Show();
    }
    
    (OR)
    
    protected void btnShowMsg_Click(object sender, EventArgs e)
        {
    Ext.Net.X.Msg.Alert("hello", "Success");
            Ext.Net.X.Msg.SetIcon(MessageBox.Icon.WARNING);
            Ext.Net.X.Msg.Show();
    }
    Even i added EnableViewState= true to the button also, no luck. Am i missing anything here? Or is it a bug ?
    Plz help me on this asap.

    Previously i was using the below normal javascript code (from codebehind) to display alerts in my project when insert/update button clicks.

    ScriptManager.RegisterStartupScript(Page, typeof(Page), "alert", string.Format("alert('Successfully created.');"), true);
    Now i wanted to replace this with ext MessageBoxes with several default Icons. As shown in the above codes, am i doing in a right way or is there any other way to implement this ?

    Thanks in advance.

    Regards,
    Santhosh
    Last edited by santhu12smart; Dec 09, 2011 at 4:20 AM.
  2. #2
    Hi,

    Please use the Configure method.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void ShowAlert(object sender, DirectEventArgs e)
        {
            Ext.Net.MessageBox msg = new MessageBox();
            msg.Configure(new MessageBoxConfig()
                {
                    Title = "Title",
                    Message = "Message",
                    Icon = MessageBox.Icon.WARNING,
                    Buttons = MessageBox.Button.OK
    
                });
            msg.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="Show an alert box" OnDirectClick="ShowAlert" />
        </form>
    </body>
    </html>
  3. #3

    I have other Similar solution

    Hi,
    Thanks alot for ur help.
    I have an another solution for this as well and which is similar to yours.
    Im not using ext button and direct events.

    I have implemented with normal asp.net button.

    Below is the code in button click of my code behind page.

    Ext.Net.X.Msg.Show(new MessageBoxConfig
                            {
                                Title = "Message",
                                Message = "Update Success.",
                                Buttons = MessageBox.Button.OK,
                                Icon = MessageBox.Icon.INFO
                            });
  4. #4
    Please clarify why not?
    Im not using ext button and direct events.
  5. #5
    Hi Daniil,
    There is nothing wrong with Ext button control. But my project is already existed and implemented with normal asp.net controls. That is why i did not replaced button controls there for my convenience.

    Quote Originally Posted by Daniil View Post
    Please clarify why not?
  6. #6
    Ok, thanks for the details.

    But please note for the future that Ajax model (DirectEvent is an ajax request) is more light-weight than common ASP.NET PostBack model.
  7. #7
    Thanks again for your info/suggestion.

    Quote Originally Posted by Daniil View Post
    Ok, thanks for the details.

    But please note for the future that Ajax model (DirectEvent is an ajax request) is more light-weight than common ASP.NET PostBack model.

Similar Threads

  1. X.Msg.Alert not triggering more than once
    By ssenthil21 in forum 1.x Help
    Replies: 0
    Last Post: Oct 03, 2011, 5:55 AM
  2. Replies: 4
    Last Post: Apr 21, 2011, 6:04 AM
  3. alert vs Ext.Msg.alert + window.location
    By Nime in forum 1.x Help
    Replies: 0
    Last Post: Nov 10, 2009, 3:34 AM
  4. MessageBox Example Not working
    By Tbaseflug in forum 1.x Help
    Replies: 5
    Last Post: Jun 18, 2009, 3:48 PM
  5. MessageBox - Cannot get working from Example
    By Tbaseflug in forum 1.x Help
    Replies: 4
    Last Post: Jun 17, 2009, 5:24 PM

Tags for this Thread

Posting Permissions