简体   繁体   English

对 aspx 页面使用 scriptlet 标签有问题吗?

[英]Is there a problem using scriptlet tags for aspx page?

I have made an aspx page in which much of the content gets generated on the logic that I have written in scriptlet tags.我制作了一个 aspx 页面,其中大部分内容都是根据我在 scriptlet 标记中编写的逻辑生成的。 For eg例如

<%
  foreach(var data in dataCollection)
  { 
    int i=0;
%>
   <div>Enter value : &nbsp; <input id="<%=i %>" type="text" /></div>

<% } %>

like this I have built the whole page based on the logic of how the data is coming from back and how the data is to be appropriately shown on the page.像这样,我根据数据如何从后面来以及数据如何在页面上适当显示的逻辑构建了整个页面。

So, is there an issue with having scriptlets in aspx page?那么,在 aspx 页面中使用 scriptlet 是否存在问题? Is there something like best practice which advises against the use of scriptlets in aspx page?是否有类似最佳实践的建议反对在 aspx 页面中使用 scriptlet?

Thanks Saarthak谢谢萨尔塔克

First of all "scriptlet" is a Java concept, isn't it?首先“scriptlet”是一个Java的概念,不是吗? Every technology has its terminology and one of best practices is call things by their proper name.每种技术都有其术语,最佳实践之一就是以正确的名称称呼事物。

This is inline server code.这是内联服务器代码。

About if there's some issue with that, certainly this isn't the recommended approach for ASP.NET, but for earlier classic ASP like 3.0 which share the name but ASP and ASP.NET are absolutely different things.关于如果有一些问题,当然这不是 ASP.NET 的推荐方法,但对于早期的经典 ASP,如 3.0,它们共享名称,但 ASP 和 ASP.NET 是完全不同的东西。

In ASP.NET, in any page there's a markup code (page declaration, control registration, standard XHTML client-side code and user and custom server controls).在 ASP.NET 中,任何页面都有一个标记代码(页面声明、控件注册、标准 XHTML 客户端代码以及用户和自定义服务器控件)。

Any logic, processing or anything handling client interaction and rendering must be placed in a System.Web.UI.Page derived class, usually called "code-behind" (for example, Default.aspx.cs).任何逻辑、处理或任何处理客户端交互和呈现的东西都必须放在 System.Web.UI.Page 派生的 class 中,通常称为“代码隐藏”(例如 Default.aspx.cs)。

ASP.NET enforces a total separation of markup and client-side scripting from server-side backend. ASP.NET 强制将标记和客户端脚本与服务器端后端完全分离。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM