I am helping my daughter build an asp.net website that has an Access database. We are using a DataList with a couple fields inside the ItemTemplate. The one that is giving me trouble is the Hyperlink. The code is below. When the page loads the hyperlink
renders like this:
This problem usually happens because in ASP.NET, if you just import a relate URL, it will follow the local Address URL of the website itself. So I suggest you should save the absolute address URL in the db, and you can just directly do binding:
(your address looks like http://……/abc.aspx)
Is the datatype of the column which the link is stored in a Hyperlink field? If so, change it to a Text field. The Hyperlink field is only for use within Access as an application - not as a database for the backend of a web site.
When you change it to a text field, you will notice the octothorpes (# signs) become visible. Run a query against the table to remove them:
UPDATE MyTable SET MyLinkField = Replace([MyLinkField],"#","");
When you change it to a text field, you will notice the octothorpes (# signs) become visible
I never used hyperlink fields, so this is new to me. So I'm still learning ;-)
So am I. I guessed what was happening from the initial post, but had to create a hyperlink field in an Access database and change it to Text to confirm my theory. So I didn't "know" this for a fact until yesterday...
Member
1 Points
58 Posts
ASP Hyperlink issue
Mar 29, 2011 11:12 PM|Skydolphin2|LINK
Hi all,
I am helping my daughter build an asp.net website that has an Access database. We are using a DataList with a couple fields inside the ItemTemplate. The one that is giving me trouble is the Hyperlink. The code is below. When the page loads the hyperlink renders like this:
<a id="ContentPlaceHolder1_DataList1_lnk_6" href="#http://www.washingtonfaire.com/#" target="_blank">Washington Midsummer Renaissance Faire</a>
But when I click on the link, it tries to navigate to"http://localhost:1852/BOOMPiratesB/Raids.aspx#http://www.washingtonfaire.com/#
What are we doing wrong?
Thanks for any insight.
Rhonda
Participant
1392 Points
374 Posts
Re: ASP Hyperlink issue
Mar 30, 2011 01:06 AM|Binary_Fiddle|LINK
href="#http://www.washingtonfaire.com/#"
The extra "#" at the start of the navigate url is the problem, please check how the link is stored in access data base.
It seems the value in the database is corrupted with an extra #.
This can be beneficial to other community members reading the thread.
Regards,
Amit
Microsoft Certified Technology Specialist (MCTS)
Member
1 Points
58 Posts
Re: ASP Hyperlink issue
Apr 05, 2011 09:34 PM|Skydolphin2|LINK
It doesn't appear to have any #s in the field in the db.
Rhonda
All-Star
94130 Points
18109 Posts
Re: ASP Hyperlink issue
Apr 05, 2011 10:11 PM|Decker Dong - MSFT|LINK
This problem usually happens because in ASP.NET, if you just import a relate URL, it will follow the local Address URL of the website itself. So I suggest you should save the absolute address URL in the db, and you can just directly do binding: (your address looks like http://……/abc.aspx)
All-Star
194428 Points
28074 Posts
Moderator
Re: ASP Hyperlink issue
Apr 06, 2011 10:00 AM|Mikesdotnetting|LINK
Is the datatype of the column which the link is stored in a Hyperlink field? If so, change it to a Text field. The Hyperlink field is only for use within Access as an application - not as a database for the backend of a web site.
When you change it to a text field, you will notice the octothorpes (# signs) become visible. Run a query against the table to remove them:
UPDATE MyTable SET MyLinkField = Replace([MyLinkField],"#","");
All-Star
25756 Points
7014 Posts
Re: ASP Hyperlink issue
Apr 07, 2011 03:21 PM|hans_v|LINK
I never used hyperlink fields, so this is new to me. So I'm still learning ;-)
Note that you should run this query in Access and not in ASP.NET, because the Replace function only works in Access, but not in Jet!
All-Star
194428 Points
28074 Posts
Moderator
Re: ASP Hyperlink issue
Apr 07, 2011 03:50 PM|Mikesdotnetting|LINK
So am I. I guessed what was happening from the initial post, but had to create a hyperlink field in an Access database and change it to Text to confirm my theory. So I didn't "know" this for a fact until yesterday...