Suppose I have javascript within ASP.NET UserControl:
function setValue(DataItem) {
var selectedDate 开发者_JAVA百科= DataItem.getMember('DomainNameKey').get_object();
Picker1.setSelectedDate(selectedDate);
}
Where Picker1 is also inside the control. Because Picker1's ID will be renamed at runtime, what do I put in the code below to make it work within a UserControl?
function setValue(DataItem) {
var selectedDate = DataItem.getMember('DomainNameKey').get_object();
<%= ?????????????? %>.setSelectedDate(selectedDate);
}
You can use something like this:
function setValue(DataItem) {
var selectedDate = DataItem.getMember('DomainNameKey').get_object();
document.getElementById("<%= Picker1.ClientID %>").setSelectedDate(selectedDate);
}
In my situation, the ComponentArt controls create a second Javascript object that should be used. Read more here:
Q10103 - HOWTO: Determining the client ID of Web.UI controls in Master / Content pages http://www.componentart.com/kb/article.aspx?id=10103
Q10087 - HOWTO: Determining the client ID of Web.UI controls in user controls and templates http://www.componentart.com/kb/article.aspx?id=10087
精彩评论