newbie - variable from code-behind to aspx page

  • Thread starter Damiano Callegari
  • Start date
D

Damiano Callegari

Sorry for the question but I am a newbie of asp.net 2.0.
I have a variable in code behind and I would show it in aspx page (with
<% ... %>).
How can I do it? or what is the best method for print db data in aspx page?

thanks
Damiano
 
K

Karl Seguin

Normally you use controls and set their value programatically in codebehind.

Say

<asp:literal id="Name" runat="server" />

you could then do Name.Text = "SomeValue"

different controls fit different needs..the literal control shown above is
great for basic data.

Karl
 
H

Henrique Mello

well you newbe in general or only in 2.0?

Because i always use a label in the page and in the code behind page i
do label.Text = myDbVar

But you can use simple as Response.Write(myDbVar)

But if there is any special way to do this in 2.0 i dunno.

And also if you new at ASP.NET, you can always use <%%> but in general
there is a better solution for this using ASP.NET code behind.

And also if you new at ASP.NET, you may get confused about compiled
code and WYSIWYG compiled code have CODE BEHIND the other dont
 
H

Henrique Mello

New to 2.0 or to ASP.NET???

I dont know if 2.0 have any new on how to do this but you can always
use
Response.Write(yourVar);
<%%> also works but its a legacy from ASP
 

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
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top