Exception Handling From Private Class In User Control?

Apr 2, 2010

I am part of a team that is developing a SharePoint web part. My task is to create a user control which will ultimately be wrapped in another class for presentation in a web part. Because of these requirements, I must fit all of my code in a single user control.To organize my code in the code-behind, I created a few private classes for the different objects which are represented in the database. I want to add some exception handling whereby if some sort of DB exception is thrown I can update a message on the page informing the user of the problem.

My problem is that the page-level controls are inaccessible from the private class where I'm issuing the query, so even if I catch the exception I have no way of directly accessing a Label control to populate the error. I tried to create a baseclass with an EventHandler defined, but when I throw events from the private class I'm not able to catch them for whatever reason. I'm far from an OOP expert Here is a snippet:
ASP Code:
using System;
using System.Collections;
[code]....

View 3 Replies


Similar Messages:

C# - How To Access A Private Data Members Of Base Class In The Derived Class

Aug 20, 2010

Since we can access the private data member of base class in the derived class with the help of friend function. How can we do the same in C# asp.net? I mean whats the alternative of friend function in C# asp.net

View 2 Replies

C# - Exception Handling - Implement Custom Exception Classes?

Jul 2, 2010

i have this application structure:

1. Presentation Layer which calls

2. Business Logic Layer which in turn calls

3. Data Access Layer to do the dealing with the database.

Now i have a Contacts page from where i can add a new contact to the database.So to add a New Contact i fill in all the required details and then call a Add Method (residing in the BLL) from the page, which in turn call a Add Method residing in the DAL.this method in the DAL returns the Current Identity of the record which is then return back to the BLL method and finally delivered on the page.this is fine. but what if a get an exception how do i handle it properly because the method in DAL has a return type of int and i dont want to throw another error!! coz other wise i will have to write try catch in almost all the methods.

//something like this
public int AddMethod(ContactClass contactObj)
{
int result = 0;[code]...

rather i want to show the user a user-friendly message which they can easily understand and in the mean while i will send a mail to myself documenting the Error that just occurred.how can i implement my custom exception classes.

View 2 Replies

User Control Event Handling

Jun 5, 2010

i have some problem with my userControl. Pls look below for better understanding. Pic1. The default page. When i click on the links on the left, userControl will load into the placeHolder as in pic2. But when i click on the Clear button that is inside the userControl, instead of clearing the text in the textbox, it load back to the default page show in pic1. Can anyone pls advise me what went wrong?

View 9 Replies

C# - Handling RequiredFieldValidator Inside Of A User Control?

Jan 28, 2011

I have a User Control which consists of a TextBox with a few extras, but for purposes of this example just assuming it's a plain TextBox will be sufficient. I am calling this User Control from a Web Form and would like to be able to use a RequiredFieldValidator that basically would function the same as if I used it on a TextBox on the web form. How do I configure my User Control to handle this?

EDIT:

DatePicker.ascx
<asp:TextBox runat="server" ID="myControlTB">
DatePicker.ascx.cs
[ValidationProperty("Text")]
public partial class DatePicker : System.Web.UI.UserControl

[code]...

View 2 Replies

Handling Dynamic User Control With JQuery

Mar 15, 2011

I have a user control which I am dynamically loading in my page_load event via a method (see below). The user control contains a gridview and a label. A key piece of information has to do with how to get around the convenient feature of gridviews not rendering when their datasource is empty. In my user control I add some hidden rows so that the grids will render and the user can see just the headers (if the situation calls for it).

The nomControl is an asp:Panel on the parent page which will hold the user controls. The dsRefinedProductsNomInfo is a strongly typed dataset.

[code]....

how I should be handling my events so that my rendered grid is up to date and not showing these hidden rows. I have a feeling I am just doing things in the wrong place/order but this is my first real swim in the deep end of the asp.net pool.

View 1 Replies

Web Forms :: Why Class Of User Control Is Unavailable In Another Class File

Nov 18, 2010

I have build a UserControl with separate code behind file.In that code behind file i have defined some public properties in the Partial class of user control that was automatically generated.Those properties will initialize some properties of controls that are used in the control.Now, in .aspx page i used this User Control and initialized the public properties through code behind of aspx page for dynamic contents.

View 6 Replies

Event Handling For A Dynamically Added User Control?

Apr 26, 2010

I have a user control say SearchVendor.ascx which contains 4 buttons a gridview and another user control. I need to load the control dynamically actually as a modal pop up

I get this code

var uc = Page.LoadControl("~/blah/VendorProductSearch.ascx") as VPSearch;
uc.ShowVPSearch(true);
_tempPlaceHolder.Controls.Add(uc);

it works fine the control gets loaded properly but onclick of any button the second time the control disappears ?

I want the dynamically added control to remain until the user clicks on the cancel button

View 2 Replies

Web Forms :: Handling Page Unloading From User Control?

Apr 20, 2010

I want to save widths of all my gridview columns in cookies on unloading the page.

how to handle page unload event from a user control, as my gridview is in a user control?

View 7 Replies

Tightly Integrated Private Helper Class

Jun 30, 2010

I'm working on a page with two sets of collapsable panels. using nHibernate) I get category objects with a list of items in them, and for each category generate a left panel and right panel. In both panels, there is a ListBox. Items are pre-populated to the left list box and the user can select and move items into the right list box (under the corresponding category.) As I've built and worked on it, I ended up with a lot of generic methods like buildPanel(side,categoryID) and then ended up with a lot of repeated if statements inside them to differentiate between the two sides

if type=PanelType.Left then
set these 5 id strings to access components
else
...

The code got messy, so I moved a lot of the logic and static builder strings for the component ids into a private helper class in order to make other parts of the main class easier to read and follow. The problem I see is that the private class is extremely dependant on specific structures in the parent class. There's a very minimal amount of encapsulation going on and I'm possibly making the logic harder to follow even if the individual components in the code are easier to read.

My question is: When you're using a private class like this, is it acceptable to have it tightly integrated with the parent class (since it's private and implemented in the same file), am I better to refactor again and find a way of either simplifying my original code to be as short as possible without the helper class (stick all category/panel functions in one spot and hide them in their own region when I'm not using them), or should I move towards putting more of the logic in the helper class and simply mapping my events directly to the subclass. After typing all this out, I'm leaning towards the last option, but I'm still torn/confused about the whole thing...

View 2 Replies

Reflection Retrieve Private Methods Of A Class?

Sep 13, 2010

I want to retrieve private (implementation and other) methods of a class which implements an interface and also is derived from (inherits) a base class.

How can I achieve this using reflection? Is there anyother way to achieve this?

This is wat m tryin to do. I need to view these private methods and their contents, I don't want to invoke them.

Dim assembly As System.Reflection.Assembly
Dim assemblyName As String assemblyName = System.IO.Path.GetFullPath("xyz.dll")
assembly = System.Reflection.Assembly.LoadFile(assemblyName)
assembly.GetType("myClass").Getmethods(Bindings.NonPublic)
assembly.GetType("myClass").GetMethods(BindingFlags.NonPublic) isn't working

View 2 Replies

Names Of The Private Properties Of A Public Class?

Mar 12, 2010

Names of the private properties of a public class?

I have the following class

[Code]....

View 3 Replies

C# - How Do I Get Specific Details About An Exception From A General Exception Class Object

Feb 4, 2010

In ASP.NET,How can i know the Specific details about an exception (like What kind of Exception it is (FileNotFound /Arithmentc etc..) )from a General Exception class object.

View 2 Replies

Web Forms :: Changing Custom User Control And Event Handling

Jul 29, 2010

I have a custom ascx user control on my page that includes a dropdownlist. There is an onSelectedIndexChanged event handler that is connected to this dropdownlist. The first time the user selects a value, the page does a postback and the logic executes correctly. However, if the user then goes to change their selection, the event handler does not get triggered.

View 3 Replies

C# - Handling MasterPage Event In User Control Of Content Page?

Aug 23, 2010

On my master page , I have "Search textbox" and "Search Button".On My content page , I have a "User Control" which has a "GridView".It shows some data about Vendors.Also, on this User Control's Page Load, i have code written to display all vendors in GridView.Now, when user enters Vendor Number in "Search textbox" , and hits "Search Button" , i want to handle this event inside my User Control.How to do this ?

View 2 Replies

ADO.NET :: DLL Exception Handling?

Mar 25, 2011

I created a simple data access layer in the dll and reference it in my web app. How can I point the error to the user that his code in this line has an exception. currently, when i input a nonexisting table it will popup an error "invalid object name table_name" and points the my code throw exception inside my dll. I want it to point out to the user code that uses my function that creates an error.

Line 92: Dim ds As DataSet = DAL.Dal.ExecuteDataset("SELECT * FROM table_nam", "DBConnectionString")

Line 93: GridView1.DataSource = ds.Tables(0)

View 4 Replies

Web Forms :: Handling MasterPage Event In User Control Of Content Page

Aug 19, 2010

On my master page , I have "Search textbox" and "Search Button".

On My content page , I have a "User Control" which has a "GridView".It shows some data about Vendors.

Also, on this User Control's Page Load, i have code written to display all vendors in GridView.

Now, when user enters Vendor Number in "Search textbox" , and hits "Search Button" , i want to handle this event inside my User Control.

How to do this ?

View 2 Replies

Architecture :: Is Using Class Level Private Shared Variables Not Good

May 28, 2010

In page behind classes I am using a private and shared object (list<client> or just client) to temporary hold data coming from database or class library. This object is used temporarily to catch data and than to return, pass to some function or binding acontrol. 1st: Can this approach harm any way ? I couldnt analyse it but a thought was using such shared variables may replace data in it ?2nd: Please comment also on using such variables in BLL (to hold data coming from database) where new object of BLL class will be made everytime.

[Code]....

View 4 Replies

C# - Is Using Private Shared Objects/variables On Class Level Harmful

May 28, 2010

In page behind classes I am using a private and shared object and variables (list or just client or simplay int id) to temporary hold data coming from database or class library. This object is used temporarily to catch data and than to return, pass to some function or binding a control.1st: Can this approach harm any way ? I couldn't analyze it but a thought was using such shared variables may replace data in it when multiple users may be sending request at a time?

[code]...

View 2 Replies

C# - Exception Handling Internal Bug?

Mar 18, 2011

Code:

public static void Test()
{
try
{
OpenConnectionToDatabase(); //Opens a connection to Oracle DB
} catch(Exception e)
{
e.Data.Add("Query:", command.CommandText);
throw e;
}
}

When this code is executed when the Database server is being shutdown and the communication is disrupted, .NET throws the following error: Item has already been added. Key in dictionary: 'Query:' Key being added: 'Query:' at System.Collections.ListDictionaryInternal.Add(Object key, Object value) How can this be?

View 2 Replies

Architecture :: Exception Handling In MVP?

May 28, 2010

I'm wondering what's the preferred way to manage exceptions in an MVP implemented with a Passive View.

There's a discussion in my company about putting try/catch blocks in the presenter or only in the view.

In my opinion the logical top level caller is the presenter (even if the actual one is the view).

Moreover I can test the presenter and not the view. This is the reason why I prefer to define a method in the view interface:

[Code]....

View 2 Replies

MVC :: Exception Handling With RenderAction?

Feb 24, 2010

We are using renderaction provided by MVC futures. We've noticed that HttpExceptions in child action methods are not propagated to the parent action. Even though a fragment has failed, we still see the parent request resulting in a 200, and this throws our error handling for a toss.

View 4 Replies

MVC :: Can't Get Exception Handling To Work?

Aug 3, 2010

I have a weird situation here. Using VS2010 and the MVC2 application template, I'm trying to set up error handling, but it refuses to work... Even with a simple controller throwing an exception in the index:

[Code]....

And <customErrors mode ="On"></customErrors> in the web.config file, MVC breaks into the code and tells me that "Exception was unhandled by user code". The default Error.aspx (static text only) is located in /Views/Shared, and I've even removed the login partial view from the master page.

View 2 Replies

Exception Handling While Reading RSS Or XML?

Nov 12, 2010

I have a code which reads from a database and loads all feeds in it. Occassionaly I will get errors when the feeds are not responding. The error is happening on this line of code:

[Code]....

How do I add in a code that if the read above fails, ignore and proceed to next data row in the SQLDataReader ?

View 1 Replies

Ways To Identify A Particular Exception From Exception Class?

May 18, 2010

Is there any way to uniquely identify a particular exception from the general exception class.

i.e any property or method that retrieves a unique identifier that to identify a particular exception.

I have kept some error values and corresponding error texts in an xml file. I want to read that xml file and have to taken the error ids and fix the corresponding texts to a label. in the case of a system exception we have to identify a particular exception.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved