我目前有一个如下所示的滑块控件:
<cc1:SliderExtender ID="sliderTest" runat="server" Enabled="True"
TargetControlID="txtBoxTest" BoundControlID="lblTestSlider"
Decimals="0" Maximum="10" Minimum="0"
EnableHandleAnimation="true">
</cc1:SliderExtender>
<asp:TextBox ID="txtBoxTest" runat="server"></asp:TextBox>
<asp:Label ID="lblTestSlider" runat="server"></asp:Label>
它有效,当滑块移动时,数字从0变为10.很棒!
我现在要做的是更改滑块标签(lblTestSlider)以显示0到10(10个不同文本值)的每个值的不同文本,而不是数字。我怎样才能做到这一点?
答案 0 :(得分:1)
以下是一个丑陋的实现,我希望有人能找到更好的东西:
<asp:UpdatePanel runat="server">
<ContentTemplate>
<ajax:SliderExtender ID="sliderTest" runat="server"
Enabled="True"
Decimals="0" Maximum="10" Minimum="0"
EnableHandleAnimation="true"
RaiseChangeOnlyOnMouseUp="true"
TargetControlID="txtBoxTest" />
<asp:TextBox ID="txtBoxTest" runat="server"
OnTextChanged="txtBoxTest_TextChanged"
AutoPostBack="true" />
<asp:Literal ID="litDisplay" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
代码隐藏:
protected void txtBoxTest_TextChanged(object sender, EventArgs e)
{
switch (int.Parse(((TextBox)sender).Text))
{
case 0:
case 1:
case 2:
case 3:
case 4: litDisplay.Text = "Less than 5"; break;
case 5:
case 6:
case 7:
case 8:
case 9:
case 10: litDisplay.Text = "Greater than 5"; break;
}
}