By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,314 Members | 1,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,314 IT Pros & Developers. It's quick & easy.

how to prevent component instantiation every time?

P: n/a
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
Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Jim Hammond" <jh******@postalinnovations.com> wrote in message
news:#8**************@TK2MSFTNGP12.phx.gbl...
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

Nov 17 '05 #2

P: n/a
Here are the details...
Thanks,

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

classid="ClientSideAssembly_Video.dll#ClientSideAs sembly_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" <jh******@postalinnovations.com> 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


Nov 17 '05 #3

P: n/a
"Jim Hammond" <jh******@postalinnovations.com> wrote in message
news:uu**************@TK2MSFTNGP09.phx.gbl...
Here are the details...
Thanks,

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

classid="ClientSideAssembly_Video.dll#ClientSideAs sembly_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:
jo***********@surfcontrol.com

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


Nov 17 '05 #4

P: n/a
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:Om**************@TK2MSFTNGP12.phx.gbl...
"Jim Hammond" <jh******@postalinnovations.com> wrote in message
news:uu**************@TK2MSFTNGP09.phx.gbl...
Here are the details...
Thanks,

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

classid="ClientSideAssembly_Video.dll#ClientSideAs sembly_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:
jo***********@surfcontrol.com

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

Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.