pass text to javascript function

  • Thread starter Thread starter prav
  • Start date Start date
P

prav

Hello,
I found this code and I want to pass this function a value
from a dataset.

How do I do this?

<INPUT onmouseover="func()" type="button" value="Button">


<script type=text/javascript>
function func()
{
//you could put anything here, e.g. opening a window etc.
alert('Hi');
}
</script>
 
<INPUT runat="server" id="myButton" onmouseover="func()" type="button"
value="Button">

In the code behind (C#):

myButton.Attributes["onmouseover"]=String.Format("func({0})", "my text");

Eliyahu
 
Eliyahu said:
<INPUT runat="server" id="myButton" onmouseover="func()"
type="button" value="Button">

In the code behind (C#):

myButton.Attributes["onmouseover"]=String.Format("func({0})", "my
text");

Eliyahu

You might want to put quotes around that text:

String.Format("func('{0}')", "my text");

(and then you could still have problems with quotes inside the string)


Hans Kesting
 
Back
Top