web对话框返回xml
来源:互联网 发布:手机淘宝店铺首页链接 编辑:程序博客网 时间:2024/06/05 21:10
1.对话框.aspx
对话框显示的是一个select,两个按钮添加和取消,注意<base target="_self">,
他保证了按照预期关闭对话框
<html>
<head>
<base target="_self">
</head>
<script>
function WinClose()
{
window.close();
}
</script>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<TABLE id="Table2" cellSpacing="0" cellPadding="0" width="100%"
border="0">
<TR>
<TD height="200"><select id="lstItems" style="WIDTH:
300px; HEIGHT: 253px" multiple size="15" name="lstItems"
runat="server"></select></TD>
</TR>
<TR>
<TD height="25" align="right"><INPUT class="FormButton"
id="btnAdd" type="button" value="添加" style="WIDTH: 60px; HEIGHT: 25px"
name="Button1" runat="server"><FONT
face="宋体"> </FONT><INPUT class="FormButton" id="btnCancel" style="WIDTH: 60px; HEIGHT:
25px" onclick="WinClose()"
type="button" value="取消"></TD>
</TR>
</TABLE>
</form>
</body><html>
2.对话框.cs
....
//绑定控件
private void BindList()
{
....
....
SqlDataReader dr=SqlHelper.ExecuteReader(str_connstring,CommandType.Text,sqlSelect);
stItems.DataSource=dr;
lstItems.DataValueField="instr_code";
lstItems.DataTextField="instr_name";
DataBind();
}
//生成xml
private void btnAdd_ServerClick(object sender, System.EventArgs e)
{
string optionStr="<?xml version=/"1.0/" encoding=/"utf-8/" ?> <InstrList>";
foreach(System.Web.UI.WebControls.ListItem item in this.lstItems.Items)
{
if(item.Selected)
{
optionStr+="<Instr code=/""+item.Value+"/">"+item.Text+"</Instr>";
}
}
optionStr+="</InstrList>";
CloseWindow(optionStr) ;
}
//关闭并返回,关键在于这个返回值
private void CloseWindow(string returnValue)
{
string script = @"<script>";
script+= " window.close();returnValue='"+returnValue+"'; ";
script+= "</script>";
Response.Write(script);
}
3.父窗体.aspx
<html>
<head></head>
<script>
//解析xml
function addInstrument(evl)
{
var openWindow =
window.showModalDialog("对话框.aspx", "Value",
"dialogHeight:320px;dialogWidth:310px;status:no;help:no;scroll:no;resizable:no;center:yes;");
if(openWindow!=null)
{
var oDoc = new ActiveXObject("MSXML2.DOMDocument");
oDoc.loadXML(openWindow);
var items=oDoc.selectNodes("InstrList/Instr");
for (var item = items.nextNode(); item; item = items.nextNode())
{
var oOption = document.createElement("OPTION");
oOption.text=item.nodeTypedValue;
oOption.value=item.getAttribute("code");
document.all.getElementById("InstrList").add(oOption);
}
}
}
//双击移除
function DelInstr(evl)
{
evt = (evt) ? evt : ((window.event) ? window.event : "");
if (evt) {
var elem = (evt.target) ? evt.target : evt.srcElement;
elem.remove(elem.selectedIndex);
}
}
//载入
windon.onload=function()
{
var btnAdd=document.all.getElementById("addInstr");
var selList=document.all.getElementById("");
btnAdd.attachEvent("onclick",addInstrument);
selList.attachEvent("ondblclick",DelInstr);
}
</script>
<body>
<INPUT type="button" value="增加" id="addInstr" >
<SELECT id="InstrList" size="4" style="WIDTH: 100%; HEIGHT: 70px"></SELECT>
</body>
</html>
- web对话框返回xml
- 从 ASP Web 页返回 XML
- 使用返回 DataTable 的 XML Web 服务时出现问题
- Java调用.NET XML Web Services返回的DataSet
- 调用.NET XML Web Services返回数据集合一
- Java调用.NET XML Web Services返回的DataSet
- 直接调用Webservice返回XML时需要配置web.config
- SQL Server 中的XML支持,查询返回XML,Web访问SQL取XML形式结果
- XML返回
- [Web]如何实现从模式窗体-网页对话框 中获得返回值
- [Web]如何实现从模式窗体-网页对话框 中获得返回值
- [Web]如何实现从模式窗体-网页对话框 中获得返回值
- android访问web工程,并解析web工程返回的xml文件
- .net 弹出对话框返回多个值
- C# 对话框的返回值
- Android 获取对话框返回值
- MFC 对话框程序返回值
- web中的模式对话框
- 最佳ASP.NET编程习惯
- 一些仿豆瓣的网站——猫扑也来抄豆瓣
- CSS简明教程——CSS定位
- Eclipse3.2 M6 的新特性和功能
- 有关Tomcat应用程序目录、端口、默认目录、应用程序默认打开文件、使用数据库连接池等方面的配置
- web对话框返回xml
- Linux相关配置
- C#设计模式:接口型模式
- C#+ASP.NET开发基于Web的RSS阅读器
- 好文章链接集合
- TCP(二)
- 比我大一岁的一个IT女生的职业规划
- 昨天写了个"Setup Builder (SP6) SPP工程文件提取器"
- 网上几种常见校验码图片分析