how to call a variable in code behind to aspx page

后端 未结 9 1916
暗喜
暗喜 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:35

    The HelloFromCsharp.aspx look like this

     <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HelloFromCsharp.aspx.cs" Inherits="Test.HelloFromCsharp" %>
    
    
    
    
    
        
    
    
        

    <%= clients%>

    And the HelloFromCsharp.aspx.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace Test
    {
        public partial class HelloFromCsharp : System.Web.UI.Page
        {
            public string clients;
            protected void Page_Load(object sender, EventArgs e)
            {
                clients = "Hello From C#";
            }
        }
    }
    

提交回复
热议问题