开发者

If I use "FindControl" outside a UserControl, what do I use within a UserControl?

开发者 https://www.devze.com 2023-01-11 08:13 出处:网络
Suppose I have javascript within ASP.NET UserControl: function setValue(DataItem) { var selectedDate 开发者_JAVA百科= DataItem.getMember(\'DomainNameKey\').get_object();

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

0

精彩评论

暂无评论...
验证码 换一张
取 消