2012-05-26 14 views
0

我的Asp頁面中有兩個下拉框。一旦用戶更改了下拉列表中的值,它將觸發Autopostback並在標籤上顯示新的選定值。標籤Autopostback abilty

label.text = Convert.ToString(Convert.Int32(DropDownList1.SelectedValue.ToString())+Convert.Int32(DropDownList2.SelectedValue.ToString())); 

我只是想檢索這個標籤值(動態再現)到另一個文本框。

不幸的是,沒有標籤的AutoPostBack事件。我該如何克服這一點? 請幫助我。

+0

你爲什麼將字符串轉換爲整數,然後返回一個字符串? – woz

+0

這是一些徹頭徹尾的糟糕的代碼... – dtsg

+0

如果標籤的值僅在更改下拉列表的回發時發生變化,爲什麼不能同時設置文本框的值? – angusf

回答

1

在您上傳標籤值時更新文本框的值。

label.text = Convert.ToString(Convert.Int32(DropDownList1.SelectedValue.ToString())+Convert.Int32(DropDownList2.SelectedValue.ToString())); 
textBox.text = label.text 
0
string Label_Value =Convert.ToString(Convert.Int32(DropDownList1.SelectedValue.ToString())+Convert.Int32(DropDownList2.SelectedValue.ToString())); 

Textbox1.Text=Label_Value .Tostring();