Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > Intro Programming
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Intro Programming What is a loop? Which language is best for beginners? What is "object oreinted?" All those types of questions and more are welcome here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Intro Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 21st, 2014, 03:11 AM
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2014
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default Not sure if I am in the right place.

I need some help with my code. I need a messagebox to show and I know the code is right, but it only works for VB not for Visual Web Developer(2010). Could someone please look at my code to see if I have done something wrong. I am using Visual Web Developer 2012, Thanks

             'Calculate and display the total charges.
            decTotal = decSubtotal + decTax     '<---Calculating(adding) the Total Charges
            lblTotal.Text = decTotal.ToString("c")  '<---Displaying decTotal in lblTotal.

            'Change and display the total charges.
            lblTotal.BackColor = Drawing.Color.Blue
            lblTotal.ForeColor = Drawing.Color.White

        Catch ex As Exception
            'Error message
            MessageBox.Show("All input must be vaild numberic values.")
        End Try
Reply With Quote
  #2 (permalink)  
Old April 24th, 2014, 01:03 AM
Friend of Wrox
Points: 528, Level: 8
Points: 528, Level: 8 Points: 528, Level: 8 Points: 528, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts

MessageBox is a windows form control. Visual web developer is for web forms. Rendering happens on the client machine; so the message box does not work. Looking at your snippet you are wanting to report some error to back to the users browser. What i typically do for this is to have a custom validator that sits silently on the page and set it up so it does not have text and its display is none. Along with this validator you add a validation summary to the page. To activate the error reporting in your try catch block set the IsValid property to false and the ErrorMessage property to your exception message on the custom validator.

Sample code to set error message on screen
catch ex as Exception
  custvalException.IsValid = false
  custValException.ErrorMessage = "some message" 'ErrorMessage displays in validation summary
End try

Last edited by mmorgan30; April 24th, 2014 at 01:12 AM..
Reply With Quote
The Following User Says Thank You to mmorgan30 For This Useful Post:
belitaross (April 24th, 2014)

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Not sure if I am in the right place. belitaross Intro Programming 1 April 24th, 2014 01:13 AM
Footer Not In the Right Place NexusFactor BOOK: Beginning ASP.NET 4 : in C# and VB 2 December 29th, 2010 03:11 PM
Where do I place the code? dotnetDeveloper ASP.NET 2.0 Basics 1 August 7th, 2008 01:06 PM
In-place precompilation AGS BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 1 December 3rd, 2005 07:45 PM
Logging in from another place Hadware General .NET 0 December 14th, 2004 03:39 PM

All times are GMT -4. The time now is 04:51 PM.

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