Javascript function works but C# function doesn't execute

  • Thread starter Thread starter Jim Hammond
  • Start date Start date
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()");
}
 
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)
 
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)
 
Back
Top