Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 3rd, 2013, 01:01 PM
Authorized User
 
Join Date: Oct 2012
Posts: 19
Thanks: 6
Thanked 0 Times in 0 Posts
Default Client Alert from Database

I have the following situation to address:
A user wants to access a data base record using its unique purchase order ID. If the user mistypes the ID and is now looking for a non-existant record the data base has to return an alert message ("POID not found") to the client.
My first attempt was to use msgbox() but I learned quickly that this is not a good way to go (the client receives a "yellow error screen"). After perusing the internet, I found three different ways of sending a Java script from the server to the client to display the alert message. Basically they use the commands: Response.Write(msg), Page.Controls.Add(lbl), or P.ClientScript.RegisterStartupScript(p.GetType,"", str).

I implemented the Response.Write approach (the simplist code) and found it works OK except that when the alert is displayed on the client's screen the main screen is blanked out. Upon the dismissal of the alert, the main screen is restored but it is somewhat distorted because some of the fonts have become larger.

My question is this: is there a good way to accomplish what I want? Should I use one of the other two methods or is there yet a better way? Any comments along this line would be appreciated.
 
Old March 3rd, 2013, 06:07 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

MsgBox is for win forms, not web apps. In web sites you can use JavaScript's alert which you can trigger using the methods you mention. You can also use plain HTML and, for example, jQuery to show a message as explained in my book. You can also look into UI frameworks such as jQuery UI.

I would stay away from Response.Write as it runs / writes in a location you may not expect. It's "classic asp style" to me, and asp.net has much better alternatives.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
nick1248 (March 13th, 2013)





Similar Threads
Thread Thread Starter Forum Replies Last Post
create setup and install application with mssql database on client system sophia .NET 4 and Visual Studio 2010 General Discussions 0 July 7th, 2012 01:21 PM
create setup and install application with mssql database on client system sophia WinForms/Console Application Design 0 July 7th, 2012 01:12 PM
Exporting database to client hans BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 10 April 10th, 2009 05:39 PM
Thick Client Database connection callmrshiva ADO.NET 0 August 28th, 2006 08:36 AM
uploading database from server to client queen22 Classic ASP Databases 0 May 1st, 2005 08:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.