简体   繁体   English

从ASP.NET中HTML标记中的属性检索值

[英]Retrieve value from attribute in HTML tag in asp.NET

I have a large string containing a custom HTML tag (xxx). 我有一个包含自定义HTML标签(xxx)的大字符串。 The tag also has two attributes. 标签还具有两个属性。

How would I retrieve the value of the two attributes and then place the tag and its content with a new string derived from those two attributes? 我将如何检索这两个属性的值,然后将标记及其内容放入从这两个属性派生的新字符串?

Thanks for your time. 谢谢你的时间。

Where do you want to retrieve it? 您想在哪里找回它? In the code behind? 在后面的代码?

If your tag is runat="server", you can do: 如果您的标签是runat =“ server”,则可以执行以下操作:

mytag.Attributes["nameofmyattribute"]

If its in string then you should consider using HTML Agility Pack . 如果它是字符串,则应考虑使用HTML Agility Pack However it may be overkill so show us some sample string... maybe only some RegEx can do it. 但是,这可能有些矫kill过正,所以请向我们显示一些示例字符串...也许只有某些RegEx可以做到。

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

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