473,581 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:M Y_TEXT" type="text"
value="0.00" maxlength="7" id="ucControl_d gGrid__ctl2_MY_ TEXT"
class="MyClass" onchange="Valid ate_It(this);" style="width:55 px;" /></td>

The JavaScript I'm using is:

function Validate_It(obj ){
....<Your validation code ending in failure here>...;
window.alert(ob j.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.getEle mentByName(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.
Sep 15 '05 #1
0 1870

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

Similar topics

3
7400
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
1760
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 happened always whenever DataSource is set, only called sometimes, in a series of setting DataSource, I could get this setting focus only one time ....
1
1602
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> ... <asp:TemplateColumn HeaderText="Name"> ... <FooterTemplate>
12
4880
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; }
0
1735
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 two EE solutions which use javascript to focus on the textbox in the "editcommandcolumn" mode. However, these solutions were made for...
2
1965
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 displaying pages and pages of rows. When I edit some row below pages 1 the post refreshes back to page one, requiring me to page down to do the input.
0
973
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...
0
1420
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 so if I keep pressing tab it will create a new row and focus on the newly created row. Recently I put the same datagrid into an asp.net ajax...
0
1037
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 bold but if the datagrid is long and some elements can only be viewed by scrolling down, it will not go straight to the elements, the user must scroll...
0
7882
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7914
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...
0
8181
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...
0
6564
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...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
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...
1
2309
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
1
1410
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1145
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...

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.