Creating a Embedded HyperLink Function

G

Guest

I would like to create a VB.net function, that builds a dynamic hyperlink
using System.Web.UI.WebControls.HyperLink, but I can not find any examples on
how to generate a dynamic hyperlink. Has anyone done this before?

I do not want to dynamically create my hyperlink on an ASP page, but rather
a behind the scenes link that a user can paste into a Word document or Email,
as an embedded link that points to a particular file. This would be similar
to what you might see in the result set of a help context search.

For example, the link might be something like:
http://www.someDomain.com/SomeFile.aspx?fileID=12345
where fileID=12345 (TestFile.doc) is the reference to the File ID on my
database table, and the embedded link name is called "File Name" with the
above URL as the link.

This function will capture the File ID and create this link dynamically when
the user selects the file they want to embed. This user then can paste this
into a Word document or Email seeing only the "File Name". Whoever clicks
that "File Name" will be directed to that page, and open up that File with
the correct program the document is formated in (i.e. Word, Adobe, Excel,
etc.).

This is what I think the function should look like:


Public Function CreateEmbeddedHyperlink(ByVal fileID As Integer, ByVal
fileName As String) As Object

Dim embeddedHyperLink As New System.Web.UI.WebControls.HyperLink

embeddedHyperLink.NavigateUrl =
"http://www.someDomain.com/SomeFile.aspx?fileID=" & fileID
embeddedHyperLink.Text = fileName

Return embeddedHyperLink

End Function
 
G

Guest

SAL,
Your on the right track but your function will return a string that can be
pasted into the email. Sometimes its better to use the built in controls and
sometimes I can just render html on the fly. I'm rendering html on the fly
here. You just have to work on pasting the string returned from the function
into the email.

Public Function CreateEmbeddedHyperlink(ByVal fileID As Integer, ByVal
fileName As String) As string
dim x as string
x = "<a href=http://www.somedomain.com/somefile.aspx?fileid="
x+=fileid
x+=">"
x+=filename
x+="</a>
return x
end function

Good Luck
DWS
 
G

Guest

Thanks DWS,

So, it's better to return a HTML string rather than the Oject?

Thanks,

Sal
 

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

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,252
Latest member
MeredithPl

Latest Threads

Top