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
- (textbox)detailsview.findcontrol("textbox1").focus()
- page.setfocus("textbox1");
- got id of textbox viewing page source , setfocus on that.
- 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
Post a Comment