我正在使用asp.net的bootstrap。我有一个bootstrap标签,其内容是在按钮点击时从DB(sql server)动态显示的。 DB表的单个单元格包含必须在该标签中显示的多行文本。
我使用break标记将数据保存在数据库中。 现在我尝试用Environment.NewLine替换break标记,如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<title>example.com</title>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root">
<div class="container fill">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar"><span
class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span
class="icon-bar"></span><span class="icon-bar"></span></button>
<a href="/" class="navbar-brand">example</a></div>
</div>
</nav>
<div>
<div class="container fill">
<div class="row">
<div class="col-12"><textarea style="width: 100%">a</textarea>
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">Action<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="javascript:void(0)">Save</a></li>
<li><a href="#">Copy</a></li>
<li class="divider" role="separator"></li>
<li><a href="#">Delete</a></li>
</ul>
</div>
</div>
<div class="content">
<div><p>a</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
这是我的aspx:
for (int i = 0; i < datatable.Rows.Count; i++)
{
QuesHint.InnerText = datatable.Rows[i]["Ques_Description"].ToString();
QuesHint.InnerText.Replace("<br/>", Environment.NewLine);
}
但我得到的输出是:like this
一切都出现在1行。
如何让它出现在下一行。
PS:我尝试过像<label id="QuesHint" runat="server" aria-multiline="True"></label>
这样的css属性
但没有任何效果。
请提出任何建议。
答案 0 :(得分:0)
使用如下所示:
for (int i = 0; i < datatable.Rows.Count; i++)
{
QuesHint.InnerHtml = datatable.Rows[i]["Ques_Description"].ToString();
}