Thursday, March 29, 2012

newbie - variable from code-behind to aspx page

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
DamianoNormally 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

--
MY ASP.Net tutorials
http://www.openmymind.net/

"Damiano Callegari" <yamne.it@.NOSPAMgmail.com> wrote in message
news:%23geTK9UFGHA.2012@.TK2MSFTNGP14.phx.gbl...
> 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
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
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

0 comments:

Post a Comment