我正在处理一个带有多个下拉控件的页面,在每个下拉列表中选择索引更改事件我想在模态弹出窗口中显示一些消息,因此我显示了带有标签的模态弹出窗口并动态更改了标签值从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;
}
答案 0 :(得分:0)
你的模态形式应该有一个标签。
function updateMessage(message) {
var $modal = $('#LoadAndSaveClonePortalDataModalModalPopup'),
$messagelbl = $modal.find('#lblMessage');
$messagelbl.val(message);
$modal.modal("show");
}
如果您需要更多说明,请阅读解释如何更改模态内容Varying modal content based on trigger button的部分