【问题标题】:label text updated through javascript but not reflected on webpage标签文本通过 javascript 更新但未反映在网页上
【发布时间】:2017-03-02 17:37:02
【问题描述】:

我正在处理具有多个下拉控件的页面,在每个下拉选择的索引更改事件上,我想在模式弹出窗口中显示一些消息,因此我显示了带有标签的模式弹出窗口并动态更改了标签值从 JS 函数调用后面的代码中,值得到了改变,但没有反映在网页上。这是代码sn-p:

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;
}

【问题讨论】:

    标签: javascript asp.net c#-4.0


    【解决方案1】:

    您的模态表单中应该有一个标签。

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

    如果您需要更多说明,请阅读解释如何更改模态内容 Varying modal content based on trigger button 的部分

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-16
      • 1970-01-01
      • 1970-01-01
      • 2011-08-06
      • 1970-01-01
      • 1970-01-01
      • 2023-02-23
      • 2014-06-03
      相关资源
      最近更新 更多