473,385 Members | 1,324 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,385 software developers and data experts.

Setting Focus() in a datagrid using Javascript

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 back to the offending textbox, I have problems.

The validation, naturally enough, is called from the 'onchange event'. When
rendered, the text box looks like this:

<td align="Right"><input name="ucControl:dgGrid:_ctl2:MY_TEXT" type="text"
value="0.00" maxlength="7" id="ucControl_dgGrid__ctl2_MY_TEXT"
class="MyClass" onchange="Validate_It(this);" style="width:55px;" /></td>

The JavaScript I'm using is:

function Validate_It(obj){
....<Your validation code ending in failure here>...;
window.alert(obj.id);
obj.focus();
}

This function pops up a messagebox when an error occurs, but does not set
the focus to the offending object. I should note that this coding works fine
outside of a datagrid/user control.

I've tried several other things that I guessed might work, most notably
replacing 'obj.focus()' with:

document.getElementByName(obj.Name).focus();

This not only didn't work, but also returned the browser error:
'Object doesn't support this property or method'

I'm now officially stymied. Is there something about the Datagrid control
that I'm missing here? Or might the problem lay in the fact that his is a
User Control?

Any help would be appreciated.

My thanks in advance,

ED M.
Nov 22 '05 #1
0 960

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

Similar topics

3
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",...
0
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...
0
by: Shravan | last post by:
Hi, I have a Windows Forms Custom DataGrid, which is put in a usercontrol, which on setting DataSource is setting focus to grid. The call stack for setting the focus is as follows. This is not...
1
by: Bonj | last post by:
Hi I've got an ASP.NET datagrid control, and in the footer, there is a series of controls for typing in new values to add an item. e.g. <asp:DataGrid runat="Server".... > <Columns> ......
12
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...
0
by: Luis Esteban Valencia | last post by:
Once a user clicks "add new row", a new row is created in my Datagrid. The datasource is huge so they have to scroll to the bottom of the page to edit the data in the new row. I have come across...
2
by: jason | last post by:
Hello and Good Day. REALLY LOST. Running ASP.NET 1.1 Becuase I think I'm using my own controls smartnavigation does not appear to work for me. Stardard issue: I've got a datagrid thats...
2
by: kenglish_hi | last post by:
hello, I have a form with a datagrid and combo box. When the form loads up, i want the focus to be on the combo box. however, whenever it loads up, the focus is always on the datagrid. in the...
0
by: =?Utf-8?B?R2FyeSBX?= | last post by:
Here is my problem. I have a datagrid that when you click on a row, it goes into edit mode and depending on where I clicked it the focus is on that control using Control.Focus(). I also have code...
0
by: toddw607 | last post by:
I have a datagrid in ASP.NET using VB.NET code which, when loaded it takes a parameter from the URL called DexNumb. When this parameter is brought it, it highlights the entire row Red and makes it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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.