473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

message box

Hi i want to show or fire a message box from
code behind my.cs file of asp.net web application
how can i do that i am using framework 1.1
Apr 11 '06 #1
9 1739
public static void MsgBox(string strMessage, string UniqueScriptName)
{
StringBuilder s;
System.Web.UI.Page p;
try
{
if (HttpContext.Current == null) return;
s = new StringBuilder("<script type=\"text/javascript\">" + nl +
"<!--" + nl);
s.Append("alert('" + strMessage.Replace("\"", "\\\"") + "');" + nl +
"// --></script>");
p = (System.Web.UI.Page) HttpContext.Current.Handler;
if (!(p.ClientScript.IsStartupScriptRegistered("MsgBo x")))
p.ClientScript.RegisterStartupScript(p.GetType(), UniqueScriptName,
s.ToString(), true);
}
catch (Exception ex)
{
HandleError(ex);
}
}

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Ankit Aneja" <ef*****@newsgroups.nospam> wrote in message
news:Ou**************@TK2MSFTNGP04.phx.gbl...
Hi i want to show or fire a message box from
code behind my.cs file of asp.net web application
how can i do that i am using framework 1.1

Apr 11 '06 #2
what is this "nl "
it doesn't exist in class or namespace
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eg**************@TK2MSFTNGP04.phx.gbl...
public static void MsgBox(string strMessage, string UniqueScriptName)
{
StringBuilder s;
System.Web.UI.Page p;
try
{
if (HttpContext.Current == null) return;
s = new StringBuilder("<script type=\"text/javascript\">" + nl +
"<!--" + nl);
s.Append("alert('" + strMessage.Replace("\"", "\\\"") + "');" + nl +
"// --></script>");
p = (System.Web.UI.Page) HttpContext.Current.Handler;
if (!(p.ClientScript.IsStartupScriptRegistered("MsgBo x")))
p.ClientScript.RegisterStartupScript(p.GetType(), UniqueScriptName,
s.ToString(), true);
}
catch (Exception ex)
{
HandleError(ex);
}
}

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Ankit Aneja" <ef*****@newsgroups.nospam> wrote in message
news:Ou**************@TK2MSFTNGP04.phx.gbl...
Hi i want to show or fire a message box from
code behind my.cs file of asp.net web application
how can i do that i am using framework 1.1


Apr 11 '06 #3
Do a script callback and point to a javascript function that does:

<script type=text/javascript language=javascript>
function MessageBx()
{

Alert("Message to display);
}
</script>

You cannot use a messag box normally because asp is server side....it
will try to display the box on the server. Javascript is the easiest
way to accomplish this. It is client side and will display the box
with the "Alert()" method.

Apr 11 '06 #4
Response.Write("<script language=jscript>alert('" + "hello" +
"')</script>");

solved

"Ankit Aneja" <ef*****@newsgroups.nospam> wrote in message
news:Ou**************@TK2MSFTNGP04.phx.gbl...
Hi i want to show or fire a message box from
code behind my.cs file of asp.net web application
how can i do that i am using framework 1.1

Apr 11 '06 #5
Take a look at this:
http://www.metabuilders.com/tools/DialogWindow.aspx

"Ankit Aneja" <ef*****@newsgroups.nospam> wrote in message
news:Ou**************@TK2MSFTNGP04.phx.gbl...
Hi i want to show or fire a message box from
code behind my.cs file of asp.net web application
how can i do that i am using framework 1.1

Apr 11 '06 #6
alert() not Alert()

"Phuff" <pc*****@gmail.com> schreef in bericht
news:11*********************@j33g2000cwa.googlegro ups.com...
Do a script callback and point to a javascript function that does:

<script type=text/javascript language=javascript>
function MessageBx()
{

Alert("Message to display);
}
</script>

You cannot use a messag box normally because asp is server side....it
will try to display the box on the server. Javascript is the easiest
way to accomplish this. It is client side and will display the box
with the "Alert()" method.

Apr 11 '06 #7
Ah sorry. I created a static variable with a short name to substitute for
having to write Environment.NewLine with each new line:

private static string nl = Environment.NewLine;

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Ankit Aneja" <ef*****@newsgroups.nospam> wrote in message
news:el****************@TK2MSFTNGP02.phx.gbl...
what is this "nl "
it doesn't exist in class or namespace
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:eg**************@TK2MSFTNGP04.phx.gbl...
public static void MsgBox(string strMessage, string UniqueScriptName)
{
StringBuilder s;
System.Web.UI.Page p;
try
{
if (HttpContext.Current == null) return;
s = new StringBuilder("<script type=\"text/javascript\">" + nl +
"<!--" + nl);
s.Append("alert('" + strMessage.Replace("\"", "\\\"") + "');" + nl +
"// --></script>");
p = (System.Web.UI.Page) HttpContext.Current.Handler;
if (!(p.ClientScript.IsStartupScriptRegistered("MsgBo x")))
p.ClientScript.RegisterStartupScript(p.GetType(), UniqueScriptName,
s.ToString(), true);
}
catch (Exception ex)
{
HandleError(ex);
}
}

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Ankit Aneja" <ef*****@newsgroups.nospam> wrote in message
news:Ou**************@TK2MSFTNGP04.phx.gbl...
Hi i want to show or fire a message box from
code behind my.cs file of asp.net web application
how can i do that i am using framework 1.1



Apr 11 '06 #8
You could use this free control to do it, or examine its free source code to
see how to do it yourself:
http://SteveOrr.net/articles/ClientSideSuite.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Ankit Aneja" <ef*****@newsgroups.nospam> wrote in message
news:Ou**************@TK2MSFTNGP04.phx.gbl...
Hi i want to show or fire a message box from
code behind my.cs file of asp.net web application
how can i do that i am using framework 1.1

Apr 11 '06 #9
Hi Ankit,

Glad that you're got it working.

BTW, for registering client-side script, we're recommended to use the
Page.ClientScript.XXXX methods instead of Response.Write to do the work.
The page's encapsulated methods can help ensure the startup script or
script block be registered and output at the appropriate place.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Apr 12 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Brian Keating EI9FXB | last post by:
Would I be correct in saying that the only way to get a user message into a Windows form would be to use P/Invoke with Message? Of is there some part of the .NET API that I am totally un aware...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
2
by: Microsoft News | last post by:
What I have is a message box that pops up. It is another browser window. The code is a general function that you pass message, title and a key to. The box works great except, that if you are on a...
0
by: ronscottlangham | last post by:
I am working on a custom WCF EndpoingBehavior that will modify the messages coming in and out of my Service. I am having an error related to the modification of the message in the...
2
by: =?Utf-8?B?QWRl?= | last post by:
HI All, I am encountering the following error when I try to send an email through a SMTP server. I believe the problem lies with the authentication part when the network crednetials are used,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.