Answered by:
Variable from aspx.vb to html

Question
-
User-1336605834 posted
Hi,
I have a aspx.vb page with a simple DB Query. The Result is stored in a string variable.
I´m able to Show the value in a textarea in my aspx page but i like to use the variable in a separate html page and in a separate .js page.
How can I do this?
thx
Tuesday, September 29, 2015 10:38 AM
Answers
-
User37182867 posted
For a separate aspx page you can use a session value
session("myValue") = myVariable
i like to use the variable in a separate html page
for a HTML page you would need to write something to bring the value in via query string and process it via javascript maybe... or open the html file in a stream writer and write the value into the html directly.. (This is a lot of work for transferring a value to raw HTML page... probably not what you want)
and in a separate .js page.
If you are wanting to use it in javascript then just assign the value to a hidden field control and access it in javascript by pulling value from the hidden control- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, September 29, 2015 11:18 AM -
User-821857111 posted
There's no such thing as a .js page. Also, HTML doesn't support "variables". What you could do is use AJAX (jQuery is easiest) to get the value from your database for display in an HTML file: http://www.mikesdotnetting.com/article/104/many-ways-to-communicate-with-your-database-using-jquery-ajax-and-asp-net
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, September 29, 2015 11:21 AM
All replies
-
User37182867 posted
For a separate aspx page you can use a session value
session("myValue") = myVariable
i like to use the variable in a separate html page
for a HTML page you would need to write something to bring the value in via query string and process it via javascript maybe... or open the html file in a stream writer and write the value into the html directly.. (This is a lot of work for transferring a value to raw HTML page... probably not what you want)
and in a separate .js page.
If you are wanting to use it in javascript then just assign the value to a hidden field control and access it in javascript by pulling value from the hidden control- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, September 29, 2015 11:18 AM -
User-821857111 posted
There's no such thing as a .js page. Also, HTML doesn't support "variables". What you could do is use AJAX (jQuery is easiest) to get the value from your database for display in an HTML file: http://www.mikesdotnetting.com/article/104/many-ways-to-communicate-with-your-database-using-jquery-ajax-and-asp-net
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, September 29, 2015 11:21 AM