我有一个 asp webform
站点,在一个页面上我有一个 asp:TextBox
和 TextMode="MultiLine"
字段代码是如下所示
<asp:TextBox ID="Step04OtherField" runat="server" class="form-control" style="max-width: 100%" TextMode="MultiLine" Rows="5"></asp:TextBox>
此页面将页面上的所有详细信息存储在一个 session 中,然后在下一页显示条目。问题是,即使用户可能在文本框中输入了 2 个条目,并且每次单击回车键,它都会在确认页面上显示在一行中,所以不是很清楚。
有没有办法做到这一点,当 session 值显示在确认页面上时,每次按下回车键也会在此页面上换行显示
Session存储代码隐藏
Session["Step04OtherField"] = Step04OtherField.Text;
确认页面 HTML
<div class="form-group">
<asp:Label ID="Step04BrowsersLabel" class="col-xs-6 col-sm-3 control-label" runat="server" Text="Browser(s) to check on:"></asp:Label>
<div class="col-xs-6 col-sm-9 form-control-static">
<%=Session["Step04OtherField"] %>
</div>
</div>
当页面显示时,它显示为: 要检查的浏览器:Entry1 Entry2 等
我希望它显示为类似的东西
要检查的浏览器:Entry1
条目 2
等
最佳答案
这将适用于文本部分:
Session["Step04OtherField"] = Step04OtherField.Text.Replace("\r\n", "<br />");
然后对于 html 格式:
<table>
<row>
<td valign="top">Browser(s) to check on:</td>
<td> <%=(string)Session["Step04OtherField"] %></td>
</row>
</table>
关于html - 在新行上显示来自 asp :TextBox 的所有条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32525683/