用戶控件獲得焦點


用戶控件爲HeadCtl,id爲HeadCtl1,用戶控件中含有TextBox的id爲txtBox,但是獲得焦點是,id要變爲HeadCtl1_txtBox

再使用函數:

    Sub GetFocus(ByVal str_ctl_name As String, ByVal page As Page)
        page.RegisterStartupScript("", "<script>document.forms(0)." + str_ctl_name + ".focus(); document.forms(0)." + str_ctl_name + ".select();</script>")
    End Sub
就可獲得焦點。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章