如何渲染控件文本的Html输出而不是控制自己 [英] How Do I Render Html Output Of Control Text Rather Than Control Itself

查看:74
本文介绍了如何渲染控件文本的Html输出而不是控制自己的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



如何使用ASP.NET C#获得如下输出,





Hello,

How can i get Output as below using ASP.NET C#,


<asp:Panel ID="Panel_add_ddl_value" CssClass="modalPopup" runat="server" style="display:inherit;">
   <table  align="center">
   <tr>
   <td colspan="2" align="center">
       <asp:Label ID="lbl_add_value_category" runat="server" Font-Bold="true" CssClass="lbl"></asp:Label>
   </td>
   </tr>
   <tr>
    <td align="center" colspan="2">
       &nbsp;
    </td>
    <tr>
    <td>
        <asp:Label ID="lbl_add_value_question" runat="server" Font-Bold="true"></asp:Label>
    </td>
    <td align="center">
        <asp:TextBox ID="txt_ddl_value_add" ToolTip="Enter The Text To Add" runat="server"></asp:TextBox>
    </td>
    </tr>
    <tr>
    <td align="center" colspan="2">
       &nbsp;
    </td>
    </tr>

     <tr>
    <td align="center" colspan="2">
          <asp:Button ID="btn_set_ddl_value" ForeColor="Black" CssClass="yes"

            runat="server" Text="Set" onclick="btn_set_ddl_value_Click"

            ToolTip="Add Only For This Patient."/>
   &nbsp;&nbsp;
        <asp:Button ID="btn_add_ddl_value" ForeColor="Black" CssClass="yes"

            runat="server" Text="Add" onclick="btn_add_ddl_value_Click"

            ToolTip="Add Permanantly Into The List."/>


   &nbsp;&nbsp;
        <asp:Button ID="btn_cancel_ddl_value" ForeColor="Black" CssClass="yes" runat="server"

            Text="Cancel" ToolTip="Cancel" onclick="btn_cancel_ddl_value_Click" />
        </td>
    </tr>
    </table>
    </asp:Panel>










 when i run this code it returns controls like panel,TextBox,label etc in output,
But i want it as a text please tell me how to do this. 
For a reference stack overflow and code project display ASPX design code as a text.

推荐答案

在这些网站中,他们正在编码HTML标记。并在侧面预HTML标签中显示这些编码文本,以便浏览器将其视为文本。如果您不进行编码,则浏览器将呈现为TextBox,Panel等。



例如,您的HTML代码为:

In those sites they are encoding the HTML tags. And display those encoded text in side pre HTML tag, so that browser will consider as text. If you will not do encode then browser will render as TextBox, Panel etc.

For instance, your HTML code is:
<p>This is a paragraph.</p>





编码格式为:



Encoded format will be:

&lt;p&gt;This is a paragraph.&lt;/p&gt;





Step1:

获取HTML标记的编码格式。



请使用以下链接对您的HTML标记进行编码:



http:// www.web2generators.com/html-based-tools/online-html-entities-encoder-and-decoder [ ^ ]



Step2:

请将编码标签放在预标签内。



< pre lang =HTML>& amp; lt; p& ; amp; gt;这是一个段落。& amp; lt; / p& amp; gt;< / pre>



Step1:
Get encoded format of your HTML tag.

Please use below link to encode your HTML tag:

http://www.web2generators.com/html-based-tools/online-html-entities-encoder-and-decoder[^]

Step2:
Please put encoded tags inside pre tag.

<pre lang="HTML">&amp;lt;p&amp;gt;This is a paragraph.&amp;lt;/p&amp;gt;</pre>


这篇关于如何渲染控件文本的Html输出而不是控制自己的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆