Public variable in aspx.vb Class no accessible in aspx

I have a variable contained in a quesrystring that I'm successfully retrieving into my aspx.vb code. I want to be able to pick that variable up in the main aspx page for use in javascript. However the aspx page doesn't see ther variable.

I have made sure the variable is declared in the Public Class level and also ensured it's a Public variable As String. So what is going wrong? I have also tried retrieving the querystring directly into the aspx page but this doesn't seem to work either.

The top of my code behind page looks like this:-


    Imports System.Data.SqlClient
    Imports System.Data
    Imports System.Web.DynamicData
    Imports System.Web.UI.WebControls.WebControl

Partial Class Act_Page

Inherits System.Web.UI.Page
Public aname As String

Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    DisplayActInfo()


    aname = Request.QueryString("aname")

apsx page:-

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Act_Page.aspx.vb" Inherits="Act_Page" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <link rel="stylesheet" type="text/css" href="~/TFStyle.css" /> <script type="text/javascript"> var aname2 = <asp:Literal ID="addthis_aname" runat="server"/>; var addthis_config = { "data_track_clickback": true }; var addthis_share = { templates: { twitter: "Check out {{title}} by " + aname2 + " {{url}} (via @TuneFever)" } } </script>

Does anybody here know what I need to change to get, what should be a simple task, to work?

Cheers,

Rob

链接地址: http://www.djcxy.com/p/96472.html

上一篇: 在Chrome中设置XHR中的断点

下一篇: aspx.vb中的公共变量aspx中不可访问的类