By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,473 Members | 3,505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,473 IT Pros & Developers. It's quick & easy.

Creating a Embedded HyperLink Function

P: n/a
SAL
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
Feb 6 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
DWS
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

"SAL" wrote:
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

Feb 7 '06 #2

P: n/a
SAL
Thanks DWS,

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

Thanks,

Sal

"DWS" wrote:
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

"SAL" wrote:
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

Feb 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.