Quick Javascript question

G

Guest

Hello All:

I'm sure that one of you can quickly spot the error in my script. I am
using a small javascript function to retrieve the text of a hyperlink in a
datagrid column.

Here is my script:

function parseHyperlinkId(o) {
alert(o.text);
alert(o.href);
alert(o.target);
return true;
}

using the following Server side code to link the hyperlink's onClick event
to the javascript:

hLink.Attributes.Add("onClick", "return parseHyperlinkId(this);")

o.target returns the hyperlink's target; o.href returns the href; o.text
returns "undefined." Does anyone know which property I should use to
retrieve the hyperlink's text?

TIA,
 
G

Guest

dont think it is...
change this:
function parseHyperlinkId(o) {
alert(o.text);
alert(o.href);
alert(o.target);
return true;
}

to this:

function parseHyperlinkId(url,text) {
alert(url);
alert(text);
return true;
}

and have the onClick like this:
hLink.Attributes.Add("onClick", "return parseHyperlinkId(yourURL,yourText);")
 
G

Guest

Curt,

This doesn't help. I can't pass in yourText if I can't retrieve the
hyperlink's text.

How do I get yourText? Please post the code.

Joe
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
 
G

Guest

The hyuperlinks are contained within the hyperlink column of a datagrid which
is databound to a datatable. They are retrieved from a database, but are
immediately bound to the datagrid, so I do not have directa ccess to them.

Do you know of a way to retrieve the text from a hyperlink after the link
has been created?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
 
P

Phillip Ian

I might be totally off base here, but have you tried o.innerHtml
instead of o.text? Once you're at the browser, we're pretty much back
to basic HTML elements, which don't include the .text property.

For instance, you used .href instead of .NavigateUrl.

Something to try while you wait for the experts to come along and
answer correctly. :)
 
G

Guest

Curt,

In fact I don't have to change anything.

I don't know why others seem to understand my questions and you do not.
Postback was never needed here; the innerText property of the hyperlink is
what I needed.

Unfortunately, both your responses today and your responses yesterday never
really addressed my question. They were either entiredly too vague or
completely off of the mark. I was not asking for architectural
recommendations; I asked a simple question that required a simple answer.

I would like to ask a favor of you. In the future, if you see one of my
posts, please please, please, please, please do NOT respond to my request for
help.

I will very much appreciate your consideration.

Thank you and best of luck to you.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
 
G

Guest

Curt,

I am writing to apologize to both you and the MSDN community for my personal
attack on you in this forum. I take full responsibility for what I wrote and
was wrong to do so. I will make every effort not to repeat my violation of
the rules of conduct and I hope that both you and the members of this
community can and will forgive me.

Regarding my not being "capable of help." The other posts answered my
questions and provided the information that I requested. So I disagree; the
evidence suggests otherwise.

Again, thank you for your time and consideration. I appreciate your
willingness to respect my wish. We clearly do not communicate well.

I wish you all the best.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top