get focus

  • Thread starter Thread starter Michael Murschell
  • Start date Start date
M

Michael Murschell

How do I get a field to have the focus from the VB codebehind side?

If I have an <asp:textbox id=fld1 runat=server>

I want something like

fld1.getFocus()

but that is not it.

What is it?
 
There isn't a server side property you can set on the textbox that gets focus when the page loads. But you can do this using client side Javascript and you can emit the Javascript from the server side codbehind code

(i.e in C# in some handler method
Page.RegisterClientScriptBlock("", "<script language=\"javascript\">document.form.object.focus = true;</script>")

If you know the focus is going to be on the same control everytime the page loads then you can put the javascript directly in your aspx page

HTH
Suresh

----- Michael Murschell wrote: ----

How do I get a field to have the focus from the VB codebehind side

If I have an <asp:textbox id=fld1 runat=server

I want something lik

fld1.getFocus(

but that is not it

What is it
 
Back
Top