473,594 Members | 2,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Create a Message box in ASP.Net

85 New Member
people face lot of problems in creating message boxes like in desktop applications in asp.net, there are lot of ways of calling javascript alerts, but here i would explain how to generate a message box in asp.net..
for that , create a class and name it Messages.cs in App_Code. the class will have a single method to generate the message box like as follows
Expand|Select|Wrap|Line Numbers
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.UI;
  7.  
  8. /// <summary>
  9. /// Summary description for Messages
  10. /// </summary>
  11. public class Messages
  12. {
  13.     public Messages()
  14.     {
  15.         //
  16.         // TODO: Add constructor logic here
  17.         //
  18.     }
  19.  
  20.  
  21.     public void CreateMessageAlert(string strMessage)
  22.     {
  23.         Guid guidKey = Guid.NewGuid();
  24.         Page pg = (Page)HttpContext.Current.Handler;
  25.         string strScript = "alert('" + strMessage + "');";
  26.         pg.ClientScript.RegisterStartupScript(pg.GetType(), guidKey.ToString(), strScript, true);
  27.     }
  28. }
  29.  
  30.  
now in your page where ever you want to display an OK message box , you can call like this
Expand|Select|Wrap|Line Numbers
  1. Messages myMsg=new Messages(); // create the object 
  2. myMsg.CreateMessageAlert("Your Message Here");
  3.  
  4.  
...
Addan
Aug 3 '12 #1
1 23764
hrothenb
2 New Member
'ASP.net MessageBox
'Add a scriptmanager to the ASP.Net Page

<asp:scriptmana ger id="ScriptManag er1" runat="server" />


try:

Dim sMsg As String = "My Message"

ScriptManager.R egisterStartupS cript(Page, Page.GetType, Guid.NewGuid(). ToString(), "alert('" & sMsg & "')", True)
Nov 6 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
8842
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
4
2760
by: Tingo | last post by:
Hi all, Is it possible to create a message queue with a specific ID? I want to do this because I'm trying to write a piece of software which restores communicating processes (which communicate through message queues) when there is a machine failure. When restarting the machine I need to setup the message queues as they were originally. I find that given the same key, when creating a queue, the queue ID is not always the same value. Is...
6
11473
by: deepak | last post by:
I have to create message queue at remote machin. My code works properly when i use console application in c#. But it throws exception whenever i try it on web application in c#. My code is MessageQueue.Create("FormatName:DIRECT=OS:MachineName\\QueueName"); or MessageQueue.Create("MachineName\\QueueName");
4
4403
by: I_AM_DON_AND_YOU? | last post by:
There is one more problem I am facing but didn't get the solution. In my Setup Program I am not been able to create 2 things (when the program is intalled on the client machine ) : (1) create shortcut to my program/utility (2) Entry in Windows' Start --> Program Menu. Actually in my VB.Net solution I have two projects (1) MYPROGRAM (2) MYPROGRAM_INSTALLER. MYPROGRAM is a "Windows Application". MYPROGRAM_INSTALLER is a "SetUp Wizard"...
10
8788
by: Zack Sessions | last post by:
Has anyone tried to create a SQL7 view using the CREATE VIEW command and ADO.NET? If so, is there a trick in trapping a SQL error when trying to create the view? I have a VB.NET app that, amoung other things, can create views based on existing tables and a table of column name equivalents. If I accidently introduce a column name equivalent that is the same as another column, I end up with a CREATE VIEW SQL statement that is in error, if...
5
3147
by: Ikkezelf | last post by:
Hi, I was wondering if it's possible to write a message in the windows message queue by means of c. Already searched a lot through this newsgroup and others. I noticed that it is possible with the use of c++, but i use "normal" c script. I just want something that looks simple, but as I can't find it, it seems not that simple at all.
27
3771
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB updates the same data in all other four tables in the right places. I know it would be possible by using the ForeignKeyConstraint object. I have created the tables using the DataSet Visual Tool and I know it doesn't create any ForeignKeyConstraint obj....
3
2279
by: kvadro | last post by:
Hi. I am new in this website. How to create message box, with buttons, and icons? And of course, with text?
0
1233
by: aadsaca | last post by:
hi there, I just want to know if it is possible to create Message Queue on other Computer? if yes, how to do it? tnx,
5
13124
by: Laetitia | last post by:
Hi All Please can anyone advise whether it is possible to display messages in the status bar. I have a number of update queries which will be run and need to find a way to identify which field is currently being updated so that I can monitor the progress. I know that I can use InputBox to display the variable table and field
0
7947
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7880
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8255
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8242
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6665
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5739
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3903
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1486
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.