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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top