I have a slider whose minimum and maximum value has to be taken from a label
Following is the code
<asp:SliderExtender ID="TextBox3_SliderExtender" runat="server" BehaviorID="TextBox3"
BoundControlID="TextBox4" TargetControlID="TextBox3" EnableHandleAnimation="true"
Maximum='<%# Math.Round(((double)lblMax.Text),0) %>' Minimum='<%# Math.Round((double)lblMin.Text,0) %>' Orientation="Horizontal" Steps="100" />
the error in above code is cannot convert type 'string to 'double'
how can i set maximum value from label named lblMax as Maximum for slider extender (Note : - lblMax contain integer value)
Maximum='<%# Math.Round(((double)lblMax.Text),0) %>'
You can't directly cast a string to a double. You're looking for double.Parse()
.
The minimum and maximum value can be set throught code as
TextBox3_SliderExtender.Minimum = int.Parse(lblMin.Text.ToString()); TextBox3_SliderExtender.Maximum = int.Parse(lblMax.Text.ToString());
that will pick the value from the label and we can assign dynamically the value to tha label
thax 4 the help
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.