最近剛學(xué),遇到了個問題,望高手能幫個忙??!我有兩個文件,一個main.aspx 一個WebForm1.aspx ,WebForm1.aspx有兩個控件,一個DropDownList1,一個TextBox1main.aspx的 Html代碼:......<frameset id="aa" cols="150,8,*"> <frame name="left" scr="lefttree.aspx"> <frame name="middle" scr="t_l.htm"> <frame name="main" scr="WebForm1.aspx"></frameset>... WebForm1.aspx.cs 代碼也只加了 private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e) { this.Page.RegisterStartupScript("","<script>document.getElementById('TextBox1').focus();</script>"); } }只運行WebForm1.aspx時,能實現(xiàn)DropDownList1改變,TextBox1獲得焦點,但運行main.aspx卻不能獲得焦點,而且TextBox1點也點不進去了! 還望各位高手給予指點??!
2 回答

小唯快跑啊
TA貢獻1863條經(jīng)驗 獲得超2個贊
腳本應(yīng)該在page_Load事件中注冊
WebForm1.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (DropDownList1 != null)
{
DropDownList1.Attributes.Add("onchange", "document.getElementById('TextBox1').focus();");
}
}

慕慕森
TA貢獻1856條經(jīng)驗 獲得超17個贊
asp:dropdownlist id="DropDownList1" style="Z-INDEX: 101; LEFT: 424px; POSITION: absolute; TOP: 160px" runat="server" AutoPostBack="True">
你這個控件都沒有DropDownList1_SelectedIndexChanged這個事件,沒想通它怎么來的
- 2 回答
- 0 關(guān)注
- 680 瀏覽