我的尝试:如何解决“输入字符串格式不正确”。错误?
标记:
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Label ID="Label1" runat="server" AssociatedControlID="TextBox2" Text="Label"></asp:Label>
<asp:SliderExtender ID="SliderExtender1" TargetControlID="TextBox2" BoundControlID="Label1" Maximum="200" Minimum="100" runat="server">
</asp:SliderExtender>
代码背后:
protected void setImageWidth()
{
int imageWidth;
if (Label1.Text != null)
{
imageWidth = 1 * Convert.ToInt32(Label1.Text);
Image1.Width = imageWidth;
}
}
在浏览器中运行的页面后,我得到的System.FormatException
:输入字符串没有一个正确的格式。
变化'Convert.ToInt32(Label1.Text)''来Convert.ToInt32(TextBox2.Text)' –
@AndreCalil我只是尝试,仍然得到了同样的错误 –
在'SliderExtender1'处,改变'Bound'和'Target'控制 –