Friday, March 16, 2012

Passing a variable to HTML

Hi,
I'm creating a control that displays the Previous and Next Pages. I get the
values I want but they don't display in the HTML Href tag. It just displays
blank. I declared the 2 variables PageBack and PageNext outside the sub but
that doesn't seem to work.
I tried using a session variable but I had to reload the page twice to get
the correct number.
<%@dotnet.itags.org. Control Language="VB" %>
<script runat="server">
Dim PageBack as String
Dim PageNext as String
Sub Page_Load(sender As Object, e As EventArgs)
Dim strPageName = System.IO.Path.GetFileName(Request.Path)
Dim PageName as String = strPageName
Dim PageNumber As String = Mid(PageName,5,3)
Dim BackPg as String = PageNumber - 1
Dim NextPg as String = PageNumber + 1
PageBack= Left(PageName,4)&"00"&BackPg &".aspx"
PageNext= Left(PageName,4)&"00"&NextPg &".aspx"
End Sub
</script>
<a href="http://links.10026.com/?link=<%# PageBack %>">Back</a><br>
<a href="http://links.10026.com/?link=<%# PageNext %>">Next</a>
Thanks
Message posted via http://www.webservertalk.com<a href="http://links.10026.com/?link='<%# PageBack %>'">Back</a><br>
Thanks. That still gives me an empty Href. I'm doing a response.write to
make sure there's a value in the variable and there is.
Message posted via http://www.webservertalk.com

0 comments:

Post a Comment