Using C# script instead of JavaScript problems

J

Jeronimo Bertran

A couple of questions I am having problems with converting my JavaScript to
C#.

I have the following code using JavaScript for the mouseover handler that
works fine:


<SCRIPT language=JavaScript>
function MyMouseOver()
{
alert("We are there!");
}
</SCRIPT>

<H3>Walk over <A onmouseover=MyMouseOver() ref="http://msdn.microsoft.com"
ME!</A></H3>

1- How can I change the script to C# using <script language=C#
runat="server">

Changing the script in the following manner doesn't work:

<SCRIPT language=C# runat="server">
void MyMouseOver()
{
// Do something
}
</SCRIPT>



2- Can I call server side functions from within JavaScript functions?

Thanks !!!

Jeronimo
 
C

-=Chris=-

1. The onMouseOver and onMouseOut events are client only functions. You
can't implement those using javascript (well, you could, but it would be a
waste of time and resources. You'd have to implement still more javascript
to do the postback on the mouse over event, which would be quite useless).

2. You cannot call server side functions from a client side script unless
you're posting back the form, which again, is fruitless if you're trying to
manipulate something on the client end. Stick with Javascript.

ASP.NET (including C#, or any other .NET language) is a server side
programming language. You cannot manipulate client side properties using
them, because server side code only gets executed once during a page's life
cycle (the actual request from the server).

Hope this helps...

I was minding my own business when Jeronimo Bertran blurted out:
 
C

-=Chris=-

I was minding my own business when -=Chris=- blurted out:
1. The onMouseOver and onMouseOut events are client only functions. You
can't implement those using javascript

[Correction: You can't implement those using C#]

(well, you could, but it would be a
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top