dropdownlist等控件的onchange事件,如果同时要触发js弹出框,则采用以下方法:
后台:
if (iStatusNo == (int)ZTE.EVAL.Model.EnumCollections.InvestigateStatus.已发布)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
this.ddlOperation.Items.Add(new ListItem(OperType.预览.ToString(),pkValue));
this.ddlOperation.Items.Add(new ListItem(OperType.关闭.ToString(),pkValue));
this.ddlOperation.Items.Add(new ListItem(OperType.全部跟催.ToString(),pkValue));
this.ddlOperation.Items.Add(new ListItem(OperType.调整结束日期.ToString(),pkValue));
this.ddlOperation.Items.Add(new ListItem(OperType.导出Excel.ToString(),pkValue));
this.ddlOperation.Items.Add(new ListItem(OperType.问卷管理.ToString(),pkValue));
}
else if (iStatusNo == (int)ZTE.EVAL.Model.EnumCollections.InvestigateStatus.已关闭)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
this.ddlOperation.Items.Add(new ListItem(OperType.预览.ToString(),pkValue));
this.ddlOperation.Items.Add(new ListItem(OperType.导出Excel.ToString(),pkValue));
this.ddlOperation.Items.Add(new ListItem(OperType.问卷管理.ToString(),pkValue));
}
![](/Images/OutliningIndicators/None.gif)
// 增加JS弹出事件
this.ddlOperation.Attributes.Add("onchange","if (ExecOperJscript('" + this.ddlOperation.ClientID + "')) return;");
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
前台:
<script language=javascript>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
function ExecOperJscript(objID)
{
var ddl = document.getElementById(objID);
var itemText = "";
var msg = "";
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
for (var i = 0; i<ddl.options.length; i++)
{
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
if (ddl.options[i].selected)
{ itemText = ddl.options[i].innerText; }
}
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
switch (itemText)
{
case "删除":
msg = "你确定要删除当前调查吗?该操作不可恢复!";
break;
case "发布":
msg = "你确定要发布当前调查吗?该操作不可恢复!";
break;
case "关闭":
msg = "你确定要关闭当前调查吗?该操作不可恢复!";
break;
case "全部跟催":
msg = "你确定要跟催当前调查吗?该操作将向所有的个体发送邮件!";
break;
default:
break;
}
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
if (msg == "")
{ return true; }
return confirm(msg);
}
</script>