473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

focus Controls

Hi All,

I have a web based application and i want to have focus on a text box on click of a button i have been trying the below solution but unfortunately its working in my test application but not in my orignal application. please let me know any solution other than this.


Expand|Select|Wrap|Line Numbers
  1. private void SetFocus(String ctrlID)
  2. {
  3. // Build the JavaScript String
  4. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  5. sb.Append("<script language='javascript'>");
  6. sb.Append("document.getElementById('");
  7. sb.Append(ctrlID);
  8. sb.Append("').focus()");
  9. sb.Append("</script>");
  10.  
  11. // Register the script code with the page.
  12. Page.RegisterStartupScript("FocusScript", sb.ToString());
  13. }
and calling this function when needed...
Please help me out.....
Jul 12 '07 #1
0 1148

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jason | last post by:
I have created a c-sharp app that has keyup, keydown events tied to the form. The form also has some other controls, buttons, labels and 1 custom control that I made which inherits from user...
0
by: Miquel | last post by:
Hi all. I felt frustrated when developing an 'UserControl' derivated from textBox, because sequence event (and Validate event) seems to fail. I Always thought my code was wrong. But after...
2
by: chris | last post by:
Does anybody know how I can programmatically cause a textbox to lose focus and automatically jump to the next appropriate control. I have a custom textbox usercontrol whereby the requirement is...
4
by: PK9 | last post by:
I have a button at the top of my page that I have an onClick event handler for which makes some new controls (at the bottom of my page) visible. When the user clicks the button I make the new...
8
by: copyco | last post by:
I want to be able to test if my app's form has focus, (ie: not in background, behind other windows). How can I do this? I tried the Me.Focused, but that doesn't work. I think it's because a...
1
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...
7
by: Pygmalion | last post by:
Hello experts, I want to use Form_Keydown event in my program. However, it turns out that one of the form controls is always in focus, so Form_Keydown event is never invoked. I tried to set...
6
by: =?Utf-8?B?U2NvdHQgTGFt?= | last post by:
Hi, I have a VB.NET form with a bunch of controls in it . The focus is in one of the controls , (i.e. a textbox), is there any way to click on the form itself and make the textbox lose focus and...
4
by: Rafael A. M. Borges | last post by:
Hi, How can I set the focus on the first control in the page? I tried Page.Controls(0).Focus() but it didn't works. Does anyone knows it?
5
by: Matt B | last post by:
I know this is a bit of nonstandard behavior, but I would like the Enter key to move focus through a group of radiobuttons without selecting them. The user would then have to use Space or actually...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.