Pass C# Values To Javascript

后端 未结 6 879
感动是毒
感动是毒 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条回答
  •  猫巷女王i
    2020-12-09 22:44

    Your string blah needs to be a public property of your Page class, not a local variable within Page_Load. You need to learn about scoping.

    public class MyPage
    {
        public string blah { get; set; }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            blah = "ER432";
        }
    }
    

提交回复
热议问题