菜鸟求助!
<asp:label id="Label1" style="Z-INDEX: 101; LEFT: 304px; POSITION: absolute; TOP: 152px" runat="server">数据一:</asp:label><asp:label id="Label2" style="Z-INDEX: 102; LEFT: 304px; POSITION: absolute; TOP: 184px" runat="server">数据二:</asp:label>
<asp:textbox id="TextBox1" style="Z-INDEX: 103; LEFT: 384px; POSITION: absolute; TOP: 144px" runat="server">
</asp:textbox><asp:textbox id="TextBox2" style="Z-INDEX: 104; LEFT: 384px; POSITION: absolute; TOP: 176px" runat="server">
</asp:textbox>
<asp:button id="Button1" style="Z-INDEX: 105; LEFT: 304px; POSITION: absolute; TOP: 224px" runat="server" Text="求和值">
</asp:button><asp:label id="Label3" style="Z-INDEX: 106; LEFT: 392px; POSITION: absolute; TOP: 232px" runat="server"></asp:label>
程序页:
private void Button1_Click(object sender, System.EventArgs e)
{
if(TextBox1.Text!=null&&TextBox2.Text!=null) //判断是否已经输入
{
double add1=double.Parse(TextBox1.Text); //文本框中输入的为字符串,要先转换成浮点型
double add2=double.Parse(TextBox2.Text); //转换第二个数值
double result=add1+add2;
Label3.Text=result.ToString(); //将求和结果再次转换为字符串,并设为Labl3的文本
}
我在求和的时候得不到值