If you don't like mixing ASP.NET code with your label, you can also do this:
Markup:
<asp:HiddenField runat="server" id="hfVisible" Value="true" />
<asp:HiddenField runat="server" id="hfSpeed" Value="1000" />
JavaScript:
$(function() {
$(".anyClass").jCarouselLite({
btnNext: ".next",
btnPrev: ".prev",
visible: $('#hfVisible').val(),
scroll: 1,
speed: $('#hfSpeed').val();
});
});
code behind:
protected override void OnLoad(EventArgs e) {
hfVisible.Value = true;
hfSpeed.Value = 1000;
}
Note: if HiddenFields are in UserControl, do not use an identifier to refer to elements, use a class instead or other attributes; or to avoid this: use RegisterHiddenField:
ClientScriptManager cs = Page.ClientScript;
cs.RegisterHiddenField('hfVisible', "false");
cs.RegisterHiddenField('hfSpeed', "1000");
This way you do not need to declare HiddenFields in the markup.
source
share