asp.net - Can't set focus on TextBox inside detailsview -


the detailsview.findcontrol("textbox1") returns me correct textbox want set focus setting focus using of following ways not work

  1. (textbox)detailsview.findcontrol("textbox1").focus()
  2. page.setfocus("textbox1");
  3. got id of textbox viewing page source , setfocus on that.
  4. made sure detailsview in edit/insert mode before focus set.

none of above has worked, stuck.

note - works if detailsview inside panel not working inside tabpanel

instead of

(textbox)detailsview.findcontrol("textbox1").focus(); 

try

scriptmanager.registerstartupscript(this, this.gettype(), "setfocus", "document.getelementbyid('" + (textbox)detailsview.findcontrol("textbox1").clientid + "').focus();", true); 

update

here's approach uses scriptmanager:

textbox textbox = (textbox)detailsview.findcontrol("textbox1"); scriptmanager.getcurrent(this).setfocus(textbox);  

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -