Javascript 在模态boostrap中更改文本

Javascript 在模态boostrap中更改文本,javascript,asp.net,vb.net,bootstrap-4,Javascript,Asp.net,Vb.net,Bootstrap 4,我正在asp.net网站中使用模式引导。 因为我需要根据错误修改文本以在代码中返回,所以我在调用之前更改了控件的文本值,但它不起作用。信息不会改变。 这是我的HTML: <!-- /.modal error--> <div id="ModalError" class="modal fade bs-example-modal-center" tabindex="-1" role="dialog" aria-labelledby="myCenterModalLabel" aria

我正在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>
我发现了问题。 模式窗口不在“我的页面”的更新面板中。 所以我在updatepanel中移动它们并开始工作。

我发现了问题。 模式窗口不在“我的页面”的更新面板中。
因此,我将它们移动到updatepanel中并开始工作。

测试了您的代码,工作正常。模态是用错误文本打开的,测试代码后,工作正常。打开模式时显示错误文本,
 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