?
Solved

Setting focus on a textbox contained in a user control

Posted on 2005-04-04
3
Medium Priority
?
231 Views
Last Modified: 2010-04-07
I have a text box (txtSearch) that is part of a user control (Search.ascx), which in turn is part of a master page (Main.aspx). This form (user control) is used to search a database. There are radio buttons to select the type of search, the text box (txtSearch) and drop-downs that act as filters for the search. I need txtSearch to have focus when the page loads (Main.aspx). There are many articles on this subject and it seems like I've tried them all but nothing seems to work. Any ideas would be greatly appreciated!
0
Comment
Question by:jaysch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Expert Comment

by:b1xml2
ID: 13699796
<%@ Page Language="vb" %>
<script language="vb" runat="server">
Sub Page_Load(ByVal sender As Object,ByVal e As EventArgs)
Page.RegisterClientScriptBlock("startup","<script language='javascript'> window.onload = function () { document.getElementById('" & txtFocus.ClientID & "').focus()</script>")
End Sub
</script>
<html>
<body>
<form runat="server">
<asp:TextBox Id="txtFocus" runat="Server" />
</form>
</body>
</html>
0
 
LVL 23

Accepted Solution

by:
b1xml2 earned 1400 total points
ID: 13699803
typo
===
Page.RegisterClientScriptBlock("startup","<script language='javascript'> window.onload = function () { document.getElementById('" & txtFocus.ClientID & "').focus() }</script>")
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question