简体   繁体   English

在网页Asp.Net中查找/替换文本

[英]Find/Replace Text in WebPage Asp.Net

I've created several .aspx templates that are displayed in an IFrame depending on main page selections. 我已经创建了几个.aspx模板,这些模板将根据主页选择显示在IFrame中。 In the templates there are 20 - 30 words to be replaced, each one is different. 在模板中,有20-30个单词要替换,每个单词都不同。 I did this as opposed to putting a bunch of labels in there. 我这样做是与在其中放置一堆标签相反。 Can I somehow find and replace the words on the template page load? 我能以某种方式找到并替换模板页面加载中的单词吗?

I would place the content in a label or literal control, and then perform a string.replace. 我会将内容放置在标签或文字控件中,然后执行string.replace。 If you need more programmatic flexibility, you can use regex replacement, but you will get better performance from string.replace, even with very large strings. 如果需要更大的编程灵活性,则可以使用正则表达式替换,但是即使使用非常大的字符串,也可以通过string.replace获得更好的性能。 I can't find a cite, but that is my experience. 我找不到引用,但这就是我的经验。

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

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