Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Copying A Control Not As A Reference

Reply
Thread Tools

Copying A Control Not As A Reference

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      06-12-2006
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
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
tomb
Guest
Posts: n/a
 
      06-12-2006
Nathan Sokalski wrote:

>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.
>
>

You have to pass the ctrl ByRef in order to be working with the one you
want to copy.

T
 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      06-12-2006
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
(E-Mail Removed)
http://www.nathansokalski.com/

"tomb" <(E-Mail Removed)> wrote in message
news:RV5jg.71053$(E-Mail Removed). ..
> Nathan Sokalski wrote:
>
>>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.
>>

> You have to pass the ctrl ByRef in order to be working with the one you
> want to copy.
>
> T



 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      06-12-2006
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?...c-61641f5c8d9d

I hope this helps,

Cor

"Nathan Sokalski" <(E-Mail Removed)> schreef in bericht
news:%(E-Mail Removed)...
>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
> (E-Mail Removed)
> http://www.nathansokalski.com/
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      06-12-2006
"tomb" <(E-Mail Removed)> schrieb:
>>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.

>
> You have to pass the ctrl ByRef in order to be working with the one you
> want to copy.


No, you should pass it 'ByVal' because 'Control' is already a reference
type.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copying object from reference techieV C++ 2 02-21-2011 08:01 AM
Copying A Control Not As A Reference Nathan Sokalski ASP .Net 4 06-12-2006 09:30 AM
Copying A Control Not As A Reference Nathan Sokalski ASP .Net Building Controls 4 06-12-2006 09:30 AM
copying values from a hash into CGI.pm via tied hash reference ioneabu@yahoo.com Perl Misc 14 01-10-2005 01:22 PM
Python Library Reference is tutorial, not reference aurora Python 6 10-18-2004 07:38 AM



Advertisments