簡體   English   中英

標簽文字通過javascript更新,但未反映在網頁上

[英]label text updated through javascript but not reflected on webpage

我正在一個具有多個下拉控件的頁面上,在每個下拉選擇的索引更改事件上,我想在模式彈出窗口中顯示一些消息,因此我在模式彈出窗口上顯示了帶有標簽的標簽,並從后面的代碼動態更改了標簽值調用JS函數,值會更改,但不會反映在網頁上。 這是代碼片段:

C#代碼:

     public void Page_Load(object sender, EventArgs e)
      {            
        //builds page controls
        this._BuildControls();

        if (IsPostBack)
        {
            // get the target of the post-back, will be the name of the control
            // that issued the post-back
            string eTarget = Request.Params["__EVENTTARGET"].ToString();

            //source database server dropdown changes event called
            if (eTarget.Contains("SourceDatabaseServer"))
            {
                this._DisplayMessage = "Loading source database...";

            }
            else if (eTarget.Contains("SourceDatabaseName"))
            {
                this._DisplayMessage = "Loading source host name...";
            }
            else if (eTarget.Contains("DestinationDatabaseServer"))
            {
                this._DisplayMessage = "Loading destination database...";
            }
            else if (eTarget.Contains("DestinationDatabaseServer"))
            {
                this._DisplayMessage = "Loading destination host name...";
            }
            else
            {
                this._DisplayMessage = "Cloning portal...";
            }
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "updateMessage('" + this._DisplayMessage + "');", true);
        }

    }

Javascript文件功能:

function updateMessage(message){
 var text = document.getElementById('LoadAndSaveClonePortalDataModalModalPopup'); 
 text.innerHTML=message;
}

您應該在模態形式中有一個標簽。

function updateMessage(message) {
  var $modal = $('#LoadAndSaveClonePortalDataModalModalPopup'),
      $messagelbl = $modal.find('#lblMessage');
      $messagelbl.val(message);
      $modal.modal("show");
}

閱讀說明如何更改模式內容的部分,如果需要更多說明,請根據觸發按鈕更改模式內容

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM