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

How to get the position of ASP.NET textbox

Does anyone know how to get the top and left positions of an ASP.NET WebControl..? I have an aspx page with controls that when clicked on enters a javascript function that looks like:
Expand|Select|Wrap|Line Numbers
  1.        function ShowPosition(oCtrl)
  2.        {
  3.  
  4.  
  5.           var ctrl = document.getElementById("ctrl_id");
  6.  
  7.           var top = ctrl.style.top;
  8.           var left = ctrl.style.left;
  9.  
  10.           alert(top + ", " + left);
  11.  
  12.        }
  13.  
The asp.net tag that calls the javascript function looks like:
Expand|Select|Wrap|Line Numbers
  1. <asp:textbox id="ctrl_id" runat="server" onclick="ShowPosition(this);"></asp:textbox>
But this doesn't work. Please help.
Sep 5 '07 #1
3 5399
iam_clint
1,208 Expert 1GB
this would need a style position absolute
Sep 5 '07 #2
pbmods
5,821 Expert 4TB
Heya, J Marsh. Welcome to TSDN!

Hopefully, this article will have all the info you need.
Sep 5 '07 #3
acoder
16,027 Expert Mod 8TB
The asp.net tag that calls the javascript function looks like:
Expand|Select|Wrap|Line Numbers
  1. <asp:textbox id="ctrl_id" runat="server" onclick="ShowPosition(this);"></asp:textbox>
One question, if you're passing a reference to the object (this), why not make use of it? Replace ctrl with oCtrl in your Javascript.
Sep 6 '07 #4

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

Similar topics

3
by: jason | last post by:
I've got this javascript routine (i found on google - thank you) in an asp.net page that on page reload sets the cursor of a textbox to the last line. It works great! Using a similar concept, I...
7
by: Steve | last post by:
does any one know a way to determine the position of the cursor in a text box. I would like to position a list next to the current position for context commands. I am using...
0
by: Jed Ozone | last post by:
In a TextBox, I'm using a MouseMove event to track the cursor position. I want to get able to tell what text the current cursor position is at so I can set the SelectionStart to that position. ...
1
by: dale zhang | last post by:
Hi, I have a web form page. it has gridlayout and a table at top like a template. When I have the literal or requiredfieldvalidator ErrorMsg displayed, they are all over the page. Is there...
6
by: Colin McGuire | last post by:
Hello experts, this is a repost but I have been (much) more clear. I want to know the position of the horizontal scrollbar in a textbox as a percentage - if the horizontal scrollbar is hard...
2
by: Agnes | last post by:
In my Textbox, User will input a date e.g "2004-12-06" How can I check the curosr position if the user use mouse or arrow to move the cursor position in the textbox ? e.g "2004-12-06" if user move...
2
by: Dale | last post by:
This seems like it should be simple and I am pretty sure I've done similar things a hundred times before but I sure can't seem to get it right this time. I have a GridView with a column of text...
4
by: Samuel | last post by:
Hi, Is it possible to get absolute position of element with javascript? e.g. I have textbox somewhere in table. Textbox relative to table cell position is 0,0. How can I get Textbox absolute...
4
by: Brandon McCombs | last post by:
Does anyone know of an easy way to set the position of the cursor in a TextBox? If I set text in the box that is longer than the length of the TextBox the position of the cursor is at the very end...
3
by: Enkidu | last post by:
I'm trying to add TextBoxes in a square 'array' into a GroupBox. It looks like I have to, for each TextBox, get the size of the GroupBox, calculate position of each TextBox, set the Location of the...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...
0
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...
0
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...
0
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,...

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.