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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. set focus in asp.net 1.1 with vb.net

set focus in asp.net 1.1 with vb.net

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelp
5 Posts 3 Posters 6 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.
  • A Offline
    A Offline
    amaneet
    wrote on last edited by
    #1

    Sir, Can i programically set the focus on the textbox.Can i write the code in code behind file in vb.net. PLease Help.

    _ R 2 Replies Last reply
    0
    • A amaneet

      Sir, Can i programically set the focus on the textbox.Can i write the code in code behind file in vb.net. PLease Help.

      _ Offline
      _ Offline
      _AK_
      wrote on last edited by
      #2

      Yes you can you can use javascript to set the focus and yes that javascript you can write in code behind also. Do you want to do it at load of the page or some other time?

      Best Regards, Apurva Kaushal

      A 1 Reply Last reply
      0
      • _ _AK_

        Yes you can you can use javascript to set the focus and yes that javascript you can write in code behind also. Do you want to do it at load of the page or some other time?

        Best Regards, Apurva Kaushal

        A Offline
        A Offline
        amaneet
        wrote on last edited by
        #3

        Sir, At page load .Can u help me by sending some code. Please help.

        _ 1 Reply Last reply
        0
        • A amaneet

          Sir, At page load .Can u help me by sending some code. Please help.

          _ Offline
          _ Offline
          _AK_
          wrote on last edited by
          #4

          this is the codebehind part: string str = ""; str += "function Focu(){"; str += "document.getElementById('TextBox3').focus();}<"; str += "/"; str += "script>"; if(!IsStartupScriptRegistered("Test")) { Page.RegisterStartupScript("Test",str); }</code> And this "Focu" function you have to call in the onload event of the body tag. <div class="ForumSig">Best Regards, Apurva Kaushal</div></x-turndown>

          1 Reply Last reply
          0
          • A amaneet

            Sir, Can i programically set the focus on the textbox.Can i write the code in code behind file in vb.net. PLease Help.

            R Offline
            R Offline
            RaghuSanta
            wrote on last edited by
            #5

            In code behind file include this code. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load setfocus(textboxid,me) End sub Private Sub setFocus(ByVal ctrl As Control, ByVal page As Page) Dim s As String = "document.getElementById('" + ctrl.ID + "').focus() " page.RegisterStartupScript("focus", s) End Sub Regards, Raghu

            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