Web Message Box

T

Tim

I'm looking for a web message box control (i.e. an ASP.NET counterpart
to the Winforms Msgbox) and would be grateful for recommendations
whether freeware, shareware, or commercial. I want to mimic the popup
behavior of the Winforms message box --superimpose the message like a
javascript alert() by calling it from any codebehind method-- but be
able to determine which button the user has clicked.

TIA!
Tim
 
J

James Radke

Why not just use the javascript Alert? You cannot call a true message box
type of pop up from code-behind because code-behind runs server-side ; while
the message box pop-up you want cannot run until the code is transferred and
executed at the client.

I have been able to use the javascript Alert to handle all my msgbox type
needs. Are you having some problem figuring out how to use it?

Thanks

Jim
 
T

Tim R.

Hi Jim,
I have been asked to display a superimposed popup-type message
from within a server-side PreSave method (e.g. "This record would
be a duplicate. Do you want to see the original record? [YES]
[NO]").

I understand that the server-side code cannot popup an alert-type
box per se because of the client-server separation, but perhaps
there is some way for the server-side code to redirect to another
webform which gets displayed like a popup in its own window and
sized smaller, like an error dialog?

Can I pass the desired window size as part of the query string? Is
there any way in the example below for ErrorForm.aspx to get the
desired height and width from the query string and DISPLAY ITSELF
initially as a popup of the specified size?

Regards
Tim


Private Sub PreSave()
ErrorForm = "DuplicateMessage.aspx"
DesiredWidth = "400"
DesiredHeight = "100"
QString = "?W=" + DesiredWidth + "&H=" + DesiredHeight
Response.Redirect(ErrorForm + QString)
End Sub
 
J

James Radke

Tim,

If I am reading your message correctly, you would like to check the database
after the user has pressed a button, and if the record attempted to be added
is a duplicate, display a pop-up message. Is that correct?

If it is, one way to handle it is to have the button onclick event wired to
a javascript function. You do this by:

btnname.Attributes.Add("onclick", "javascript: return
CheckAdd(<parameters>);")

What this does is perform the javascript function, and if you return true
from the javascript function, a postback, if you have an OnClick defined for
the button, will occur. If you return false, the postback will not be
called.

Then, in the javascript function, call a web service from the javascript
(Here is the article that got me started using this technique
http://www.fawcette.com/vsm/2002_06/online/delcogliano/default_pf.aspx)

You can then interpret the results of the webservice call from the
javascript, and display an alert if desired.

I actually use the webservice technique quite a bit to reduce screen flicker
(since the whole page does not refresh), and speed up page processing since
only a small portion of a large page is sent to the server. This also makes
the application appear and perform more professionally.

Does this make sense?

Jim

Tim R. said:
Hi Jim,
I have been asked to display a superimposed popup-type message
from within a server-side PreSave method (e.g. "This record would
be a duplicate. Do you want to see the original record? [YES]
[NO]").

I understand that the server-side code cannot popup an alert-type
box per se because of the client-server separation, but perhaps
there is some way for the server-side code to redirect to another
webform which gets displayed like a popup in its own window and
sized smaller, like an error dialog?

Can I pass the desired window size as part of the query string? Is
there any way in the example below for ErrorForm.aspx to get the
desired height and width from the query string and DISPLAY ITSELF
initially as a popup of the specified size?

Regards
Tim


Private Sub PreSave()
ErrorForm = "DuplicateMessage.aspx"
DesiredWidth = "400"
DesiredHeight = "100"
QString = "?W=" + DesiredWidth + "&H=" + DesiredHeight
Response.Redirect(ErrorForm + QString)
End Sub






Why not just use the javascript Alert? You cannot call a true message box
type of pop up from code-behind because code-behind runs server-side ; while
the message box pop-up you want cannot run until the code is transferred and
executed at the client.

I have been able to use the javascript Alert to handle all my msgbox type
needs. Are you having some problem figuring out how to use it?

Thanks

Jim
 
T

Tim R.

Jim,
Invoking a webservice from client-side javascript is not something
I've done before--but the approach looks very promising. Thank you
for the link.
Tim
 
J

James Radke

Tim,

It is pretty easy to add, and it does add a lot to the application. I bet
once you try it, you will want to use this technique more often.

Good luck!

Jim
 
K

Ken Cox [Microsoft MVP]

On second thought, it might not be wise to count on pop-up windows in the
future - once IE has the ability to block them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top