Pass variables VB.net to Javascript

0

It is possible if I define my variables in vb.net framework 2 to pass them to a function in javascript, test I have tried this:

<script type="text/javascript">
alert("<%=Rotulo.ID%>");

but I get an error, help friends

    
asked by Pablo Moraga 03.12.2018 в 22:04
source

1 answer

0

In the end what I did was use the following Function:

 Page.ClientScript.RegisterClientScriptBlock(Page.GetType, "initMyClientVariable", String.Format("var variable1 = '{0}'; var variable2 = '{1}'", System.Web.HttpUtility.JavaScriptStringEncode(valorvariable1), valorvariable2), True)

I put this in the load event of the page to set the variables before calling the javascript resource, that's very important.

    
answered by 04.12.2018 в 13:58