| |

VerySource

 Forgot password?
 Register
Search
Author: wanderwb

Difference between <% # .....%> and <% = ......%>

[Copy link]

0

Threads

32

Posts

20.00

Credits

Newbie

Rank: 1

Credits
20.00

 China

Post time: 2020-5-22 23:30:01
| Show all posts
I tried it. In fact, # also has the function of =, which means that wherever <% = ......%> appears, it can also be replaced with <% # ......%>, which has the same effect.
Your experiment is wrong
Reply

Use magic Report

0

Threads

11

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-5-23 00:00:01
| Show all posts
# Bind database fields
= Is a public variable in the binding cs file
#Only valid in the context of bound data.
= Is Response.Write
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-9 09:00:02
| Show all posts
<%%> is writing server code in html, but accessing common member variables, for example
a.aspx.cs defines public datatable dt;
In a.aspx.source you can access dt in <%%>
Reply

Use magic Report

0

Threads

5

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-6-12 16:00:02
| Show all posts
So lively
<%%> This kind of thing is inherited from ASP
Now ASP.NET has a # in many places, my point is that it is used in the bound control, the reference to the data source of the bound control
Reply

Use magic Report

0

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 Norway

Post time: 2020-6-12 23:30:01
| Show all posts
<%=......%> = Response.Write()
<%#......%> Data binding only works when running Object.DataBind()
Reply

Use magic Report

0

Threads

9

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-6-27 21:15:01
| Show all posts
<%# %> binding
<%= %> Can be bound to public members in the background
Reply

Use magic Report

0

Threads

8

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-7-1 07:15:02
| Show all posts
ASP used to use =
Reply

Use magic Report

0

Threads

60

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-7-4 13:00:01
| Show all posts
Halo, this problem



<%# %> Bind the writing method, calculate the value when calling the DATABIND() method in the background, and use the value instead of the page to display HTML
<%= %> Run the code on the server side, calculate the value when parsing the page, display HTML, the same reason as the previous ASP server-side code

As can be seen from the above introduction, <%# %>, <%= %> are different concepts, they also run at different times, according to the life cycle of a page, first execute the background CS code, and then parse the ASPX page, you can Know that <%# %> runs before <%= %>

You can verify it with an example
Reply

Use magic Report

0

Threads

12

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-7-5 08:45:01
| Show all posts
Asymooner,3521565said!
<%# %> is used for data binding, but the program can also be executed
<% %> is used to execute server-side running code
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list