我在aspx.vb后面有一个变量。
我想在.aspx网页上使用它。
例如
Public Class proventos_rendimento_distribuicoes_amortizacoes
Inherits System.Web.UI.Page
Dim id_to_use As String = ""
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
lblCustomerId.Text = Me.Page.RouteData.Values("nome_artigo").ToString()
id_to_use = Me.Page.RouteData.Values("nome_artigo").ToString()
End If
End Sub
End Class
我想在.aspx上使用<%= id_to_use%>
例如
<b>Customer Id:</b>
<asp:Label ID="lblCustomerId" runat="server" />
<br />
<b><%= id_to_use %></b>
但这不起作用。
有可能做到吗?
答案 0 :(得分:0)
只需向公共声明Dim id_to_use As String =“”:
public Dim id_to_use As String = ""
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
lblCustomerId.Text = Me.Page.RouteData.Values("nome_artigo").ToString()
id_to_use = Me.Page.RouteData.Values("nome_artigo").ToString()
End If
End Sub