메뉴 건너뛰기

조회 수 8500 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

3가지 방법이 있다.

1. 페이지 로드할때 컨트롤에 포커스를 주는 스크립트를 작성한다.
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>제목 없음</title>
        <script type="text/javascript">
            function fn_focus()
            {
                document.getElementById("txt").focus();
            }
        </script>
    </head>
    <body onload="fn_focus()">
        <form id="form1" runat="server">
        <div>
            <input type="text" id="txt" runat="server" />
        </div>
        </form>
    </body>
    </html>

  또는 cs에서 스크립트를 문자열로 추가하거나..
    string script = string.Empty;
    script += "<script type='text/javascript'>document.getElementById('txt').focus();</script>";

    Page.RegisterStartupScript("Focus", script);

2. 폼테그 안에서 포커스를 줄 컨트롤을 지정한다.
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>제목 없음</title>
    </head>
    <body>
        <form id="form1" runat="server" defaultfocus="txt">
        <div>
            <input type="text" id="txt" runat="server" />
        </div>
        </form>
    </body>
    </html>

3. cs에서 페이지 속성에 추가한다.
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Page.SetFocus("txt");
     }


List of Articles
번호 제목 날짜 조회 수
247 'Array', 배열 및 다차원 배열 선언에 대해 알아보자! 2015.02.03 11110
246 'blur', 이미지 클릭시 테두리를 없애자! file 2015.02.03 7353
245 'button', 클릭한 횟수 알아내기! file 2015.02.03 10755
244 'checkbox', 체크박스 모두체크 그리고 모두해제! file 2015.02.03 7492
243 'focus', 엔터 누르고 이동하자! file 2015.02.03 12857
242 'onmouseover', 마우스 오버 효과 - 글씨 바꾸기! file 2015.02.03 9433
241 'open', 새창을 열어보자! file 2015.02.03 6036
240 'opener', 부모창과 자식창의 텍스트를 교환하자! file 2015.02.03 7308
239 'setInterval', 타이머를 사용하자! ==setTimeout 2015.02.03 6223
238 'setTimeout', 타이머를 사용하자! file 2015.02.03 7033
237 '레이블', 반복문을 제어하자! file 2015.02.03 5540
236 '문자 ↔ 숫자', 타입을 바꿔보자! 2015.02.03 6207
235 (소스)jqury 롤오버 버튼 쉽게 만들기 file 2014.03.01 5784
234 2단계 트리메뉴 마우스오버(mouseover), 온포커스(onfocus) 구현 2015.04.06 8203
233 3자리 마다 쉼표만 찍어주는 number_format 함수 2021.03.26 225
232 3자리마다 콤마찍기 2014.02.27 5755
231 5초 후에 해당페이지로 url 옮기기 2014.02.27 10485
230 5초후 자동으로 창닫기 2015.02.03 9034
229 == / === / != / !== 차이 2018.11.07 1443
228 ajax 사용시 Internal Sever Error 뜨는 경우 2021.03.26 958
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 13 Next
/ 13

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved