Try our conversational search powered by Generative AI!

Setting focus on a textbox

It’s all beginning to feel like a joke… All I want to do is to put the cursor, nice and blinking, in a textbox by default when a user enters the page. I know you have to make a javascript for it, since we’re talking about a server-side executed webpage. So I did, and this short code did the trick (called from Page_Load) – in Internet Explorer, but NOT in Firefox: protected void FocusToInput(TextBox textbox) { if (!Page.IsClientScriptBlockRegistered("FocusToInput")) { Page.RegisterStartupScript("FocusToInput", ""); } } Then, in search of an answer, I read something about Firefox and that it uses the w3c dom, not the IE proprietary dom (.all collection). Therefore I used the example brought with that comment, which looks the following: And I also tried it from codebehind, like the semi-working code above. But neither of them works. There’re no errors, but it doesn’t work anyway. BUT, the interesting part is that I tried the code (the one with the
Feb 21, 2007 16:55
Forgot to add: I'm using .NET Framework 1.1, so the (maybe?) simple .NET 2.0-solution with "this.TextBox2.Focus();" doesn't work. ;-)
Feb 21, 2007 17:04
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.