473,748 Members | 2,398 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 1914
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
7415
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
1896
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
14656
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
4905
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
3950
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
2062
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
2515
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
2039
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
5193
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
8830
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
9544
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...
0
9372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4606
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
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
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
3
2215
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.