473,383 Members | 1,958 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,383 software developers and data experts.

Message Box in ASP

Hello,
I'm trying to figure out how to set up and call a javascript pop up window
within C# ASP. I know how to use RegisterStartupScript. This works fine if I
use it in the Page_Load area. What I want to do is call a pop-up window from
several areas in my class.
For example, I've got a Submit button but based on several conditions I
might want to pop up a message with the message varying. If I put the
RegisterStartupScript in this Submit_Click function, it doesn't pop up
anything.
I'm thinking I need to register a javascript popup function and then call
the function where I need to, but I don't know how to do this.
Can someone point me in the right direction?

Thanks
Nov 19 '05 #1
4 940
Here are some free MessageBox controls you can use to simplify things. The
source code is included in case you need to make any modifications:
http://SteveOrr.net/articles/ClientSideSuite.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Randy" <te**@temp.com> wrote in message
news:O7**************@tk2msftngp13.phx.gbl...
Hello,
I'm trying to figure out how to set up and call a javascript pop up window
within C# ASP. I know how to use RegisterStartupScript. This works fine if
I use it in the Page_Load area. What I want to do is call a pop-up window
from several areas in my class.
For example, I've got a Submit button but based on several conditions I
might want to pop up a message with the message varying. If I put the
RegisterStartupScript in this Submit_Click function, it doesn't pop up
anything.
I'm thinking I need to register a javascript popup function and then call
the function where I need to, but I don't know how to do this.
Can someone point me in the right direction?

Thanks

Nov 19 '05 #2
It is similar to RegisterStartupScript...

Page.RegisterClientScriptBlock("alertblock", "<script
language='javascript'>function doalert() {alert('Hi there!'); return
true;}</script>")

And to call it from one of your buttons, add this:

Button1.Attributes.Add("onclick", "javascript:return doalert();")

Note that the return value will determine whether or not your page
posts back. So if you put return false in the function, you won't get
a postback, but return true will let the button continue on with
whatever server-side functionality it has.

Nov 19 '05 #3
That's just what I needed...Thanks so much!

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:uN**************@TK2MSFTNGP15.phx.gbl...
Here are some free MessageBox controls you can use to simplify things.
The
source code is included in case you need to make any modifications:
http://SteveOrr.net/articles/ClientSideSuite.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Randy" <te**@temp.com> wrote in message
news:O7**************@tk2msftngp13.phx.gbl...
Hello,
I'm trying to figure out how to set up and call a javascript pop up
window within C# ASP. I know how to use RegisterStartupScript. This works
fine if I use it in the Page_Load area. What I want to do is call a
pop-up window from several areas in my class.
For example, I've got a Submit button but based on several conditions I
might want to pop up a message with the message varying. If I put the
RegisterStartupScript in this Submit_Click function, it doesn't pop up
anything.
I'm thinking I need to register a javascript popup function and then call
the function where I need to, but I don't know how to do this.
Can someone point me in the right direction?

Thanks


Nov 19 '05 #4
What if you want to call it from within a button click function, and put
different messages in it based on certain processing?
How would you call it like this?

"Phillip Ian" <ph****@comcast.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
It is similar to RegisterStartupScript...

Page.RegisterClientScriptBlock("alertblock", "<script
language='javascript'>function doalert() {alert('Hi there!'); return
true;}</script>")

And to call it from one of your buttons, add this:

Button1.Attributes.Add("onclick", "javascript:return doalert();")

Note that the return value will determine whether or not your page
posts back. So if you put return false in the function, you won't get
a postback, but return true will let the button continue on with
whatever server-side functionality it has.

Nov 19 '05 #5

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,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
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: 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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.