Use the Attributes property. Here is a simple little function I wrote for
myself to create rollovers, but it's a good example of how to use the
Attributes property:
Public Shared Sub AddRollover(ByVal img As Web.UI.WebControls.Image,
ByVal rollover As String)
'Adds the rollover feature to an Image or ImageButton (or other
class that inherits from an Image)
img.Attributes.Add("onmouseover", "this.src='" & rollover & "';")
img.Attributes.Add("onmouseout", "this.src='" & img.ImageUrl & "';")
End Sub
The Add method of the Attributes property takes two parameters, the
attribute's name and value, both of which are of type String. I'm sure you
can take it from here, if you want more help, just ask or look at the help
files. Good Luck!
--
Nathan Sokalski
njsokalski@hotmail.com http://www.nathansokalski.com/
"Savas Ates" <in da club> wrote in message
news:OBCb7eJLGHA.1532@TK2MSFTNGP12.phx.gbl...[color=blue]
>
> How can i add javascript code to my server control object ?
>
> I want to add a javascript code when a user OnClick it ..
>
> Is there any sample code or reference web site or knowledge to solve it ?
>
> <asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 6px; POSITION:
> absolute; TOP: 6px" runat="server"
> Text="Button"></asp:Button>
>[/color]