Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Setting Focus for textbox

Setting Focus for textbox

Scheduled Pinned Locked Moved ASP.NET
javascripthelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sam M
    wrote on last edited by
    #1

    Hi, In my web application am using Samrtnavigation in web.config file

    <pages smartNavigation="true">

    And when i try to set Focus for my text box, like

    TextBox1.Focus()

    it's not working. I've tried javascript and other stuffs. Can any one here to help? Pls

    Regards n Thks Sam.M

    J 1 Reply Last reply
    0
    • S Sam M

      Hi, In my web application am using Samrtnavigation in web.config file

      <pages smartNavigation="true">

      And when i try to set Focus for my text box, like

      TextBox1.Focus()

      it's not working. I've tried javascript and other stuffs. Can any one here to help? Pls

      Regards n Thks Sam.M

      J Offline
      J Offline
      jack_ajay
      wrote on last edited by
      #2

      Hi friend, use this code if u r using javascript or the other if u r using VB.net. Page.RegisterClientScriptBlock("focus", _ "document..focus();") or (VB.NET) Page.RegisterClientScriptBlock("focus", _ "" & _ "document.<id-of-your-control>.focus();" & _ "</id-of-your-control> ")

      S 1 Reply Last reply
      0
      • J jack_ajay

        Hi friend, use this code if u r using javascript or the other if u r using VB.net. Page.RegisterClientScriptBlock("focus", _ "document..focus();") or (VB.NET) Page.RegisterClientScriptBlock("focus", _ "" & _ "document.<id-of-your-control>.focus();" & _ "</id-of-your-control> ")

        S Offline
        S Offline
        Sam M
        wrote on last edited by
        #3

        Sorry friend. This is not working. I've tried. Do u've anyother solution for this?

        Regards n Thks Sam.M

        S 1 Reply Last reply
        0
        • S Sam M

          Sorry friend. This is not working. I've tried. Do u've anyother solution for this?

          Regards n Thks Sam.M

          S Offline
          S Offline
          Sathesh Sakthivel
          wrote on last edited by
          #4

          Try this code:

          [VB.NET]

          Page.RegisterStartupScript("SetFocus", _
          "<script>document.getElementById('" & TextBox1.ClientID & _
          "').focus();</script>")

          [C#]

          Page.RegisterStartupScript("SetFocus", "<script>document.getElementById('" + TextBox1.ClientID + "').focus();</script>");

          SSK. Anyone who says sunshine brings happiness has never danced in the rain.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups