protected override void CreateChildControls()
{
txt = (TextBox)this.Parent.FindControl(TargetControlID);
if (txt != null) {
_txt.Attributes.Add("ondblclick", "alert('foo')");
}
base.CreateChildControls();
}
Programming Journal C#, Java, SQL and to a lesser extent HTML, CSS, XML, and regex. I made this so other programmers could benefit from my experience.
Saturday, February 16, 2008
FindContol Solution to add Javascript to a control from a user control
Here is a great solution to finding a control using FindControl method from a user control. TargetcontrolID is the public property for TextBoxFooExtender (User Control). _txt is the targeted TextBox assuming it is found.
Labels:
C# AJAX,
C# javascript,
C# MasterPage,
C# Web User Control,
FindControl
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2008
(54)
-
▼
February
(13)
- Lazy Load Panel Courtesy of TabContainer and Updat...
- Simple and Complex Drilldown for ASP.Net Objects
- Web User Control Library error
- Prevent RadioButtonList from forcing a line break
- Using Web.config hash for variables using add, key...
- Drilling down a nested master page in ASP.NET to r...
- Intercepting return in list menu items in ASP.NET
- FindContol Solution to add Javascript to a control...
- How to show and hide CalendarExtender and Collapsi...
- Understanding Default Values for User Web Controls
- Creating a ListItemCollection Template User Control
- Installing CA Anti-virus with error on open
- Web Control IDs INamingContainer to avoid duplicat...
-
▼
February
(13)
No comments:
Post a Comment