메뉴 건너뛰기

조회 수 8507 추천 수 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");
     }


  1. input 빈칸 체크

    Date2014.03.01 Views6281
    Read More
  2. 해상도에 따라 배경 바꾸기

    Date2014.03.01 Views6089
    Read More
  3. 입력된 폼의 내용 똑같이 복사

    Date2014.03.01 Views6901
    Read More
  4. select 당일 날짜 출력

    Date2014.03.01 Views5811
    Read More
  5. 입력된 글씨수 제어

    Date2014.03.01 Views6711
    Read More
  6. 따라다니는 배너

    Date2014.03.17 Views6279
    Read More
  7. 이미지클릭시 옆에 큰이미지나오기

    Date2014.03.17 Views5532
    Read More
  8. 특정부위 마우스 오버시 설명을 보여주는 소스

    Date2014.03.17 Views8712
    Read More
  9. 이미지 마우스 드래그로 스크롤을 움직이는 소스

    Date2014.03.17 Views9368
    Read More
  10. 자바스크립트 영문입력, 숫자만입력, 한글만 입력, 붙여넣기 방지

    Date2015.02.02 Views10194
    Read More
  11. 페이지 로드 할때 컨트롤에 포커스 주기

    Date2015.02.03 Views8507
    Read More
  12. 마우스로 이미지크기 조절(자바스크립트)

    Date2015.02.03 Views6547
    Read More
  13. 문자열 바꾸기

    Date2015.02.03 Views5734
    Read More
  14. 라디오 바스 체크 유무 확인

    Date2015.02.03 Views6361
    Read More
  15. 버튼 삭제

    Date2015.02.03 Views5965
    Read More
  16. 양력-음력

    Date2015.02.03 Views7716
    Read More
  17. 달력

    Date2015.02.03 Views6692
    Read More
  18. 5초후 자동으로 창닫기

    Date2015.02.03 Views9054
    Read More
  19. 'focus', 엔터 누르고 이동하자!

    Date2015.02.03 Views12868
    Read More
  20. 유효성 검사, 모든 폼에 값이 입력되도록 해보자!

    Date2015.02.03 Views6130
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 13 Next
/ 13

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved