如何在我的视图页面中使用html解码?

时间:2012-07-30 13:54:44

标签: asp.net html c#-3.0 html-encode

我的引擎是Aspx。

我目前无法在我的表格中编辑其中一个列(问题解答),因为它中包含html标记。有没有办法只能解码值区域中的特定行/列?

<form id="updateFreqQuestionsUser" action="<%=Url.Action("SaveFreqQuestionsUser","Prod")%>" method="post">
<table> 
    <tr>
        <td colspan="3" class="tableHeader">Freq Questions User Details <input type ="hidden" value="<%=freqQuestionsUser.freqQuestionsUserId%>" name="freqQuestionsUserId"/> </td>
    </tr>
     <tr>
        <td colspan="2" class="label">Question Description:</td>
        <td class="content">
            <input type="text" maxlength="2000" name="QuestionDescription" value="<%=freqQuestionsUser.questionDescription%>" />
        </td>
    </tr>
     <tr>
        <td colspan="2" class="label">QuestionAnswer:</td>
        <td class="content">
            <input type="text" maxlength="2000" name="QuestionAnswer" value="<%=freqQuestionsUser.questionAnswer%>" />
        </td>
    </tr>
    <tr>
        <td colspan="3" class="tableFooter">
                <br />
                <a id="freqQuestionsUserUpdateButton" href="#" class="regularButton">Save</a>
                <a href="javascript:history.back()" class="regularButton">Cancel</a>
        </td> 
    </tr>
</table>

1 个答案:

答案 0 :(得分:1)

是的,你可以这样做:

<input type="text" maxlength="2000" name="QuestionAnswer" 
value="<%=Server.HtmlDecode(freqQuestionsUser.questionAnswer)%>" />

Reference