Attaching JavaScript To ASP.Net Controls

J

Jim Heavey

Hello, I was wondering how I would go about attaching some Java script code
to a <asp:EditCommandColumn. If the user presses the "edit" link, then I
want to test other controls to see if any information has been keyed into
them.

Is there a way to do that?

How do I reference other controls in my JavaScript?

Thanks in advance for your assistance!!!!!!!!!
 
S

S. Justin Gengo

Jim,

Attach javascript to your control in the code-behind page:

MyButton.Attributes.Add("onClick", "javascript: return
myJavascriptFunction();")

Reference other controls by their client id's

document.Form1.button1

If you're building your javascript in the code-behind page and then
registering it with Page.RegisterClientScriptBlock then you can get a
control's client id via its ClientId property: Button1.ClientId


Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top