locked
Storing a hyperlink in the database? RRS feed

  • Question

  • User1943304822 posted

    Hello i was wondaring how can i store a hyperlink in the database?

    or which datatype should i use to store it?

    Wednesday, December 25, 2013 8:09 AM

Answers

  • User-1716253493 posted

    Maybe you can use HyperLinkField to pass id value using query string to get the record containing the text. Set 

    DataNavigateUrlFields = "id" DataNavigateUrlFormatString = "detail.aspx?id={0}"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 25, 2013 8:54 AM
  • User281315223 posted

    Depending on how you actually store the content in the database (ie either store the entire <a> tag in HTML or just the target URL) you'll just need to use either decode the URL (if you encoded it) and output it using a TemplateField. Otherwise, you could simply create a HyperLinkField and map your specific URL that is stored in your database to each of the HyperLinkFields (which would generate the necessary link that your user could use).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 26, 2013 8:41 AM

All replies

  • User-1618234021 posted

    You can store it in simple varchar data type column. when you fetch it, you can form a hyperlink using <a> tag

    Wednesday, December 25, 2013 8:18 AM
  • User281315223 posted

    You shouldn't have to do anything special to store a hyperlink within your database as they are simply strings. So you'll want to use a VARCHAR or TEXT field and you may want to consider making it fairly large (ie VARCHAR(512) or VARCHAR(MAX)) as URLS "can" be quite large although you may not run into any that big.

    You may also want to consider encoding your URL strings prior to storing them in your database and decoding them prior to retrieval.

    Wednesday, December 25, 2013 8:35 AM
  • User1943304822 posted

    Hey thank you for the reply :)!

    what if i wanted to navigate the text i added in the database to a certain page in the website?

    Wednesday, December 25, 2013 8:48 AM
  • User-1716253493 posted

    Maybe you can use HyperLinkField to pass id value using query string to get the record containing the text. Set 

    DataNavigateUrlFields = "id" DataNavigateUrlFormatString = "detail.aspx?id={0}"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 25, 2013 8:54 AM
  • User281315223 posted

    Depending on how you actually store the content in the database (ie either store the entire <a> tag in HTML or just the target URL) you'll just need to use either decode the URL (if you encoded it) and output it using a TemplateField. Otherwise, you could simply create a HyperLinkField and map your specific URL that is stored in your database to each of the HyperLinkFields (which would generate the necessary link that your user could use).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 26, 2013 8:41 AM