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

Relative url returned in hyperlink field

Hi

In a bound grid view I have the following hyperlink field;

<asp:HyperLinkField
DataNavigateUrlFields="FldDirections"
DataNavigateUrlFormatString="{0}"
HeaderText="Directions"
Target="_blank"
Text="Directions">
<HeaderStyle ForeColor="White" />
</asp:HyperLinkField>

FldDirections is coming from the underlying source and provides a url such
as www.mydomain.com. Problem is clicking on this hyperlink brings the url
relative to were the site is running ie something like
http://localhost/Folder1/Folder2/www.mydomain.com. How can I just get the
value retuned by FldDirections i.e. www.mydomain.com?

Thanks

Regards
Jun 27 '08 #1
4 2309
Is it because you don't have a protocol prefix? Seems like the browser
doesn't figure out it's a domain.

What if you try something like this:

DataNavigateUrlFormatString="http://{0}"

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"John" <in**@nospam.infovis.co.ukwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi

In a bound grid view I have the following hyperlink field;

<asp:HyperLinkField
DataNavigateUrlFields="FldDirections"
DataNavigateUrlFormatString="{0}"
HeaderText="Directions"
Target="_blank"
Text="Directions">
<HeaderStyle ForeColor="White" />
</asp:HyperLinkField>

FldDirections is coming from the underlying source and provides a url such
as www.mydomain.com. Problem is clicking on this hyperlink brings the url
relative to were the site is running ie something like
http://localhost/Folder1/Folder2/www.mydomain.com. How can I just get the
value retuned by FldDirections i.e. www.mydomain.com?

Thanks

Regards
Jun 27 '08 #2
Thanks. Anyway to make it conditional i.e. if FldDirections returns the url
with http:// then it is shown as it is and if without http:// then http://
is appended?

Thanks again

Regards

"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Is it because you don't have a protocol prefix? Seems like the browser
doesn't figure out it's a domain.

What if you try something like this:

DataNavigateUrlFormatString="http://{0}"

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"John" <in**@nospam.infovis.co.ukwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Hi

In a bound grid view I have the following hyperlink field;

<asp:HyperLinkField
DataNavigateUrlFields="FldDirections"
DataNavigateUrlFormatString="{0}"
HeaderText="Directions"
Target="_blank"
Text="Directions">
<HeaderStyle ForeColor="White" />
</asp:HyperLinkField>

FldDirections is coming from the underlying source and provides a url
such as www.mydomain.com. Problem is clicking on this hyperlink brings
the url relative to were the site is running ie something like
http://localhost/Folder1/Folder2/www.mydomain.com. How can I just get the
value retuned by FldDirections i.e. www.mydomain.com?

Thanks

Regards

Jun 27 '08 #3
On Jun 2, 3:29 pm, "John" <i...@nospam.infovis.co.ukwrote:
Thanks. Anyway to make it conditional i.e. if FldDirections returns the url
with http:// then it is shown as it is and if without http:// then http://
is appended?

Thanks again

Regards

"Jonathan Wood" <jw...@softcircuits.comwrote in message

news:%2****************@TK2MSFTNGP03.phx.gbl...
Is it because you don't have a protocol prefix? Seems like the browser
doesn't figure out it's a domain.
What if you try something like this:
DataNavigateUrlFormatString="http://{0}"
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"John" <i...@nospam.infovis.co.ukwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi
In a bound grid view I have the following hyperlink field;
<asp:HyperLinkField
DataNavigateUrlFields="FldDirections"
DataNavigateUrlFormatString="{0}"
HeaderText="Directions"
Target="_blank"
Text="Directions">
<HeaderStyle ForeColor="White" />
</asp:HyperLinkField>
FldDirections is coming from the underlying source and provides a url
such aswww.mydomain.com. Problem is clicking on this hyperlink brings
the url relative to were the site is running ie something like
http://localhost/Folder1/Folder2/www.mydomain.com. How can I just get the
value retuned by FldDirections i.e.www.mydomain.com?
Thanks
Regards
Hi

best way to modify such issue is on itemdatabound event...
in item databound use findcontrol method of item and then re-write the
url property

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #4
Hi
I forget to mention another easy way...
add a public method in your aspx page ...
and pass the item to format the string...

for example in code behind file add a method like this

public string GetFormatedURL(object arg)
{
string args = arg.ToString();

if (args.Contains("http://"))
return args;
else
return "http://" + args;
}

and in aspx page use it like

<asp:TemplateField HeaderText="Url" SortExpression="value">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# GetFormatedURL( Eval("value") ) %>' Target="_blank"
Text='<%# Eval("value") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #5

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

Similar topics

2
by: deko | last post by:
I have a subform in my Access 2002 mdb that holds Hyperlinks to documents (.pdfs) that are associated with each record in the database. The datasheet subform is simply a list of Hyperlinks to...
4
by: Tero Partanen | last post by:
Hello! I'm writing about a rather peculiar problem I'm having with Access2000. I have a table in which I have created one hyperlink-type field. I have given the field a default value which is...
4
by: Salad | last post by:
If I create a field as a hyperlink, Access will open the hyperlink if I single click it. Is there a method within the operating system that would tell access to only open the hyperlink if...
4
by: Andreas Meffert | last post by:
Hello, How can I change the Type of a field in a table from Memo to hyperlink? I import a table from Oracle to Access 2003. After that, the field type of some hyperlink-fields is "Memo". How...
3
by: hermawih | last post by:
Please help . I want to load the contents of another rtf document by double-clicking the words . Chapter1.rtf Chapter2.rtf Chapter3.rtf ....
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...
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
SBCUser666
by: SBCUser666 | last post by:
Form field (Text66) defined as Hyperlink. Access 2003 table field defined as Hyperlink. Using VBA I build the hyperlink and poke it into the form field. The field displays like it is a hyperlink...
3
by: John | last post by:
Hi In a bound grid view I have the following hyperlink field; <asp:HyperLinkField DataNavigateUrlFields="FldDirections" DataNavigateUrlFormatString="{0}" HeaderText="Directions"...
1
by: tomek.romanowski | last post by:
Hi ! I have a problem with defining a relative url, which is one of parameters of window.open call. Here is the situation: 1. "Parent" page called 2000 is in subfolder of my app, the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.