Friday, March 16, 2012

Passing a variable to HTML tag

Hi,

I'm creating a control to get the next and back page name. When I try to pass that name to the href tag in the HTML, the link is empty and I'm not sure what's wrong. I've checked the values with response.write so I know that the values are there. I've also defined the PageBack and PageNext variables outside the sub.


<%@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 PageNumStart as Integer = strPageName.Indexof("P") +2
Dim PageNumEnd as Integer = strPageName.Indexof(".")+1
Dim PageNum as String = Mid(strPageName,PageNumStart,PageNumEnd-PageNumStart)
PageBack=Left(strPageName,PageNumStart-1)&PageNum-1 &".aspx"
PageNext=Left(strPageName,PageNumStart-1)&PageNum+1 &".aspx"
End Sub

</script>
Back<br>
Next

I've also tried the href with just the double quotes: ="<%# PageBack %>"
ThanksYou need to call DataBind() at the end of your Page_Load.
Thanks so much. I normally do but forgot it here.

0 comments:

Post a Comment