using client-side component keeps calling component's init

J

Jim Hammond

The following code uses a client-side component to capture an image from the
camera on the client system.

The problem is that the init function (in ClientSideAssembly_Video.dll) is
called once when the page is first displayed and then each time the button
is pressed.

I'm guessing that the component is being instantiated each time. Is there
any way to keep using the same instance?

Thanks,

Jim


<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>
<asp:button id="Button3" runat="server" Text="TAKE
PHOTO"></asp:button>
</form>
<script language="javascript">
function TakePicture()
{
VideoControl.TakePicture();
document.Form1.hidden1.value = VideoControl.jpgFile;
}
</script>
</body>


I enable the button to call the JavaScript function TakePicture() with the
following
C# code in the web form:

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

Jim Hammond

The following code uses a client-side component to capture an image from the
camera on the client system.

The problem is that the init function (in ClientSideAssembly_Video.dll) is
called once when the page is first displayed and then each time the button
is pressed.

I'm guessing that the component is being instantiated each time. Is there
any way to keep using the same instance?

This happens even if I comment out the statements inside the JavaScript
function.

Thanks,

Jim


<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>
<asp:button id="Button3" runat="server" Text="TAKE
PHOTO"></asp:button>
</form>
<script language="javascript">
function TakePicture()
{
VideoControl.TakePicture();
document.Form1.hidden1.value = VideoControl.jpgFile;
}
</script>
</body>


I enable the button to call the JavaScript function TakePicture() with the
following
C# code in the web form:

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top