asp.net服务器端取js弹出层中dropdownlist的选中值???
我用了一个js的弹出层,里面放了一个dropdownlist控件,为什么每次我都不能取到选中的当前值,服务器端取到的都是原来的值。有什么解决方案吗?
asp.net前台代码(弹出层的div):
<div id="test" style="display:none; text-align:center ">
<asp:DropDownList ID="ddlCategory" runat="server" >
</asp:DropDownList>
<asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click" Text="转移"></asp:LinkButton>
</div>
cs页面代码:
if (!IsPostBack)
{
BindDataToDDL();
}
protected void BindDataToDDL()
{
绑定数据到dropdownlist....
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
string test = ddlCategory.SelectedValue.ToString()
}
页面首次加载的时候的值是“6”,后来我选择了别的,为什么取到的值还是“6”??、!
js弹出层代码:
popWin("将选择的供应商转移分类", div, 200, 60);
function popWin(title, msg, w, h){
var objSelect = document.getElementsByTagName("select"); //捕捉所有select标签
for(var j=0;j<objSelect.length;j++){
//设为不显示,再进行下面操作
objSelect[j].style.display="none";
}
var iWidth = document.documentElement.clientWidth;
var iHeight = document.documentElement.clientHeight;
var bgObj = document.createElement("div");
bgObj.id = "BgDiv";
bgObj.style.width = iWidth+"px";
bgObj.style.height = Math.max(document.body.clientHeight, iHeight)+"px";
document.body.appendChild(bgObj);
var msgObj=document.createElement("div");
msgObj.id = "MsgDiv";
msgObj.style.top = (iHeight-h)/2+"px";
msgObj.style.left = (iWidth-w)/2+"px";
msgObj.style.width = w+"px";
msgObj.style.height = h+"px";
document.body.appendChild(msgObj);
var table = document.createElement("table");
msgObj.appendChild(table);
table.id = "MsgDivTable";
var tr = table.insertRow(-1);
var titleBar = tr.insertCell(-1);
tr.id = "MsgTitle";
titleBar.id = "MsgDivTitle";
titleBar.innerHTML = title;
var moveX = 0;
var moveY = 0;
var moveTop = 0;
var moveLeft = 0;
var moveable = false;
var docMouseMoveEvent = document.onmousemove;
var docMouseUpEvent = document.onmouseup;
titleBar.onmousedown = function() {
var evt = getEvent();
moveable = true;
moveX = evt.clientX;
moveY = evt