how to call a variable in code behind to aspx page

后端 未结 9 1944
暗喜
暗喜 2020-11-27 07:06

i know i have seen this but cant recall the correct way of doing it... basically i have a string variable called \"string clients\" in my .cs file.. but i wasn\'t to be able

9条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 07:22

    In your code behind file, have a public variable

    public partial class _Default : System.Web.UI.Page
    {
        public string clients;
    
        protected void Page_Load(object sender, EventArgs e)
        {
            // your code that at one points sets the variable
            this.clients = "abc";
        }
    }
    

    now in your design code, just assign that to something, like:

    <%= clients %>

    or even a javascript variable

    
    

提交回复
热议问题