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

HyperLink text property undefined

HI,
I have a HyperLink in my code. It has a OnClick function defined. I am
trying to access the text property of the HyperLink in my JavaScript
function.

<CoreCtrl:Controls.WebControls.HyperLink id="securityCodeLink" text="My

Text" OnClick="ShowText(this);" Href="#" CssClass="textSmall"
runat="server" />

function ShowText(obj)
{
alert(obj.text);
}

I also tried getting a var for the hyperlink with its id and showing
its text. It says 'undefined' instead of 'My Text'. Am I doing
something wrong?

Thanks,
Avanti

Jan 2 '07 #1
3 3696
avanti wrote:
function ShowText(obj)
{
alert(obj.text);
}

I also tried getting a var for the hyperlink with its id and showing
its text. It says 'undefined' instead of 'My Text'. Am I doing
something wrong?
There is no default property called "text" for anchor elements. You
should use innerHTML as follows:

function ShowText(obj) {
alert(obj.innerHTML);
}
Jan 2 '07 #2
Jim
Avanti,
You can determine the text attribute value in this manner:
<a href="#"
text="sometext should go here"
onClick="alert(this.getAttribute('text'))"
>
Show the Text Attribute Value
</a>

Hope that helps,

Jim

Jan 2 '07 #3
Thanks guys for the quick reply. It worked!

Jim wrote:
Avanti,
You can determine the text attribute value in this manner:
<a href="#"
text="sometext should go here"
onClick="alert(this.getAttribute('text'))"
>
Show the Text Attribute Value
</a>

Hope that helps,

Jim
Jan 2 '07 #4

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

Similar topics

9
by: Leigh Kendall | last post by:
I can't find any issue in the MS KB, but I'm experiencing the following problem which seems to be specific to IE5, and NOT any other version of IE 5.5+ or NN 6+. Issue: I'm using an asp.net...
1
by: Mark | last post by:
Ok this is very odd. I have a hyperlink server control (not a linkbutton) on my .aspx page. When the navigateurl property is set to a file (blah.aspx) in the same directory as the current page,...
19
by: Joe | last post by:
I have an aspx page (referred to here as page_1) with a datagrid whose first column contains hyperlinks. When a user clicks one of these hyperlinks, he will navigate to another aspx page (referred...
3
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I...
5
by: Patrick.O.Ige | last post by:
I want to have a rollover image on an hyperlink inside a Repeater control but when i run the page i get "Image1 is undefined" Any ideas? I have a Hyperlink and an Image control in a repeater...
2
by: Keith Wilby | last post by:
I have a personnel database with a hyperlink field which contains the path to a mugshot. I was thinking of combining the hyperlink field with the surname field by putting the surname in the...
3
by: Nathan Sokalski | last post by:
I am using the ImageUrl property of the HyperLink control. My image is large, so I am setting the width/height attributes, but when it renders the width/height attributes are in the <atag rather...
5
LAD
by: LAD | last post by:
Using Access 2003 on Windows 2000. My Skill Level: Med Low (Some VBA, okay with Access) Form: Single View - based on Query of single Table to sort by field. Application: Dealers email 'contract...
1
by: sivasrec | last post by:
Hi, This is sivakumar from India. Now I am learning to ASP.NET 2.0.. I have a doubt.... I have used in a one hidden field control, 2 label controls, 2 button controls and...
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
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.