Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What type is THIS page when passing it?
Message
De
19/02/2008 17:53:26
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01293614
Message ID:
01294050
Vues:
20
>>>
>>>I think the last paragraph defines what I should learn to do - create some kind of a business object and pass it around. Let me explain why I need to pass THIS/PAGE (and I agree and learned that it is not possible) to a method of another class. In that method of another class I need to get .Text values of the page controls. E.g. This.MyTextBox.Text and so on. These values are only "available" in the Page class of the application, however. So I guess what you are saying is I need to create an object, set values of all my control .Text to this object and then pass it around. What I don't understand is where to start <g>. This object that will be passed around, where do you create it, and how do you use (instantiate) it in the page class?
>>>
>>>If the answer to my questions are too basic and require too much of explanation on your part, feel free to ignore it. I won't take it personally, I will just have to hit the books.
>>>
>>
>>If you don't have very many values you need to pass in you could pass them individualy. It is better to create another class in the same namespace or a business namespace that contains properties to hold all the values. Then in your button or whatever method you are using to instantiate the new page, you could instantiate an instance of the class and store all the .text values into those properties. Then pass this object over to your next page. Another idea depending on the individual situation would be to make this other class use either static or use a singleton pattern so you don't have to pass it. I have used this approach many times for things like settings classes and such. It is like Rick said rather poor practice and not really necessary to pass in a UI object.
>>
>>If you need examples, I have some I would share.
>
>Tim,
>
>Thank you very much for your input. What I don't understand is how to define properties of the class that will hold my page controls .Text values. I would like the routine to be generic and not hard coded to my specific page. That is, somehow scan all controls of the page and create a property in the "other" object class for each control the page has. If you have some tips on how to do it, I would appreciate it.

I see, well it looks like Bruce gave you a good idea then by using a hashtable. Since what you want to pass seems to be variable, then I it would be more difficult. Try the Hashtable as I have used them also and it is a good idea.
Tim
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform