how to prevent component instantiation every time?

Discussion in 'ASP .Net' started by Jim Hammond, Nov 11, 2003.

  1. Jim Hammond

    Jim Hammond Guest

    Every time I call a method in a client-side assembly (component), it seems
    like the component gets instantiated again. More specifically, I have
    determined that the Init method is getting called every time. Is there a way
    to preserve the initial instantiation?

    Thanks,

    Jim
    Jim Hammond, Nov 11, 2003
    #1
    1. Advertising

  2. "Jim Hammond" <> wrote in message
    news:#...
    > Every time I call a method in a client-side assembly (component), it seems
    > like the component gets instantiated again. More specifically, I have
    > determined that the Init method is getting called every time. Is there a

    way
    > to preserve the initial instantiation?


    Details, please?

    Who is calling this client-side assembly? How is it calling the assembly
    (you don't call an assembly, you call a method or property defined in a type
    in the assembly, and you may instantiate an object of that type first).
    --
    John
    John Saunders, Nov 11, 2003
    #2
    1. Advertising

  3. Jim Hammond

    Jim Hammond Guest

    Here are the details...
    Thanks,

    <body MS_POSITIONING="GridLayout">
    <OBJECT id="Object1"

    classid="ClientSideAssembly_Video.dll#ClientSideAssembly_Video.VideoDisplay"
    name="VideoControl" VIEWASTEXT>
    </OBJECT>
    <form id="Form3" name="Form1" method="post"
    encType="multipart/form-data" runat="server" VIEWASTEXT>
    <INPUT id="Hidden3" type="hidden" name="hidden1" runat="server">
    <asp:image id="Image1" runat="server"></asp:image>
    </form>
    <script language="javascript">
    function TakePicture()
    {
    VideoControl.TakePicture();
    document.Form1.hidden1.value = VideoControl.jpgFile;
    }
    </script>
    </body>

    "Jim Hammond" <> wrote in message
    > Every time I call a method in a client-side assembly (component), it seems
    > like the component gets instantiated again. More specifically, I have
    > determined that the Init method is getting called every time. Is there a

    way
    > to preserve the initial instantiation?


    Details, please?

    Who is calling this client-side assembly? How is it calling the assembly
    (you don't call an assembly, you call a method or property defined in a type
    in the assembly, and you may instantiate an object of that type first).
    --
    John
    Jim Hammond, Nov 11, 2003
    #3
  4. "Jim Hammond" <> wrote in message
    news:...
    > Here are the details...
    > Thanks,
    >
    > <body MS_POSITIONING="GridLayout">
    > <OBJECT id="Object1"
    >
    >

    classid="ClientSideAssembly_Video.dll#ClientSideAssembly_Video.VideoDisplay"
    > name="VideoControl" VIEWASTEXT>
    > </OBJECT>
    > <form id="Form3" name="Form1" method="post"
    > encType="multipart/form-data" runat="server" VIEWASTEXT>
    > <INPUT id="Hidden3" type="hidden" name="hidden1" runat="server">
    > <asp:image id="Image1" runat="server"></asp:image>
    > </form>
    > <script language="javascript">
    > function TakePicture()
    > {
    > VideoControl.TakePicture();
    > document.Form1.hidden1.value = VideoControl.jpgFile;
    > }
    > </script>
    > </body>




    Jim,



    I don't see where the TakePicture function is being called.



    Are you saying that each time TakePicture is called the Init method of your
    Object1 object is called, so that if you called it twice in a row during the
    same request, you'd have Init called twice? Or are you saying that Init is
    called once per request?



    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    John Saunders E-mail:


    Internet Engineer
    Tel: +1 508 621 3818

    WWW: www.surfcontrol.com
    Fax: +1 508 621 3921

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    SurfControl - the World's #1 Web & E-mail Filtering
    Company
    John Saunders, Nov 11, 2003
    #4
  5. Jim Hammond

    Jim Hammond Guest

    I left out the following button:

    <asp:button id="Button3" runat="server" Text="TAKE PHOTO"></asp:button>

    I enable it to call the JavaScript function TakePicture() with the following
    code:

    private void Page_Load(object sender, System.EventArgs e)
    {
    if (!IsPostBack)
    Button3.Attributes.Add("onclick", "TakePicture()");
    }

    The init function is called once when the page is first displayed and then
    each time the button is pressed.



    "John Saunders" <john.saunders at surfcontrol.com> wrote in message
    news:...
    "Jim Hammond" <> wrote in message
    news:...
    > Here are the details...
    > Thanks,
    >
    > <body MS_POSITIONING="GridLayout">
    > <OBJECT id="Object1"
    >
    >

    classid="ClientSideAssembly_Video.dll#ClientSideAssembly_Video.VideoDisplay"
    > name="VideoControl" VIEWASTEXT>
    > </OBJECT>
    > <form id="Form3" name="Form1" method="post"
    > encType="multipart/form-data" runat="server" VIEWASTEXT>
    > <INPUT id="Hidden3" type="hidden" name="hidden1" runat="server">
    > <asp:image id="Image1" runat="server"></asp:image>
    > </form>
    > <script language="javascript">
    > function TakePicture()
    > {
    > VideoControl.TakePicture();
    > document.Form1.hidden1.value = VideoControl.jpgFile;
    > }
    > </script>
    > </body>




    Jim,



    I don't see where the TakePicture function is being called.



    Are you saying that each time TakePicture is called the Init method of your
    Object1 object is called, so that if you called it twice in a row during the
    same request, you'd have Init called twice? Or are you saying that Init is
    called once per request?



    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    John Saunders E-mail:


    Internet Engineer
    Tel: +1 508 621 3818

    WWW: www.surfcontrol.com
    Fax: +1 508 621 3921

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    SurfControl - the World's #1 Web & E-mail Filtering
    Company
    Jim Hammond, Nov 11, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Louis Dupont
    Replies:
    2
    Views:
    1,974
    Mike Treseler
    Aug 31, 2004
  2. systolic
    Replies:
    1
    Views:
    664
    Mike Treseler
    Nov 29, 2004
  3. Replies:
    1
    Views:
    562
    Salt_Peter
    Dec 25, 2006
  4. =?Utf-8?B?SXJ3YW5zeWFo?=
    Replies:
    4
    Views:
    2,441
    =?Utf-8?B?SXJ3YW5zeWFo?=
    Oct 30, 2007
  5. Dave Mihalik
    Replies:
    6
    Views:
    146
    Dave Mihalik
    Jul 28, 2006
Loading...

Share This Page