Create javaScript variable in code behind of asp.net

前端 未结 4 2149
不知归路
不知归路 2020-12-16 19:39

How do I register a Javascript variable on the server side (backend) and access it on the client side (Javascript file), without a hidden field, Literal, etc.?

4条回答
  •  自闭症患者
    2020-12-16 20:09

    You can put a literal in the xml portion of the code and assign that literal some text:

    myLiteral.Text = "";
    

    This makes myVar globally available on the client side once it's rendered. You can also use the ClientScriptManager object to use Asp.Net to inject scripts and variables.

提交回复
热议问题