how to prevent component instantiation every time?

  • Thread starter Thread starter Jim Hammond
  • Start date Start date
J

Jim Hammond

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 said:
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).
 
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 said:
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).
 
Jim Hammond said:
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:
(e-mail address removed)

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
 
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
Jim Hammond said:
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:
(e-mail address removed)

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
 
Back
Top