Response.Write 或普通 ol'超文本标记语言
考虑到速度(经典 ASP),什么是更好的编码实践:
sPg=sPg& "<select id=""actions"" onchange=""emact(this.value)"">"
sPg=sPg& "<option value=""""></option>"
sPg=sPg& "<option value=""read"">read</option>"
sPg=sPg& "<option value=""unread"">unread</option>"
sPg=sPg& "<option value=""spam"">spam</option>"
sPg=sPg& "<option value=""unspam"">unspam</option>"
sPg=sPg& "<option value=""delete"">delete</option>"
sPg=sPg& "<option value=""undelete"">undelete</option>"
或者
<select id="actions" onchange="emact(this.value)">
<option></option>
<option value="read">read</option>
<option value="unread">unread</option>
<option value="spam">spam</option>
<option value="unspam">unspam</option>
<option value="delete">delete</option>
<option value="undelete">undelete</option>
这样想,但是规模更大(在线商店后端几乎完全以这种方式编写,正在开发新版本)-我将把它全部转换为简单的每次管理HTML而不是response.write,但我只是想知道这样做,我不是在给自己挖坑。
What is better coding practice, with speed in mind (Classic ASP):
sPg=sPg& "<select id=""actions"" onchange=""emact(this.value)"">"
sPg=sPg& "<option value=""""></option>"
sPg=sPg& "<option value=""read"">read</option>"
sPg=sPg& "<option value=""unread"">unread</option>"
sPg=sPg& "<option value=""spam"">spam</option>"
sPg=sPg& "<option value=""unspam"">unspam</option>"
sPg=sPg& "<option value=""delete"">delete</option>"
sPg=sPg& "<option value=""undelete"">undelete</option>"
OR
<select id="actions" onchange="emact(this.value)">
<option></option>
<option value="read">read</option>
<option value="unread">unread</option>
<option value="spam">spam</option>
<option value="unspam">unspam</option>
<option value="delete">delete</option>
<option value="undelete">undelete</option>
think this, but on a way larger scale (online store backend written this way almost completely, working on a new version) - I am going convert it all to easy to manage HTML instead of response.write each time, but I just want to know the by doing that, I am not digging myself a hole.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果你要重写,为什么要使用 10 年前的技术?
(使用第二个。)
If you are re-writing why are you going to use 10 year old technology?
(Use the 2nd one.)
这就是我会做的。
绝对没有充分的理由通过字符串连接来创建整个 HTML 结构,并且通过更改为直接 HTML 可以获得一些性能。
它也更易于维护,因为您不必担心转义引号并确保字符串正确连接。
That's what I would do.
There is absolutely no good reason to go with creating the whole HTML structure through string concatenation, and you will gain a bit of performance by changing to straight HTML.
It would also be more maintainable, as you won't have to worry about escaping quotes and making sure your strings are properly concatenated.
在 HTML 上使用 Response.Write 的论点是否与在直接 SQL 查询上参数化 SQL 语句的论点相同?意思是,堵住一些可能注入的漏洞?
Wouldn't the argument for using Response.Write over HTML be the same one for parameterizing SQL statements over straight SQL queries? Meaning, to close a few loopholes for possible injection?