You can, but you'll have to do it a bit differently. In your default.aspx.cs, add a member:
protected MyObject _myObject;
Then, in Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
_myObject = new MyObject();
}
Then, in default.aspx, you can do:
<%= _myObject.SomePropertyOfThisObject %>
Of course, this assumes that class MyObject has a property named Awesome. You didn't mean the System.Object class, did you, since it doesn't have a property named Awesome.
Since your question was asking about the best way, I'll go further. The way I showed is not the best. The best is more often to use a data binding expression. If you don't like those, then you can set things in the codebehind:
protected void Page_Load(object sender, EventArgs e)
{
_myObject = new MyObject();
//
_myLabel.Text = _myObject.SomePropertyOfThisObject;
}
Assuming:
<asp:Label runat="server" id="_myLabel" />
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…