473,405 Members | 2,160 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,405 software developers and data experts.

Sending exceptions to a TextBox


I am using page level exceptions on some of my WebForms.
In most cases I am handling the errors simply like this:

Private Sub Page_Error(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Error
Response.Write(Server.GetLastError().Message)
Server.ClearError()
End Sub
Instead of doing that I would like to send the error info
to a textbox that is on the current form. Somthing like
this:

Private Sub Page_Error(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Error
txtErrMsg.text = Server.GetLastError().Message
Server.ClearError()
End Sub
This doesn't work, the page displayed isalways just a
blank white page. Is there a way to do this?

Jerry J
Nov 18 '05 #1
1 1026
I think you must use try...catch.
you can show exceptions on textbox of current page use
catch.like this:
public void YourFunctionOrEvent(YourParametersList){
try{
// your code..
}
catch(Excepion ex){
this.YourEcvepionText.Text = ex.Message;
}
}

Response.Write(Server.GetLastError().Message) is a new
instance of page so there isn't a textbox.

you can add a textbox in your every page,and then you let
your page accept a parmeter names err,and then you can
send a parameter to current page.for example:

// this page name is a.aspx,there is a textbox in it
named txtErrMsg.
protected void Page_Error(parametersList){
Response.Redirt
(this.page...+"@err="+Server.GetLastError().Messag e);
}

public void Page_Load(PrametersList){
// your code..
if(this.Param["err"] != null){
txtErrMsg.text = Server.GetLastError().Message
Server.ClearError()
}
}
-----Original Message-----

I am using page level exceptions on some of my WebForms.
In most cases I am handling the errors simply like this:

Private Sub Page_Error(ByVal sender As Object, ByVal e AsSystem.EventArgs) Handles MyBase.Error
Response.Write(Server.GetLastError().Message)
Server.ClearError()
End Sub
Instead of doing that I would like to send the error infoto a textbox that is on the current form. Somthing like
this:

Private Sub Page_Error(ByVal sender As Object, ByVal e AsSystem.EventArgs) Handles MyBase.Error
txtErrMsg.text = Server.GetLastError().Message
Server.ClearError()
End Sub
This doesn't work, the page displayed isalways just a
blank white page. Is there a way to do this?

Jerry J
.

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Marcelo | last post by:
Hi guys, I'm using the following code to send values from one page to another, but seems to me, that the event Page_Load in the receiving page never fires. Why? This is the code: Thanks ...
4
by: tfsmag | last post by:
It acts like it sends, but nothing ever shows up... anything you guys can find glaringly wrong here? Thanks in advance, Jeff Here is the code that is supposed to send the mail. ...
3
by: Ant | last post by:
Hi, I'm using the MailMessage & smtpMail classes in System.Web.Mail to send mail, however it's not sending any emails. I'm using it on a Windows 2003 server. The simplest way to use this is...
6
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
6
by: GiddyUpHorsey | last post by:
We have a website built on ASP.NET 2.0. We log exceptions in the Error event of Global.ASAX. We keep a getting number of random exceptions that make no sense and that we can't reproduce but happen...
2
by: nautonnier | last post by:
Hello, I have a C# app that spawns several processes each containing a console app written by another developer in C++. The console app was written first to be just like a console app: it...
14
by: John | last post by:
Hi How does one send email from within a vb.net app? Thanks Regards
11
by: =?Utf-8?B?QW5u?= | last post by:
Hello, I want to send an email when the Insert button is clicked that includes data entered on the form. I am using asp.net 2.0 and an insert template. I receive the email OK, but there is no...
3
by: ganesh22 | last post by:
Hi, in my application iam sending a mail to user bt its all running well then my problem is its not sending in HTML format i want to send a mail which format is in textbox as it is that format...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.