javascript - 更改模态引导中的文本
问题描述
我在我的 asp.net 网站中使用模态引导程序。由于我需要根据错误修改文本以在后面的代码中返回,因此我在进行调用之前更改了控件的文本值,但它不起作用。消息不变。这是我的 HTML:
<!-- /.modal error-->
<div id="ModalError" class="modal fade bs-example-modal-center" tabindex="-1" role="dialog" aria-labelledby="myCenterModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content alert-primary">
<div class="modal-header">
<h4 class="modal-title text-danger" id="CenterModalLabel">Errore</h4>
<i class="mdi mdi-alert-octagon-outline" style="font-size:30px"></i>
</div>
<div class="modal-body">
<asp:Label runat="server" ID="ltlErrormsg" Text="Errore"></asp:Label>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary btn-danger" data-dismiss="modal">Ok</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
function openModal() {
$('#ModalInfo').modal('show');
}
function openModalErr() {
$('#ModalError').modal('show');
}
ValidatorUpdateIsValid = function () {
Page_IsValid = AllValidatorsValid(Page_Validators);
SetValidatorStyles();
}
SetValidatorStyles = function () {
var i;
// clear all
for (i = 0; i < Page_Validators.length; i++) {
var inputControl = document.getElementById(Page_Validators[i].controltovalidate);
if (null != inputControl) {
WebForm_RemoveClassName(inputControl, 'parsley-error');
}
}
// set invalid
for (i = 0; i < Page_Validators.length; i++) {
inputControl = document.getElementById(Page_Validators[i].controltovalidate);
if (null != inputControl && !Page_Validators[i].isvalid) {
WebForm_AppendToClassName(inputControl, 'parsley-error');
}
}
}
</script>
这是我背后的代码:
Private Sub cmdCambiaPwd_Click(sender As Object, e As EventArgs) Handles cmdCambiaPwd.Click
Dim strOldPassword As String
If txtPassword.Value = "" Then
ltlErrormsg.Text = "Compilare le password"
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "Pop", "openModalErr();", True)
Exit Sub
End If
解决方案
我发现了问题。模态窗口不在我页面的更新面板中。所以我将它们移动到更新面板中并开始工作。
推荐阅读
- linux - 带有 / 字符的 BASH_REMATCH
- python-3.x - 在时间序列图上将不同的分类类别显示为不同的颜色
- python - 在 aws lightsail 中缓慢安装 python/django 包
- html - 视频高度最大到屏幕高度
- c# - 在 Datagrid 中显示 Excel 中的数据
- javascript - 如何在反应中的CSelect元素中显示从api获取的数组
- c++ - 洗牌向量的最快“简单”方式
- android - 设置意图在 SAMSUMG M51 中不起作用
- r - 将数据框 Group BY 代码放入 R 中的函数中
- virtualbox - VirtualBox 6.1 在运行几分钟后自动重启我的主机