Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Javascript function works but C# function doesn't execute

Reply
Thread Tools

Javascript function works but C# function doesn't execute

 
 
Jim Hammond
Guest
Posts: n/a
 
      11-14-2003
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()");
}


 
Reply With Quote
 
 
 
 
Polux
Guest
Posts: n/a
 
      11-14-2003
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)


Jim Hammond wrote:

> 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()");
> }
>
>


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      11-14-2003
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)




"Jim Hammond" <(E-Mail Removed)> wrote in message
news:O#$(E-Mail Removed)...
> 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()");
> }
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When I turn on my PC, it works, works, works. Problem! Fogar Computer Information 1 01-17-2006 12:57 AM
Can i execute aspx file in my asp pag with server.execute method(sorry) Savas Ates ASP General 1 08-17-2004 04:52 PM
[py2exe.i18n] English works, German works, but not French. What do I miss? F. GEIGER Python 3 08-06-2004 10:01 AM
After rebooting my PC works, works, works! Antivirus problem? Adriano Computer Information 1 12-15-2003 05:30 AM
Why this javascript function does not work on IE5, but works on IE6? Andrzej Javascript 0 10-06-2003 04:21 PM



Advertisments