我有一個Web窗體在GridView的文本框,我想higlight點擊一個按鈕的文本。 textbox.select(start,end)
不起作用。這裏是代碼:突出顯示文本不可
Dim row As GridViewRow = TryCast(DirectCast(sender, ImageButton).Parent.Parent, GridViewRow)
Dim txtdays As TextBox = row.Cells(2).FindControl("txtDays")
Dim lbldays As Label = row.Cells(2).FindControl("lblDays")
Dim btndel As ImageButton = row.Cells(2).FindControl("btndel")
Dim imgbttnadd As ImageButton = row.Cells(2).FindControl("imgbttnadd")
//Show textbox and set its text.
txtdays.Visible = True
txtdays.Text = lbldays.Text
txtdays.Focus()
//Here is where I want to select the text.
txtdays.Select() //???????? Doesn't work.
你是如何做到這一點的?
.Select
適用於Windows窗體文本框,但不適用於Web窗體文本框。
感謝您的額外幫助(+1)。但我已經嘗試了一個很像你請求的函數,但我得到一個JavaScript錯誤,說txtdays沒有聲明。我的txtdays在模板字段中,但它應該找到它的權利?我應該發佈一些標記嗎? – Eric 2009-06-04 16:33:55