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. Set focus on usercontrol datagrid textbox

Set focus on usercontrol datagrid textbox

Scheduled Pinned Locked Moved ASP.NET
helpquestion
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.
  • A Offline
    A Offline
    asingh70
    wrote on last edited by
    #1

    Hi Guys I have datagrid on usercontrol. Usercontrol i droped on web page. On edit command button click event how can i set focus on my edit text box. Any help appriciated.

    A 1 Reply Last reply
    0
    • A asingh70

      Hi Guys I have datagrid on usercontrol. Usercontrol i droped on web page. On edit command button click event how can i set focus on my edit text box. Any help appriciated.

      A Offline
      A Offline
      Atilla Ozgur
      wrote on last edited by
      #2

      First solution which comes to my mind is via javascript. Create a hidden variable in your page. You can do so with plain html in aspx page or with the help of ASP.NET javascript help functions. this.Page.RegisterHiddenField("myFocusField","myhiddenfield"); this code results in a html below. Now change your code as this. this.Page.RegisterHiddenField("myFocusField",FindName()); private string FindName() FindName function will return unique name of your edit controls. You can take it with this.UniqueID; code piece in your edit control. After that write a startupscript in your aspx page. var vFocText = document.myFocusField.value; var vFoc = document.getElementById("vFocText"); vFoc.focus() Education is no substitute for intelligence. That elusive quality is defined only in part by puzzle-solving ability. It is in the creation of new puzzles reflecting what your senses report that you round out the definition. Frank Herbert

      A 1 Reply Last reply
      0
      • A Atilla Ozgur

        First solution which comes to my mind is via javascript. Create a hidden variable in your page. You can do so with plain html in aspx page or with the help of ASP.NET javascript help functions. this.Page.RegisterHiddenField("myFocusField","myhiddenfield"); this code results in a html below. Now change your code as this. this.Page.RegisterHiddenField("myFocusField",FindName()); private string FindName() FindName function will return unique name of your edit controls. You can take it with this.UniqueID; code piece in your edit control. After that write a startupscript in your aspx page. var vFocText = document.myFocusField.value; var vFoc = document.getElementById("vFocText"); vFoc.focus() Education is no substitute for intelligence. That elusive quality is defined only in part by puzzle-solving ability. It is in the creation of new puzzles reflecting what your senses report that you round out the definition. Frank Herbert

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

        Acually i solved this issue. Any way Thanks a lots for your solution. Here is my solution: On Edit Command public void Edit(object sender,DataGridCommandEventArgs e) { dgNotes.EditItemIndex = e.Item.ItemIndex; BindNoteData(); des.Visible = false; TextBox _txt; _txt = (TextBox) MyDatagridName.Items[e.Item.ItemIndex].Cells[3].FindControl("txtDescreption"); Page.RegisterStartupScript("focus","" + "frm." + _txt.ClientID + ".focus();" + "frm." + _txt.ClientID + ".select();" + "<" + "/script>"); } Note: frm = Form name where i droped usercontrol. Once again thanks lot Atilla Ozgur for your solution. </x-turndown>

        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