ASP.NET variables

  • Thread starter Thread starter Richard Grene
  • Start date Start date
R

Richard Grene

How can I pass a variable from my vb code to the HTML code in my asp.net
project?

Thanks,
Richard
 
Hi Richard,

To pass variables to the HTML page (I assume you need this for JavaScript?),
you can use the RegisterStartupScript method. (For some reason, it does not
show up in Intellisense.)

Dim JavaScript As String
JavaScript = "<script language=""javascript"">" & VbNewLine
JavaScript &= "myPassedVariable = '" & myVariable & "';" & VbNewLine
JavaScript &= "</script>"
Page.RegisterStartupScript("myScript", JavaScript)

The StartupScript is physically appended to the HTML page. Is this what you
are looking for?

Take care,

Eric
 
Back
Top