Attaching JavaScript To ASP.Net Controls

  • Thread starter Thread starter Jim Heavey
  • Start date Start date
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!!!!!!!!!
 
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
 
Back
Top