Using C# script instead of JavaScript problems

  • Thread starter Thread starter Jeronimo Bertran
  • Start date Start date
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
 
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:
 
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
 
Back
Top