code behind again

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?
 
C

Carl Prothman [MVP]

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";
 
W

wei

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top