페이지가로드 될 때 컨트롤에 포커스를 설정하려고합니다.페이지로드시 asp.net 컨트롤에 포커스 설정
this.setFocus(txtHeightfeet);
이 도와주세요 : 는이 코드 있지만 작동하지 않습니다 ..
protected void setFocus(System.Web.UI.Control ctrl)
{
string s = "<SCRIPT language='javascript'>document.getElementById('" + ctrl.ID + "').focus() </SCRIPT>";
Type csType = this.GetType();
ClientScript.RegisterStartupScript(csType, "focus", s);
}
및 PageLoad 방법이 선을 썼다.
편집 :
<input name="ctl00$MainContent$txtHeightfeet" type="text" maxlength="2" id="MainContent_txtHeightfeet" class="textEntry2" style="width:65px;" />
이것은 영문 코드 :
<asp:TextBox ID="txtHeightfeet" runat="server" CssClass="textEntry2" MaxLength="2" Width="65"></asp:TextBox> ft
및 CS 파일 뒤에 코드
, 난이 같은 당신이 언급 한 선언이 HTML입니다.
의 중복 가능성 http://stackoverflow.com/questions/3043592/set-focus-to-textbox-in-asp-net -login-control-on-page-load) –