如何设置从c#到asp.net
本文关键字:net asp h4 何设置 设置 | 更新日期: 2023-09-27 18:14:41
我有一个弹出创建在bootstrap在我的。aspx页面。
<div id="myModal" class="modal fade " tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-title">
<h4 id="modaltext" runat="server" class="modal-body"></h4>
<div class="modal-footer">
<button type="button" data-dismiss="modal" onclick="show_loginpanel()" class="btn btn-primary">Okay</button>
</div>
</div>
</div>
在c# .cs文件中,
modaltext.InnerHtml = "Successful";
从c#中,我调用了一个js函数,它显示了上面的模态弹出。
ScriptManager.RegisterStartupScript(this, GetType(), "Message", "showModal();", true);
JavaScript函数:showModal()
function showModal() {
$('#myModal').modal('show')
}
当我运行我的项目时,弹出窗口上没有显示文本。<h4>
标签为空
谁能告诉我我错过了什么
使用LiteralControl:
<h4><asp:Literal id="SuccessfulLine" runat=server /></h4>
背后的代码:
SuccessfulLine.Text ="Successful";
编辑:你也可以用javascript实现:
string successfullString = "Successful";
string js = @"$( document ).ready(function() {
$('#modaltext').text('" + successfullString + "')@
$('#myModal').modal('show');
})";
ScriptManager.RegisterStartupScript(this, GetType(), "Message", js , true);