I'm implementing something like suggested on this question, having a dynamically generated user control nested in another one.
The issue I'm facing is that some controls have some javascript functions or css classes that are not being loaded.
For example, I have a control that resume to this ListBox:
<div class="form-group listbox-align" style="width:100%;">
<asp:ListBox ID="ListBox_Options" runat="server" CssClass="multiselect-group listbox-element" AutoPostBack="false"></asp:ListBox>
</div>
And the css classes exclusive to this control (listbox-align and listbox-element) looks like this:
.listBox-align {
text-align: left;
}
.listBox-align .input-group-btn {
display: none;
}
When loading page I have this javascript code to this component:
$(document).ready(function () {
var listBox = '#<%=ListBox_Options.ClientID %>';
Sys.Application.add_load(function () {
aplicarComponenteOctopusSearchable(listBox, '100%');
});
});
function aplicarComponenteOctopusSearchable(seletor, btnWidth) {
try {
$(seletor).multiselect({
includeSelectAllOption: false,
allSelectedText: 'All',
selectAllText: 'All',
nSelectedText: 'Selected',
nonSelectedText: 'Select...',
buttonWidth: btnWidth,
maxHeight: 400,
enableFiltering: true,
filterPlaceholder: 'Filter...',
enableCaseInsensitiveFiltering: true
});
} catch (e) {
alert(e.message);
}
}
Now I'm unable to use this component properly 'cause I couldn't figure out how to load this css and javascript just once and just on the pages that use this user control (it'll be added after some event).
Can anyone help me with this?