I added de code you gave me, but I dont know if I am doing something wrong,
the focus is not being set. This is how my conde looks now:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If (Page.IsClientScriptBlockRegistered("Focus") = False) Then
MyBase.Page.RegisterStartupScript("Focus",
"<scriptlanguage='javascript'>document.getElementB yId('" + txtLinea.ClientID
+ "').focus();</script>")
End If
End Sub
"Ken Dopierala Jr." <> wrote in message
news:uOu6Vz$...
> Hi,
>
> This will do it, just add it to the load event of your User Control:
>
> If (Page.IsClientScriptBlockRegistered("Focus") = False) Then
> MyBase.Page.RegisterStartupScript("Focus", "<script
> language='javascript'>document.getElementById('" + TextBox1.ClientID +
> "').focus();</script>")
> End If
>
> Be sure to use control.ClientID and not just hard code the control id
> because ASP.Net will change the control id inside a User Control to
> somthing
> like "_ctl0_controlid". Good luck! Ken.
>
> --
> Ken Dopierala Jr.
> For great ASP.Net web hosting try:
> http://www.webhost4life.com/default.asp?refid=Spinlight
> If you sign up under me and need help, email me.
>
> "TCORDON" <> wrote in message
> news:OIvr$r$...
>> How can I make a UserControl run some javascript when it loads? this is
>> so
>> the control sets focus to a textbox it contains.
>>
>> TIA!
>>
>>
>
>