Results 1 to 11 of 11

Thread: Pass Exception Message to label on another page

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2011
    Posts
    22

    Post Pass Exception Message to label on another page

    I’m wondering once I catch an exception, how can I use the exception message in another page?
    How can I pass this exception message into a label on another page? In order so I can have the exception message displayed with my own material. What is the best way to go about this?

    Example:

    Try

    'logic in here

    Catch ex As Exception

    ex.Message 'pass this message of the exception so it can be used in a different page

    End Try

  2. #2
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: Pass Exception Message to label on another page

    Create a global variable (ie. errMsg as string).

    Then:

    Code:
    Try
    
    Catch
       errMsg=ex.Description
    End Try

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Pass Exception Message to label on another page

    "page" ??? Page or form? ASP.NET or WinForm?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 2011
    Posts
    22

    Re: Pass Exception Message to label on another page

    its an asp.vb page

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Pass Exception Message to label on another page

    That's what I thought... thread needs to be moved to the ASP.NET forum where you'll get a better response. I'll ask the mods to move it.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2011
    Posts
    22

    Re: Pass Exception Message to label on another page

    The try catch is inside a public function so will this method work?

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Pass Exception Message to label on another page

    Moved to the ASP.Net forum.

  8. #8
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: Pass Exception Message to label on another page

    Help keep this forum clean: Remember to mark your thread as resolved · Search before you post · Remember to rate posts that help

    VS2010: Visual Studio 2010 Keybinding Posters
    · Service Pack 1
    Tools: GhostDoc - automatically generates XML documentation comments
    · NuGet package Manager · PowerCommands IDE extensions
    Source Control: ankhsvn - integration for SVN
    · Windows Shell Extension for Subversion

    Development Laptop: Intel Core i5 430M 2.26 GHz @ 2.53 GHz
    · 4096 MB, DDR3 PC3-8500F (533 MHz), Kingston · ATI Mobility Radeon HD 5470 · 15.6 @ 16:9, 1366x768 pixel, HD LED LCD

    I follow:
    JoelOnSoftware - A weblog by Joel Spolsky, a programmer working in New York City, about software and software companies
    ScottGu's Blog - Scott Guthrie works for Microsoft as the Product Manager of the .NET Framework
    Portugal-a-Programar - Portuguese Developers Community
    .NET Rocks! - is a weekly Internet audio talk show for .NET Developers.

    Programming Languages:
    C#
    · VB.NET · JAVA · PHP · Javascript
    Other:
    XML
    · HTML · CSS · JQuery · SQL



    *** Proudly Portuguese ***

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Pass Exception Message to label on another page

    Hey,

    Depending on exactly what you are trying to do, and for what reason, you might want to look into something like ELMAH:

    https://code.google.com/p/elmah/

    Which does the job of collating all your error messages, and logging them for you.

    Gary

  10. #10
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Pass Exception Message to label on another page

    Every unhandled exception will pass and logged through global.asax so you don't really need an extra plug in but if you want more automated control then i guess you can try it (haven't used it).
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  11. #11
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Pass Exception Message to label on another page

    For what it's worth, ELMAH is very good at what it does

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width