4
Reply

How you can access fields & properties defined in code behind in ASPX page?

Rahul Singh

Rahul Singh

9y
2.2k
0
Reply

    Thanks

    Suppose we have field `Id` & property `Name` defined in code behind calss we can access them in ASPX page like this:- Id: <%= Id% > Name: <%= Name %>

    if we have Salary field in Aspx.cs Int Salary=1000; then we can use Salary in aspx page like as Sal:<%=Salary%>

    define your property as public or protected in code behind file.using server side syntax you can use that in aspx filepublic string CodeBehindVarProperty{get{return "Property Variable";} }protected void Page_Load(object sender, EventArgs e){// Bind data from code-behind to ASPX server controlsPage.DataBind();}in aspx<%=CodeBehindVarPublic %>