以下语句可以将模式对话框'NewValue.aspx'的值str返回给主页面的TextBox1:
string strScript="<Script language='Javascript'>";
strScript += "var str=window.showModalDialog('NewValue.aspx');";
strScript += "if(str!=null) {document.Form1.TextBox1.value=str}";
strScript += "</script>";this.Page.RegisterStartupScript("NewValue",strScript);--------------------------------------------------------------------
那么,要把值str返回给主页面的DropDownList1,即在DropDownList1中添加一项str,
并使DropDownList1的当前值为str,应该怎么做?谢谢!
string strScript="<Script language='Javascript'>";
strScript += "var str=window.showModalDialog('NewValue.aspx');";
strScript += "if(str!=null) {document.Form1.TextBox1.value=str}";
strScript += "</script>";this.Page.RegisterStartupScript("NewValue",strScript);--------------------------------------------------------------------
那么,要把值str返回给主页面的DropDownList1,即在DropDownList1中添加一项str,
并使DropDownList1的当前值为str,应该怎么做?谢谢!
解决方案 »
- treeview中节点NavigateUrl汉字参数
- GridView,RowUpdating的时候DataSource为null?
- ASP.NET如何限制<input>日期录入格式,我已经用javascript日历控件。但是依然可以手动录入我想写个限制约束。
- 紧急求助,关于web.config的问题
- 在线等!如何获取当前浏览器中显示页面的源代码?
- 大家的用户权限是什么设计的呢
- "不重新发送信息,则无法刷新网页",看了之前的贴,但是不能解决问题,还望各位老鸟鼎力相助!!!
- 怎样在客户端控制TREEVIEW
- 在ASHX 内,用存储过程和SQL 字符串哪个效率高
- 字符串数组赋初值问题(在线等待)
- textbox的visible属性设置为false后,客户端不会生成的html语法?
- 从数据库取出一条记录内容与直接读取指定记录文件的内容,哪个快些?
var ret = new Array();
ret[0] = 你的在DropDownList中显示的text";
ret[1] = "你在DropDownList中显示的Value";
window.returnValue = ret;然后在父窗口如下得到返回值
var result = window.ShowModalDialog(..后面自己写
在将返回值加入到dropdownlist中
var drop = document.getElement('你的dropdownlist的id);
var option = document.createElement('option');
option.text = result[0];
option.value = result[1];
drop.add(option);
完工。。
应该是parent.window.returnValue = ret;
我用的是window.parent.returnValue = ret;可以得到结果了。但是,1、每执行一次该段代码,上一次新增的值就没有了,而替以新值。为什么?
2、新增的同时,希望同时选中该项,如何写?
if(str!=null)
{
var list=document.Form1.DropDownList1;
var option = document.createElement('option');
option.text =str;
option.value =str;
list.add(option);
list.selectIndex=list.options.length;--新增的同时,希望同时选中该项,此句怎写才对?
}
list.selectedIndex=list.options.length-1;
谢谢!