By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,033 Members | 1,285 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,033 IT Pros & Developers. It's quick & easy.

JAVASCRIPT IN ASP.NET

P: n/a

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>
Feb 8 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
nj********@hotmail.com
http://www.nathansokalski.com/

"Savas Ates" <in da club> wrote in message
news:OB**************@TK2MSFTNGP12.phx.gbl...

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>

Feb 9 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.