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

Focus Problem

Scheduled Pinned Locked Moved ASP.NET
help
3 Posts 2 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.
  • C Offline
    C Offline
    ccotton333
    wrote on last edited by
    #1

    I am needing some help guys. I have a function that creates a javasript function that will run when the I want it to to set focus on specified objects. I'm using a user control, and the problem is that after the page loads the focus is set to a textbox. that all works fine, but it doesn't set focus where I want it to on PageIndexChanged of one of the 3 grids I have on the usercontrol. The catch is that the first time you do the PageIndexChanged event it doesn't work but the second time you do it it works which I think is kinda weird. Anyways here is the code: Private Function setfocus(ByVal obj As Object) 'this will set focus to a specified object Dim sb As New StringBuilder sb.Append("") sb.Append("function Focus()") sb.Append("{") sb.Append("document.") sb.Append("Form1") sb.Append("['") sb.Append(obj.uniqueid) sb.Append("'].focus();") sb.Append("}") sb.Append("window.onload = Focus;") sb.Append("") Me.Page.RegisterClientScriptBlock("Focus", sb.ToString()) End Function Thanks guys for all your help, Chris Cotton

    W 1 Reply Last reply
    0
    • C ccotton333

      I am needing some help guys. I have a function that creates a javasript function that will run when the I want it to to set focus on specified objects. I'm using a user control, and the problem is that after the page loads the focus is set to a textbox. that all works fine, but it doesn't set focus where I want it to on PageIndexChanged of one of the 3 grids I have on the usercontrol. The catch is that the first time you do the PageIndexChanged event it doesn't work but the second time you do it it works which I think is kinda weird. Anyways here is the code: Private Function setfocus(ByVal obj As Object) 'this will set focus to a specified object Dim sb As New StringBuilder sb.Append("") sb.Append("function Focus()") sb.Append("{") sb.Append("document.") sb.Append("Form1") sb.Append("['") sb.Append(obj.uniqueid) sb.Append("'].focus();") sb.Append("}") sb.Append("window.onload = Focus;") sb.Append("") Me.Page.RegisterClientScriptBlock("Focus", sb.ToString()) End Function Thanks guys for all your help, Chris Cotton

      W Offline
      W Offline
      Wyxlwiis
      wrote on last edited by
      #2

      Have you tried obj.ClientId instead of obj.uniqueid since obj.ClientId is the clientside id provided to the control when rendered The difference is as shown below MyControl_TextBox1 = ClientId = correct MyControl:TextBox1 = uniqueid = wrong :cool:

      C 1 Reply Last reply
      0
      • W Wyxlwiis

        Have you tried obj.ClientId instead of obj.uniqueid since obj.ClientId is the clientside id provided to the control when rendered The difference is as shown below MyControl_TextBox1 = ClientId = correct MyControl:TextBox1 = uniqueid = wrong :cool:

        C Offline
        C Offline
        ccotton333
        wrote on last edited by
        #3

        Hey man I had that working on my other versions of the same sub procedure but the reason i was doing the string instead is because I have multiple grids and on page index changed I need to set focus back to the grid that i changed the page index on. but the problem is this, you can't set focus to a datagrid so i have been trying to create a transparent textbox so that it would be there but they wouldn't realixe they could type in it. the idea i have come up with is to make the forecolor, backcolor and cursor when in the textbox transparent there is a problem though for some reason when all this is set up the cursor and text typed in is still black. I have tried making the textbox invisible but it causes an error so if anyone has any ideas of how to make this type of functionality work like I'm talking about an advice would be greatly appreciated.

        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