Pass C# Values To Javascript

后端 未结 6 880
感动是毒
感动是毒 2020-12-09 22:00

On loading the page I want to pass a value to my javascript function from a server side variable.

I cannot seem to get it to work this is what I have:

Asp.Ne

6条回答
  •  情书的邮戳
    2020-12-09 22:43

    I believe your C# variable must be a class member in order to this. Try declaring it at the class level instead of a local variable of Page_Load(). It obviously loses scope once page_load is finished.

    public partial class Example : System.Web.UI.Page
    {
        protected string blah;
    
        protected void Page_Load(object sender, EventArgs e)
        {
            blah = "ER432";
            //....
    

提交回复
热议问题