Copying A Control Not As A Reference

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Copying A Control Not As A Reference

    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
    [email]njsokalski@hotmail.com[/email]
    [url]http://www.nathansokalski.com/[/url]


    Nathan Sokalski Guest

  2. Similar Questions and Discussions

    1. reference to Composite Control
      Hi, I have created a composite control which, in its simplest form inherits from Control, implements INamingContainer and provides a method...
    2. #40737 [NEW]: Variable passing by reference instead of copying.
      From: anter at voliacable dot com Operating system: XP Prof SP2 PHP version: 5.2.1 PHP Bug Type: Class/Object related Bug...
    3. Reference Datagrid Footer Control
      In a datagrid footer, how could I programmatically set a footer textbox text? E.g.. the datagrid (dg1) will bind to a datareader based on a query....
    4. Simple Control With a Reference to Another Control
      Hello, I am trying to make a Web Cstom Control with a property which is simply a reference to another control. This is exactly the same as the...
    5. ActiveX control for copying file in DTS
      Hi Freinds, I need to copy a file from: \\serverone\folder\myfile.txt to \\servertwo\folder\myfile.txt where \\servertwo is my sql server and...
  3. #2

    Default Re: Copying A Control Not As A Reference

    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
    tomb Guest

  4. #3

    Default Re: Copying A Control Not As A Reference

    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
    [email]njsokalski@hotmail.com[/email]
    [url]http://www.nathansokalski.com/[/url]

    "tomb" <tomb@technetcenter.com> wrote in message
    news:RV5jg.71053$QU3.68250@bignews8.bellsouth.net. ..
    > 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

    Nathan Sokalski Guest

  5. #4

    Default Re: Copying A Control Not As A Reference

    Nathan,

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

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

    I hope this helps,

    Cor

    "Nathan Sokalski" <njsokalski@hotmail.com> schreef in bericht
    news:%23ZajLSdjGHA.3440@TK2MSFTNGP02.phx.gbl...
    >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
    > [email]njsokalski@hotmail.com[/email]
    > [url]http://www.nathansokalski.com/[/url]
    >

    Cor Ligthert [MVP] Guest

  6. #5

    Default Re: Copying A Control Not As A Reference

    "tomb" <tomb@technetcenter.com> 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/>

    Herfried K. Wagner [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139