读书人

请问个小疑点。

发布时间: 2013-01-01 14:04:19 作者: rapoo

请教个小问题。。。。。。
这是我的后台代码,没有错的,能运行。


[解决办法]
放构造函数里

protected void btc()
{
int normalTemperature = Convert.ToInt16(DropDownList1.SelectedItem.Text);
int addTemperature = Convert.ToInt16(DropDownList2.SelectedItem.Text); double materialValue = Convert.ToDouble(DropDownList3.SelectedItem.Value);
int equipmentQuantity = Convert.ToInt16(TextBox2.Text);
int normalMoisture = Convert.ToInt16(DropDownList5.SelectedItem.Text); int addMoisture = Convert.ToInt16(DropDownList6.SelectedItem.Text);


int targetMTBF = Convert.ToInt16(TextBox3.Text);
double power1 = materialValue / normalTemperature - materialValue / addTemperature;
double power2 = (normalMoisture * normalMoisture)/10000 - (addMoisture * addMoisture)/10000;
double moutiplier = Math.Pow(2.18, power1);
double montiplicand = Math.Pow(2.18,power2);
double af = moutiplier * montiplicand;
double t=targetMTBF/(equipmentQuantity*af);
TextBox1.Text = t.ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
btc();
}


[解决办法]
在事件外面定义变量,在事件中赋值。

读书人网 >asp.net

热点推荐