code behind again

  • Thread starter Thread starter wei
  • Start date Start date
W

wei

thank Carl. do you mean there is no good way to reach the same goal as the
Response.Write does in code behind except adding a label on it?
 
wei said:
thank Carl. do you mean there is no good way to reach the same goal
as the Response.Write does in code behind except adding a label on it?

Wei,
Response.Write was the method used in classic ASP.

With ASP.NET, you now read and write to either HTML controls or
Web control's properties. By default, Web controls will already run
server-side. For HTML controls, you can get them to run server-side
by right clicking on the HTML control (in Designer view) and select
"Run As Server Control".
e.g.
In ASPX file
<ASP:LABEL id="Label1" runat="server" />

Then in the code behind file:
protected System.Web.UI.WebControls.Label Label1;
...
Label1.Text = "Hello ASP.NET World";
 
thank you for help!

Carl Prothman said:
Wei,
Response.Write was the method used in classic ASP.

With ASP.NET, you now read and write to either HTML controls or
Web control's properties. By default, Web controls will already run
server-side. For HTML controls, you can get them to run server-side
by right clicking on the HTML control (in Designer view) and select
"Run As Server Control".
e.g.
In ASPX file
<ASP:LABEL id="Label1" runat="server" />

Then in the code behind file:
protected System.Web.UI.WebControls.Label Label1;
...
Label1.Text = "Hello ASP.NET World";

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
 
Back
Top