Hello, I create and fill a variable in the Page_Load sub and then i need it in a javascript code. Of course the xxx variable is declared in the sub so that it is not available out of the sub. How can i fill the javascript variable with its content? Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Dim [B]xxx [/B]As String = "xxx" End Sub <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>PR</title> <script type="text/javascript" language="javascript"> var xxx = <%=[B]xxx[/B]%> Code (markup): Thx in advance
declare it at module level ie right at the top of the class, then it will have scope throughout the module (the m_ prefix is used here as good practice to indicate a module level variable) Partial Class imagegallery Inherits System.Web.UI.Page Private m_xxxx As String Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) m_xxx = "xxx" End Sub <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>PR</title> <script type="text/javascript" language="javascript"> var xxx = <%=m_xxx%>