Groups | Blog | Home
all groups > asp.net building controls > june 2006 >

asp.net building controls : Copying A Control Not As A Reference


Nathan Sokalski
6/11/2006 11:59:08 PM
I have a Control that I want to copy as a copy of the Control, not a copy of
the reference to the original. My reason for doing this is because some of
the methods I would calling would prevent proper rendering afterwards. I
access the Control as a parameter of a function, as follows:

Private Function MyFunction(ByVal ctrl As Control) As String
'code that will make a copy of ctrl
'my function code
End Function

(NOTE: I am using VB.NET and .NET Framework 1.1) Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

Cor Ligthert [MVP]
6/12/2006 12:00:00 AM
Nathan,

If a class is serializable you can almost forever copy something to
serialize the object first and than deserialize it again.

http://www.vb-tips.com/default.aspx?ID=7ffd296f-9e81-47e6-88dc-61641f5c8d9d

I hope this helps,

Cor

"Nathan Sokalski" <njsokalski@hotmail.com> schreef in bericht
news:%23ZajLSdjGHA.3440@TK2MSFTNGP02.phx.gbl...
[quoted text, click to view]

tomb
6/12/2006 12:15:29 AM
[quoted text, click to view]
You have to pass the ctrl ByRef in order to be working with the one you
want to copy.

Nathan Sokalski
6/12/2006 1:08:37 AM
That does not help. Let me try explaining my problem differently with an
example:

Private Function MyFunction(ByVal ctrl As Control) As String
dim copyofctrl as Control

'copyofctrl=ctrl this will be replaced with code that will assign a
copy of ctrl to copyofctrl that points to a new instance of whatever type
ctrl was
'my function code
End Function

In the part of my code labeled "my function code" I want to be able to do
ANYTHING I WANT to the local variable copyofctrl without having any effect
on ctrl. Hopefully this clears up what I am trying to do.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

[quoted text, click to view]

AddThis Social Bookmark Button