Need Help with System.Web.UI.WebControls.HyperLink

G

Guest

Has anyone worked with the System.Web.UI.WebControls.HyperLink? I am trying
to find examples on how to use it.

What I am trying to do is assign a Hyperlink to a document (i.e. .doc, .pdf,
..txt, etc.) programmatically. I am using VB.net, and ASP.net in VS.net 2003
with Framework 1.1.

Right now, I have a DBGrid on a ASP.net page that displays documents and
checkboxes for each row displayed. If a user checks one or more of these
checkboxes, then I want to assign a Hyperlink containing that URL to each
document selected using VB.net, and paste those Hyperlinks to the clipboard.
The user then can paste these Hypelinks to whatever they wish later (i.e.
Word, email, etc.).

The online documentation with System.Web.UI.WebControls.HyperLink is vague
and I could use a little help.

Thanks,
 
N

Nathan Sokalski

Well, first of all you cannot copy to the clipboard using ASP.NET. If you
want to display HTML code for anchor tags, you would simply use a label and
assign a value to it's text property. However, when doing this, be sure to
use the Server.HtmlEncode() method, otherwise your users will see a
clickable link rather than the code. Here is an example:


Dim anchorcode As String = "<a
href=""http://www.mysite.com/mydocument.pdf"">mydocument.pdf</a>"
Server.HtmlEncode(anchorcode)


Something else you should notice here that is extremely important is the
fact that when assigning a value to anchorcode, I used two double-quotes for
the ones that I want to see in the output code. You will probably want to
use variable values from somewhere to generate anchorcode, but I think you
get the idea (you may even want to write a function to create it). If you
need more help, let me know.
 

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

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top