473,383 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

For ASP .Net display use databind or implicit Response.Write (<%=

For ASP .Net display of a protected value what's better <%# %> (with
DataBinding) or the ASP <%= %>?

Is one more efficent or is there no difference?

Thank you.
Jul 21 '05 #1
5 2241
Hi Siudp,

As for the two expressions you mentioned, they're two different things
which have different usage in asp.net web page.

The <%= %> expression is just dervied from the classic asp, which help to
output content on page(just like the response.Write()). So it is ok to
output a page's protected / public member value via it.

However, the <%# expression... %> is rather different, it's the
databinding expression in asp.net which is used to perform databinding
task. And it is not only used on page but mainly used in many template
databinding controls such as (DataGrid/ DataList)'s template. And the
expressions in the <%# %> will be called when its container control's
"DataBind()" method is called. So if you use the <%# %> on your page, it
will only be called when you call the Page.DataBind() mehtod, then all the
sub control(on the page)'s "DataBind()" will also be called recursively.
For detailed reference on the asp.net databinding expression, you may have
a look at the following msdn doc:

#Data Binding Expression Syntax
http://msdn.microsoft.com/library/en...abindingexpres
sionsyntax.asp?frame=true

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 21 '05 #2
Steven,

Thanks for your reply. I should have been more explicit. I can display a
public or protected variable in ASP .net by using <%# TotalAmount.ToString(
"###,###,##0" ) %> in the ASPX page and calling DataBind(); in the code behind

I am attempting to learn whether or not there is performance or other reason
to instead use <%= TotalAmount %> or is it a draw and merely a matter of
preference.

Thank you

"Steven Cheng[MSFT]" wrote:
Hi Siudp,

As for the two expressions you mentioned, they're two different things
which have different usage in asp.net web page.

The <%= %> expression is just dervied from the classic asp, which help to
output content on page(just like the response.Write()). So it is ok to
output a page's protected / public member value via it.

However, the <%# expression... %> is rather different, it's the
databinding expression in asp.net which is used to perform databinding
task. And it is not only used on page but mainly used in many template
databinding controls such as (DataGrid/ DataList)'s template. And the
expressions in the <%# %> will be called when its container control's
"DataBind()" method is called. So if you use the <%# %> on your page, it
will only be called when you call the Page.DataBind() mehtod, then all the
sub control(on the page)'s "DataBind()" will also be called recursively.
For detailed reference on the asp.net databinding expression, you may have
a look at the following msdn doc:

#Data Binding Expression Syntax
http://msdn.microsoft.com/library/en...abindingexpres
sionsyntax.asp?frame=true

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 21 '05 #3
Hi Siudp,

Thanks for you response. There is not performance concerns on choosing <%=
%> or <%# %>. Just for different scenarios. As you said, you can use both
<%= %> and <%# .. %> + calling Page.DataBind() to do the same thing.
However, this is ok when your page only contains plain HTML and some <%= %>
or <%# %> blocks. If there is other controls on the page which also
contains <%# %> for databinding, calling Page.DataBind will cause all the
sub controls(subcontrol's subcontrols)' DataBind be fired, but this is
sometimes unnecessary.

In addition, <%# %> databinding expression can help bind values onto
asp.net servercontrol's property such as
<asp:Label ... Text='<%# variable or expression %>' ></asp:Label>

but <%= %> can't not, it is only used to output content on the top page
level.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 21 '05 #4
Just the answer for which I was looking. Thanks

"Steven Cheng[MSFT]" wrote:
Hi Siudp,

Thanks for you response. There is not performance concerns on choosing <%=
%> or <%# %>. Just for different scenarios. As you said, you can use both
<%= %> and <%# .. %> + calling Page.DataBind() to do the same thing.
However, this is ok when your page only contains plain HTML and some <%= %>
or <%# %> blocks. If there is other controls on the page which also
contains <%# %> for databinding, calling Page.DataBind will cause all the
sub controls(subcontrol's subcontrols)' DataBind be fired, but this is
sometimes unnecessary.

In addition, <%# %> databinding expression can help bind values onto
asp.net servercontrol's property such as
<asp:Label ... Text='<%# variable or expression %>' ></asp:Label>

but <%= %> can't not, it is only used to output content on the top page
level.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 21 '05 #5
You're welcome. Thanks again for your posting.
Have a good day!

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: dmiller23462 | last post by:
Somebody take a look and give me any suggestions? My brain is nuked... Here's my deal....I have online submission forms on my intranet at work here....I am appending to an Access DB with the...
10
by: Mark J. McGinty | last post by:
As I was working on a project, I noticed something interesting about use of statements such as: dim cn, rs ' variants Set cn = New ADODB.Connection Set rs = New ADODB.Recordset 'cn.Open...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
4
by: Joe Van Meer | last post by:
Hi, Is the datalist meant for one table or can I use it to display information from 2 different tables? Or should I be looking at a datagrid instead? I began my code and kinda ran into a snag...
5
by: Joel Reinford | last post by:
I am attempting to verify whether a datareader is closed by calling the databind on a control. for example (fake code) Dim rdr as SqlDataReader rdr = mycommand.executeReader... ...
2
by: Colin Nicholls | last post by:
Platform: ASP.NET 1.1 I have a repeater nested inside another repeater. My outer repeater is looping fine. I am manually binding the inner repeater to a DataReader obtained from another...
5
by: Mike | last post by:
For ASP .Net display of a protected value what's better <%# %> (with DataBinding) or the ASP <%= %>? Is one more efficent or is there no difference? Thank you.
3
by: AG | last post by:
Below is code (slightly modified and converted to VB) that was provided to me in response to another post. I am using it to demonstrate another problem. In order for paging and other features to...
0
parshupooja
by: parshupooja | last post by:
Contact Reply 1 point Member propoo Joined on 08-31-2007, 10:32 PM Posts 3 Hey all ,
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.