vb.net passing variable from .aspx.vb to .aspx javascript variable
How do I pass a variable defined in .aspx.vb to .aspx.
I've tried this in the .aspx.vb:
Partial Class show_zoos
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'database logic
Dim postcode As String = an.Postcode
End Sub
End class
And this for priting it out in the .aspx:
var postcode = '<%=postcode%>'
I got the following error:
'postcode' i开发者_高级运维s not declared. It may be inaccessible due to its protection level.
What am I doing wrong?
postcode needs to be min visibility Protected.
Public postcode As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
postcode = "ABCD"
End Sub
精彩评论