473,847 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Throwing Exception in a composite control

KJ
This is kind of hard to explain but I have a [composite control] The
controls are created with CreateChildCont rols(). Now let say I click a
button and an error occurs in the control. If I throw it up it goes
back to the web form. where do I catch the exception at?
Example
Webform

Composite Control

but_click

Throw e as exception

Then the exception goes back up the chain until it gets to the
webform. Can I catch the exception in any event on the webform?
Because after it get pass the control the chain is broken.

Or do I have to pass it as a parameter like RaiseEvent Click(Me, e,
exception)?

I hope this is clear. If anyone know of a good resource for throwing
exception from composite controls let me know.
Nov 17 '05 #1
5 2013
Does your control know how to handle the exception? Then it should catch the
exception in the catch block of a try-catch statement. The exception should
be caught where it can be handled.

If your control doesn't know what to do with the exception, then leave it
alone. It's up to the person who knows how to handle the exception to have
the exception handler.

BTW, this has nothing at all to do with composite controls. This is a basic
matter of one method calling another,. which calls another - which raises an
exception. Exception processing does nothing special with the control
hierarchy.

--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com
"KJ" <kl******@hotma il.com> wrote in message
news:d8******** *************** ***@posting.goo gle.com...
This is kind of hard to explain but I have a [composite control] The
controls are created with CreateChildCont rols(). Now let say I click a
button and an error occurs in the control. If I throw it up it goes
back to the web form. where do I catch the exception at?
Example
Webform

Composite Control

but_click

Throw e as exception

Then the exception goes back up the chain until it gets to the
webform. Can I catch the exception in any event on the webform?
Because after it get pass the control the chain is broken.

Or do I have to pass it as a parameter like RaiseEvent Click(Me, e,
exception)?

I hope this is clear. If anyone know of a good resource for throwing
exception from composite controls let me know.

Nov 17 '05 #2
Why do you think you want to catch it in the webform? What do you expect to
do about such an exception? Are you concerned about some one particular
exception, or just exceptions in general?

Is your control explicitly throwing a particular exception? If so, then
please stop doing that. Exceptions are for exceptional circumstances.
They're not a general non-local goto.

You say it's not that easy with composite controls. You're dead wrong. Your
situation is in no way specific to controls, much less to composite
controls. This is nothing more than a chain of subroutine calls. I strongly
recommend that you stop asking your questions about controls and instead
just ask them about subroutines calling subroutines which call subroutines.

Has this exception ever occurred? In that case, one really big hint will be
the stack trace. Look at the trace and pretend you've never even _heard_
about controls!

If necessary, post the stack trace and I'll become less general. But I'm
concerned that if I do that, you won't learn the real lesson - that this has
nothing whatsoever to do with controls.

--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com
"Kyle Johnson" <kl******@hotma il.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..


my problem is. Where do I catch the exception in the webform? If the was
a user control made of of html controls it would be simple but it's not
that easy with composite controls. I want to catch it at the webform
level

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #3
Kyle,

First, like I said, you should abstract the problem away from "controls" and
"web forms" to "components " and "component consumers".

However, you were given a good suggestion, one which would work whether this
were a "control" issue or a "component" issue. Your control should define an
Error event with the exception as a parameter. btnSearchClick (NOT "Search")
should catch any exceptions and should raise them as Error events to whoever
cares about Error events. Possibly even your Web Form.

--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com

"Kyle Johnson" <kl******@hotma il.com> wrote in message
news:eW******** ******@TK2MSFTN GP10.phx.gbl...


Thank you for your help. I will post my stack trace. That might explain
my situation better. I'm not at work today so it will be tomorrow. Thank
you again
But just to let you know someone told me to pass the exception back as a
parameter in the event that gets raised to the webform. That does not
sound like the best way to do it.

Another example

Control

AddHandler btnSearch.Click AddressOf btnSearchClick

Sub btnSearchClick( )
onclick()
End Sub
..... Sub OnClick()

Search()

End Sub
Sub Search()
Try
.
.
.
Catch
.
.
.
Throw New Exception(e.Mes sage)

End Sub
When I click thesearch button on the control and If an exception occurs
in Search() and I need to get it to the webform that the control is in,
so a custom error object can handle it. How do I get it there?

Thanks again

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #4
Can you explain what you mean by 'error events'? I'm fairly new to this.
Thanks for your help.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #5
I meant an event called "Error" which is raised to indicate that an error
has occurred. Such an event can be handled by any number of pieces of code
which care whether an error has occurred.
--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com

"Kyle Johnson" <kl******@hotma il.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Can you explain what you mean by 'error events'? I'm fairly new to this.
Thanks for your help.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #6

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

Similar topics

0
1589
by: Satya Bojanapally | last post by:
Hi, I am unable to add a pager for this composite control. I had created a composite control in C#. The control is having 5 labels, one radio button and one DropDownList control. The composite control should display 2 columns and 2 rows per page. I am able to display 4 Composite Controls independently, when the user is changing the index of the DropDownList control, automatcially the output should get reflected on the composite control...
1
2073
by: Paul Kia | last post by:
I have an ATL composite control which I drop into a tab control dialog page of an MFC application. When I click on the composite control and then click anywhere outside the MFC application, the application immediately hangs! Spy++ indicates that the application is hanging on the WM_GETDLGCODE message. This problem does not happen if the ATL control is a standard (that is, non-composite) control, neither does it happen if the composite...
1
3157
by: sleigh | last post by:
Hello, I'm building a web application that will build a dynamic form based upon questions in a database. This form will have several different sections that consist of a panel containing one to many questions. To keep it simple, I'll describe the basics of what I'm trying to design. I've created a TextBox composite control that consists of a label for
10
2337
by: dx | last post by:
I have the Microsoft Press: Developing Microsoft ASP.NET Server Controls and Components book. It's starting to shine some light on control development but there is something about composite controls that I don't understand... I've included a snippet from Chapter 12 below on Composite Controls: <start> Override the CreateChildControls method to instantiate child controls, initialize them, and add them to the control tree. Do not perform...
1
1319
by: Jeff | last post by:
Hi - I am developing a composite control using VB.NET. In the ASP.NET page using the control, How can I update a label text value to reflect the value of a property of the custom control whenever the composite control is changed? The label is not a part of the custom control. I've managed to correctly set the composite control properties whenever it
0
1412
by: multiformity | last post by:
Ok, so I have gone off and documented the lifecycle of a page with a custom composite control on it. You can find that document here: http://www.ats-engineers.com/lifecycle.htm Now, I am working on a much more complex grid example, and according to my findings, the order should be like so: Page Constructor Page OnInit
3
3016
by: Beavis | last post by:
I hate to repost a message, but I am still at the same point where I was when I originally posted, and hopefully someone else will see this one... Ok, so I have gone off and documented the lifecycle of a page with a custom composite control on it. You can find that document here: http://www.ats-engineers.com/lifecycle.htm
3
1953
by: Eric | last post by:
I have created a fairly basic composite control consisting of a Label and a TextBox. In the overridden Render function, I'm creating a table with two rows and each row contains a cell (td). The Label and the TextBox are each rendered in one of the cells. Everything renders fine. The problem is that depending on the column the control represents I may want the textbox to be a different visible size during both design and runtime. I...
6
2638
by: shapper | last post by:
Hello, I am working in a class library with various custom controls. In which cases should a control inherit Control, WebControl and CompositeControl classes? And when should a custom control implement INamingContainer? In this moment I am working on a custom control that is composed by a
0
9735
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10658
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10718
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10347
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9497
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7062
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5730
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4133
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.