how to fix size of webmessagebox?

Last post 11-06-2008 6:10 PM by Haissam. 1 replies.

Sort Posts:

  • how to fix size of webmessagebox?

    11-05-2008, 6:22 AM
    • Member
      point Member
    • ankitsahu
    • Member since 08-06-2008, 5:43 AM
    • Posts 36

    hi all,

    i m using webmsg box but the content i m putting in msgbox is large.and its extend the size of msgbox.

    WebMsgBox.Show("Thank you for your interest come in mysite! Your message has been recieved and someone will contact you within 2 business days");

    i want to show this msg in 2 lines like--

     Thank you for your interest come in mysite!

     Your message has been recieved and someone will contact you within 2 business days.

    and the size of msgbox will not extend .

    i m using this class-----

    using System;

    using Microsoft.VisualBasic;

    using System.Text;

    using System.Collections;

    using System.Web;

    using System.Web.UI;

    using System.Web.UI.WebControls;

     

    namespace ank.HelperClasses

    {

    public class WebMsgBox

    {

    protected static Hashtable handlerPages = new Hashtable();private WebMsgBox()

    {

    }

    /// <summary>

    /// This method will display the Message box with Message passed as

    /// method parameter

    /// </summary>

    /// <param name="Message"></param>

    public static void Show(string Message)

    {

    if (!(handlerPages.Contains(HttpContext.Current.Handler)))

    {

    Page currentPage = (Page)HttpContext.Current.Handler;if (!((currentPage == null)))

    {

    Queue messageQueue = new Queue();

    messageQueue.Enqueue(Message);

    handlerPages.Add(HttpContext.Current.Handler, messageQueue);

    currentPage.Unload += new EventHandler(CurrentPageUnload);

    }

    }

    else

    {

    Queue queue = ((Queue)(handlerPages[HttpContext.Current.Handler]));

    queue.Enqueue(Message);

    }

    }

     

     

    private static void CurrentPageUnload(object sender, EventArgs e)

    {

    Queue queue = ((Queue)(handlerPages[HttpContext.Current.Handler]));if (queue != null)

    {

    StringBuilder builder = new StringBuilder();

    int iMsgCount = queue.Count;

    builder.Append("<script language='javascript'>");

    string sMsg;while ((iMsgCount > 0))

    {

    iMsgCount = iMsgCount - 1;

    sMsg = System.
    Convert.ToString(queue.Dequeue());

    sMsg = sMsg.Replace("\"", "'");

    builder.Append("alert( \"" + sMsg + "\" );");

    builder.Append("window.close();"); //code for closing the window

    }

    builder.Append(
    "</script>");

    handlerPages.Remove(HttpContext.Current.Handler);

    HttpContext.Current.Response.Write(builder.ToString());

     

    }

    }

    }

     

     

    }

     

    on aspx.cs page i m calling it like this---

    WebMsgBox.Show("Thank you for your interest in my site! Your message has been recieved and someone will contact you within 2 business days");

     

    tell me if any solution.

     

     

  • Re: how to fix size of webmessagebox?

    11-06-2008, 6:10 PM
    Answer
    • All-Star
      37,391 point All-Star
    • Haissam
    • Member since 10-05-2006, 2:25 AM
    • Beirut - Lebanon
    • Posts 5,632

    MessageBox.Show is used in windows application. In ASP.NET, you should use javascript to alert message

    Page.ClientScript.RegisterStartupScript(this.GetType(),"alert","alert('hello world');",true);

     

    Haissam Abdul Malak
    MCAD.NET
    | Blog |
Page 1 of 1 (2 items)