Javascript function works but C# function doesn't execute

J

Jim Hammond

The script function in the code below works fine when it is JavaScript, but
when I try to use C#, the function doesn't get executed.

<body MS_POSITIONING="GridLayout">

<form id="Form1" name="Form1" method="post"
encType="multipart/form-data" runat="server" VIEWASTEXT>
<asp:button id="Button3" runat="server" Text="TAKE PHOTO"></asp:button>
</form>

<script language="C#">
void TakePicture()
{
}
</script>

</body>

I don't know if this is relevant, but 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()");
}
 
P

Polux

You are trying to execute C# inside the browser. C# can only be executed
in the server. For client side scripting you must use javascript.

Most browsers (mozilla, netscape,opera) understand only javascript. (but
Internet Explorer understand also VBScript)
 
B

bruce barker

the browser does not support C# as a scripting language, but does support
javascript. C# is only valid with the runat=server attribute, but then of
course it cannot be called on the client side, but only on a postback


-- bruce (sqlwork.com)
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top