473,699 Members | 2,364 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

setting the focus to a textbox in a user control

Hi,

I have a question. I have created a user control which contains a
textbox and a button. we will enter some search word in the textbox and hit
the button. Then we will get a pop-up with the listbox that contains the
matches. Once I select one of the matches, it will close the pop-up and
display the selected one in a label control which is also in the user
control. Everything is working fine. But I am not getting one thing. After
the pop-up is closed by selecting the match, I would like to set the focus
back to the textbox. But I am not knowing how to do that. I wrote javascript
that will set the focus on onLoad event of <body> of the form. It is working
when the form is first displayed. But when we come from the pop-up it is not
setting the focus. I am not knowing where exactly I should set the focus.
Please let me how to do it.

Thanks,
Sridhar.
Feb 10 '06 #1
2 1904
DWS
Srid,

After you set label call the focus method on the textbox.
Good Luck
DWS

"Sridhar" wrote:
Hi,

I have a question. I have created a user control which contains a
textbox and a button. we will enter some search word in the textbox and hit
the button. Then we will get a pop-up with the listbox that contains the
matches. Once I select one of the matches, it will close the pop-up and
display the selected one in a label control which is also in the user
control. Everything is working fine. But I am not getting one thing. After
the pop-up is closed by selecting the match, I would like to set the focus
back to the textbox. But I am not knowing how to do that. I wrote javascript
that will set the focus on onLoad event of <body> of the form. It is working
when the form is first displayed. But when we come from the pop-up it is not
setting the focus. I am not knowing where exactly I should set the focus.
Please let me how to do it.

Thanks,
Sridhar.

Feb 10 '06 #2
Dear Sridhar,

Maybe use this

protected void setFocus( System.Web.UI.C ontrol ctrl )

{

string s = "<SCRIPT language='javas cript'>document .getElementById ('" +
ctrl.ID + "').focus() </SCRIPT>";

this.RegisterSt artupScript( "focus", s );

}

In the on load event

this.setFocus( TextBox1 );

Regards,

Ton



"Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
news:55******** *************** ***********@mic rosoft.com...
Hi,

I have a question. I have created a user control which contains a
textbox and a button. we will enter some search word in the textbox and
hit
the button. Then we will get a pop-up with the listbox that contains the
matches. Once I select one of the matches, it will close the pop-up and
display the selected one in a label control which is also in the user
control. Everything is working fine. But I am not getting one thing. After
the pop-up is closed by selecting the match, I would like to set the focus
back to the textbox. But I am not knowing how to do that. I wrote
javascript
that will set the focus on onLoad event of <body> of the form. It is
working
when the form is first displayed. But when we come from the pop-up it is
not
setting the focus. I am not knowing where exactly I should set the focus.
Please let me how to do it.

Thanks,
Sridhar.

Feb 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7404
by: Jesper Dannemamm | last post by:
Hi I am having trouble setting focus on I tried using this script in the usercontrol's page_load sub to set focus on a textbox with the ID = "user_name": Page.RegisterStartupScript("focus", "<script language=""JavaScript"">document.getElementById.user_name.focus();</script> ")
0
1883
by: ED M. | last post by:
Hello all...I'm new to the board. I have a problem that I hope someone here might be able to solve for me. I am doing some clientside validation using Javascript. The text I am testing is within a textbox that is part of a datagrid. To complicate things, the datagrid is part of a user control. The following code is all part of the user control. The validation part of the script works fine. However, when I try to set the focus...
2
14648
by: Jesper | last post by:
Hi, I'm showing a usercontrol containing a textbox on the screen by clicking a notifyIcon in the taskpane. I use textBox.Focus() to set the focus for the texbox, and I also get a blinking text cursor in the textbox. However. I have to click on the usercontrol before it gets the input so that I can type text in the textbox. I would really much like to be able to wirte in the textbox immediately after clicking the notify icon. I've...
12
4895
by: CLEAR-RCIC | last post by:
Hi, I'm having problems setting focus to a textbox on a web user contol on an asp.net web page. The following script works on normal asp.net pages: <script language="javascript"> function cmdButton1_Clicked() { document.all('txtInput1').focus(); return false; }
4
3948
by: SJ | last post by:
Hi all, I have come across a weird problem when attempting to automatically set the focus in a vb.net form to a checkbox control... In my form I have (on a tab page in a tab control) several textboxes and a checkbox. The behaviour I want from my app is as follows:- When the textbox (which is prior in tab order to the tab control) has been filled with a certain length of text by the user, the focus is
1
2050
by: clickon | last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains a text box, TextBox1 and TextBox2 respectively. If i put the following code in the respective activate event handlers for the two steps, TextBox1.Text ="foo"; and TextBox2.Text = "bar";
1
2513
by: Praveena.Alapati | last post by:
Hi, There is a tab control on a page with multiple tabs and handful of controls in each tab. The way it's rendered in html (like grid etc..) is in table format in tablerows and cells. On clientside, on form validation in javascript, I would like to set focus on to one of the tabs and set the focus to the control on that tab.
5
2037
by: Finn Stampe Mikkelsen | last post by:
Hi How can i set a focus to a textbox in my codebehind page?? I have this WebForm, that takes information from a user and 2 buttons on the form. One that takes action on the entered information and one that resets the form... The second on, the reset button, i would like to set focus back to the first textbox on the form. I already have an onload in my body, which sets the
3
5191
by: jp2express | last post by:
I have several applications that use panels as screens, but I can *not* seem to set the focus for a Textbox. Panel1.BringToFront() Panel1_Textbox.Focus() ' do something with a control on Panel1 Panel2.BringToFront() Panel2_Textbox.Focus() ' do something with a control on Panel2
0
8617
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8884
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.