473,320 Members | 1,950 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,320 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 1736
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.