Interviews4 answers
How you can access fields & properties defined in code behind in ASPX page?
4 Answers
Thanks
Venkataramana murthyPosted Sep 14, 2016, 5:33 AM EDT
if we have Salary field in Aspx.cs
Int Salary=1000;
then we can use Salary in aspx page like as
Sal:<%=Salary%>
Pankaj Kumar ChoudharyPosted May 14, 2015, 8:50 AM EDT
define your property as public or protected in code behind file.using server side syntax you can use that in aspx file
public string CodeBehindVarProperty
{
get
{
return "Property Variable";
} }
protected void Page_Load(object sender, EventArgs e)
{
// Bind data from code-behind to ASPX server controls
Page.DataBind();
}
in aspx
<%=CodeBehindVarPublic %>
keyurPosted Feb 9, 2015, 8:21 PM EST
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 %>
Rahul SinghPosted Dec 23, 2014, 8:27 PM EST

