从弹出的asp.net C#刷新父的DropDownList [英] Refresh parent dropdownlist from popup in asp.net c#
问题描述
我在我的父页面dropdwnlist控制 - ASP.NET C#,按钮的点击是有弹出式开放的新值添加到控件
I have a dropdwnlist control in my parent page - ASP.NET C#, on click of button there is a popup opening to add new value to the control.
[+]
[+]
在弹出的页面 - 保存按钮,我有以下的code:
In PopUp page - Save button , I have the following code :
Response.Write("<script>opener.loadOptionLandlord('" + stid + "','" + strLandlorconn_dbame + "');</script>");
Response.Write("<script>window.close();</script>");
其中loadOptionLandlord是一个函数在我父页面:
where loadOptionLandlord is a function in my parent page :
function loadOptionLandlord(val,txt)
{
var opt = document.createElement('<option value="'+ val +'">');
opt.innerText = txt;
var sCtrl = document.getElementById('<%= ddlLandlord.ClientID %>');
sCtrl.options[sCtrl.options.length] = new Option(txt, val, false, true);
}
该值被保存到数据库中,并在弹出的窗口正在关闭,但新加入的数据没有在DropDownList耳目一新。
这是工作的IE浏览器,而不是浏览器。
The value is being saved to the database and the popup window is closing , but the newly added data is not refreshing in the dropdownlist. This is working for IE, but not for Chrome.
请帮助..
推荐答案
更改 loadOptionLandlord
如下
Change your loadOptionLandlord
as below
function loadOptionLandlord(val,txt)
{
var opt = document.createElement("option");
var sCtrl = document.getElementById('<%= ddlLandlord.ClientID %>').options.add(opt);
opt.text = txt;
opt.value = val;
}
这篇关于从弹出的asp.net C#刷新父的DropDownList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!