A. JQuery always run on a client side. It has nothing to do with C# or
VB.NET. So no wonder that compiler gives you an error it simply does
not know what $(...) is.
B. You need to add to your page
<script>
 $('input#<%=tbLogin.ClientId%>).focus();
</script>
The actuall ID of the tbLogin might be different ASP.NET generates
them to make sure the ID of the control on the page is unique.

C. For something that simple you can use tbLogin.Focus(); on a server
side. You do not need JQuery

George.


On Nov 22, 1:41 pm, lszk <[EMAIL PROTECTED]> wrote:
> I have a code in asp.net:
>
> <body>
>    <form id="form1" runat="server">
>    <div id="container">
>        <div id="login">
>            <div class="window">
>                <table>
>                    <tr>
>                        <td>
>                            Login:
>                        </td>
>                        <td>
>                            <asp:TextBox ID="tbLogin" runat="server"></
> asp:TextBox>
>                            <asp:RequiredFieldValidator ID="rfvLogin"
> runat="server"
>                                ControlToValidate="tbLogin"
> ErrorMessage="Musisz podać login"></asp:RequiredFieldValidator>
>                        </td>
>                    </tr>
> etc.
>
> I'm using firebug, and now I want to set focus on tbLogin. When I open
> it on the server and I write $('input#tbLogin').focus();
> I have a error:>>> $('input#tbLogin').focus();
>
> TypeError: $("input#tbLogin") is undefined login.aspx (line 65)
>
> but when I save a generated html and open this saved file, it works
> fine.>>> $('input#tbLogin').focus();
>
> Object length=1
>
> Where I made a mistake?

Reply via email to