Click here to Skip to main content
15,896,522 members
Articles / Web Development / ASP.NET

AJAX Enabled MessageBox

Rate me:
Please Sign up or sign in to vote.
4.73/5 (56 votes)
14 Sep 2009CPOL2 min read 202.3K   7.8K   108  
MessageBox usercontrol that is AJAX ready and has confirmation support
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace YaBu_MessageBox
{
    public partial class _Default : System.Web.UI.Page
    {
       
        protected void btnInfo_Click(object sender, EventArgs e)
        {
            uscMsgBox1.AddMessage("The user saved successfully but should be activated by an administrator within 3 days.", YaBu.MessageBox.uscMsgBox.enmMessageType.Info);
        }

        protected void btnError_Click(object sender, EventArgs e)
        {
            uscMsgBox1.AddMessage("Unknown error occured. Please try again later.", YaBu.MessageBox.uscMsgBox.enmMessageType.Error);
        }

        protected void btnAttention_Click(object sender, EventArgs e)
        {
            uscMsgBox1.AddMessage("You must enter the user name.", YaBu.MessageBox.uscMsgBox.enmMessageType.Attention);
        }

        protected void btnSuccess_Click(object sender, EventArgs e)
        {
            uscMsgBox1.AddMessage("The user saved successfully.", YaBu.MessageBox.uscMsgBox.enmMessageType.Success);
        }

        protected void btnMultiple_Click(object sender, EventArgs e)
        {
            uscMsgBox1.AddMessage("The user saved successfully.", YaBu.MessageBox.uscMsgBox.enmMessageType.Success);
            uscMsgBox1.AddMessage("The newly saved user account should be activated by an administrator within 3 days", YaBu.MessageBox.uscMsgBox.enmMessageType.Attention);

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            uscMsgBox1.MsgBoxAnswered += MessageAnswered;
        }

        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            uscMsgBox1.AddMessage("Do you confirm to save a new user?.", YaBu.MessageBox.uscMsgBox.enmMessageType.Attention, true, true, txtArg.Text);
        }

        public void MessageAnswered(object sender, YaBu.MessageBox.uscMsgBox.MsgBoxEventArgs e)
        {
            if (e.Answer == YaBu.MessageBox.uscMsgBox.enmAnswer.OK)
            {
                uscMsgBox1.AddMessage("You have just confirmed the transaction. The user saved successfully. You have entered " + txtArg.Text + " as argument.", YaBu.MessageBox.uscMsgBox.enmMessageType.Info);
            }
            else
            {
                uscMsgBox1.AddMessage("You have just cancelled the transaction.", YaBu.MessageBox.uscMsgBox.enmMessageType.Info);
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) NetCad
Turkey Turkey
Yavuz is a software developer since 2001. He has been working as senior software developer in Netigma Project at NetCad since 2012.



He has experience in mostly Microsoft technologies such as ASP.Net, SQL Server, C#, VB.Net, WPF, WCF etc. and especially interested in security and performance issues.

Comments and Discussions