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. Textbox Focus Problem

Textbox Focus Problem

Scheduled Pinned Locked Moved ASP.NET
helpjavajavascriptquestion
6 Posts 4 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.
  • H Offline
    H Offline
    Hemalatha A M
    wrote on last edited by
    #1

    Hi, Am having textbox in Gridview.I need to set the focus(i.e. the cursor should place inside textbox) when add link button is clicked. For this i have used java scipt. function Click_Enter(CID,event) { var key; key=(event.which) ? event.which : event.keyCode; if(key==13) { document.getElementById(CID).focus(); } return true; } And in code behind of link button click event ImageButton ibtnSave = (ImageButton)gvBillingType.FooterRow.FindControl("ibtnSave"); TextBox txtAddcontrol = (TextBox)gvBillingType.FooterRow.FindControl("txtFooterBillingType"); Page.RegisterStartupScript("SetFocus", "document.getElementById('" + txtAddcontrol.ClientID + "').focus();"); txtAddcontrol.Attributes.Add("onkeydown", "javascript : return Click_Enter('" + ibtnSave.ClientID + "',event);"); this code is Wkg in Mozila.. but in IE it is not WKG.. Pls anyone help me fast.

    J M 2 Replies Last reply
    0
    • H Hemalatha A M

      Hi, Am having textbox in Gridview.I need to set the focus(i.e. the cursor should place inside textbox) when add link button is clicked. For this i have used java scipt. function Click_Enter(CID,event) { var key; key=(event.which) ? event.which : event.keyCode; if(key==13) { document.getElementById(CID).focus(); } return true; } And in code behind of link button click event ImageButton ibtnSave = (ImageButton)gvBillingType.FooterRow.FindControl("ibtnSave"); TextBox txtAddcontrol = (TextBox)gvBillingType.FooterRow.FindControl("txtFooterBillingType"); Page.RegisterStartupScript("SetFocus", "document.getElementById('" + txtAddcontrol.ClientID + "').focus();"); txtAddcontrol.Attributes.Add("onkeydown", "javascript : return Click_Enter('" + ibtnSave.ClientID + "',event);"); this code is Wkg in Mozila.. but in IE it is not WKG.. Pls anyone help me fast.

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

      Hai, I don't know about it.

      1 Reply Last reply
      0
      • H Hemalatha A M

        Hi, Am having textbox in Gridview.I need to set the focus(i.e. the cursor should place inside textbox) when add link button is clicked. For this i have used java scipt. function Click_Enter(CID,event) { var key; key=(event.which) ? event.which : event.keyCode; if(key==13) { document.getElementById(CID).focus(); } return true; } And in code behind of link button click event ImageButton ibtnSave = (ImageButton)gvBillingType.FooterRow.FindControl("ibtnSave"); TextBox txtAddcontrol = (TextBox)gvBillingType.FooterRow.FindControl("txtFooterBillingType"); Page.RegisterStartupScript("SetFocus", "document.getElementById('" + txtAddcontrol.ClientID + "').focus();"); txtAddcontrol.Attributes.Add("onkeydown", "javascript : return Click_Enter('" + ibtnSave.ClientID + "',event);"); this code is Wkg in Mozila.. but in IE it is not WKG.. Pls anyone help me fast.

        M Offline
        M Offline
        Murugesan G
        wrote on last edited by
        #3

        I don't think problem with browser but ur code checks KeyCode and which won't work if u use mouse to click.

        H 1 Reply Last reply
        0
        • M Murugesan G

          I don't think problem with browser but ur code checks KeyCode and which won't work if u use mouse to click.

          H Offline
          H Offline
          Hemalatha A M
          wrote on last edited by
          #4

          Then what is the solution for this problem.. I have tried hardly for this.. The cursor alone is not placing inside textbox.. But all the other work like after entering any text and press enter it is getting save in gridview... This problem is occuring only in IE

          C 1 Reply Last reply
          0
          • H Hemalatha A M

            Then what is the solution for this problem.. I have tried hardly for this.. The cursor alone is not placing inside textbox.. But all the other work like after entering any text and press enter it is getting save in gridview... This problem is occuring only in IE

            C Offline
            C Offline
            codingrocks
            wrote on last edited by
            #5

            txtAddcontrol.Attributes.Add("onkeypress", "javascript : return Click_Enter('" + ibtnSave.ClientID + "',event);"); try this...Hope it should be KeyPress event....

            CodingRocks ASP.NET,C#.NET Programmer BANGALORE "Winners don't do different things. They do things differently. ...

            H 1 Reply Last reply
            0
            • C codingrocks

              txtAddcontrol.Attributes.Add("onkeypress", "javascript : return Click_Enter('" + ibtnSave.ClientID + "',event);"); try this...Hope it should be KeyPress event....

              CodingRocks ASP.NET,C#.NET Programmer BANGALORE "Winners don't do different things. They do things differently. ...

              H Offline
              H Offline
              Hemalatha A M
              wrote on last edited by
              #6

              Hi... I tried but it is not wkg

              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