Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What type is THIS page when passing it?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01293614
Message ID:
01293669
Vues:
14
>I want to pass object 'this' from a page code to a static method in a class in .cs file. In the called method, I need to define what type is this object. How do I define it?

If you use standard ASP.NET projects the class name is dynamically generated so the name is not available to you, at least not for the final class. You CAN pass the name of your code file class however.

loObj.MyMethod( (MyNamespace.MyPage) this );

With Web Application projects you can define the name of the generated class as well and you can use that name instead and get full support.

In general though I don't think this is a good idea. You should never pass a Page object to anything. If anything you should create an interface that has the properties/methods you want to expose and then have the page in question implement that interface, but even that is not a good idea. THere's no reason you should ever pass a user interface component around.

Instead any data you care about should be attached to some sort of data object (or a business object) and you acan then pass THAT around more effectively.

+++ Rick ---


>
>Here is an example:
>
>
>// in the calling program:
>MyClass.MyMethod( this )
>
>
>
>
>// in the .CS file
>public static void MyMethod( 'type of object' ThisObject )
>// What should be in the 'type of object'?
>
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform