【点击父窗口里的按钮时,把下拉列表organ_name所选中的值传给子页面。】父窗口:
<asp:DropDownList ID="organ_name" runat="server" AutoPostBack="True" Width="100px">
</asp:DropDownList><br /><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/add_led.png" OnClientClick="Pop1('Led_action.aspx?Organ_name2= document.getElementById("organ_name").value' ,500,300)" />
</td>
</tr>
【方法在JS中如下:】
function Pop1(file,width,height)
{
//var Organ_name2;
//Organ_name2= document.getElementById("organ_name").value;
window.showModalDialog(file,"subpage","dialogWidth:"+width+"px;dialogHeight:"+height+"px;center:yes;status:no;scroll:no;help:no;resizable:no");
}【子窗口中是这样接受值的】
string Organ_name2 = Request.QueryString["Organ_name2"];
可是总是接受不到值,不知道为什么。 我用注释的Organ_name2= document.getElementById("organ_name").value;,也接收不到值。谢谢
<asp:DropDownList ID="organ_name" runat="server" AutoPostBack="True" Width="100px">
</asp:DropDownList><br /><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/add_led.png" OnClientClick="Pop1('Led_action.aspx?Organ_name2= document.getElementById("organ_name").value' ,500,300)" />
</td>
</tr>
【方法在JS中如下:】
function Pop1(file,width,height)
{
//var Organ_name2;
//Organ_name2= document.getElementById("organ_name").value;
window.showModalDialog(file,"subpage","dialogWidth:"+width+"px;dialogHeight:"+height+"px;center:yes;status:no;scroll:no;help:no;resizable:no");
}【子窗口中是这样接受值的】
string Organ_name2 = Request.QueryString["Organ_name2"];
可是总是接受不到值,不知道为什么。 我用注释的Organ_name2= document.getElementById("organ_name").value;,也接收不到值。谢谢
function Pop1(width,height)
{
//var Organ_name2;
//Organ_name2= document.getElementById("organ_name").value;
var file='Led_action.aspx?Organ_name2='+ document.getElementById("organ_name").value
window.showModalDialog(file,"subpage","dialogWidth:"+width+"px;dialogHeight:"+height+"px;center:yes;status:no;scroll:no;help:no;resizable:no");
}
没看出来,你在那里传的值
OnClientClick="Pop1('Led_action.aspx?Organ_name2= document.getElementById("organ_name").value' ,500,300)"
取值时你改成这样试试
JS代码: function jieyuejilu()
{
var xiaohao="document.getElementById("txtxiaohao").value";
var WinSetings="center:yes;resizable:no;dialogHeight:500px;dialogWidth:700px;scroll:no;help:no";
var Myarg=window.showModalDialog("jieyuejilu.aspx?xiaohao="+xiaohao,null,WinSetings);
}接收时:代码string xiaohao = Request.QueryString["xiaohao"].ToString();
服务器空间的ID可能会在运行的时候被加上一堆字符串。。
搜索下organ_name,然后找到他的name
用Request["源文件中的name"]就行
var Myarg=window.showModalDialog("jieyuejilu.aspx?xiaohao=test",null,WinSetings);
Get the parameter:
Request["xiaohao"]
传页面值的话,这样写不对吧,应该怎么写 OnClientClick="Pop1('Led_action.aspx?Organ_name2=document.getElementById("organ_name").value ',500,300)"是一个下拉列表
ImageButton1_Click 里注册你的客户端脚本即可;要么就都用客户端控件
<select >
<input type="button"你同样的代码,相信问题即可解决,因为你用的服务器控件,有一个回发的动作,所以可能你传送的数据被页面刷新后就没值 了
document.Form1.drop.options[document.Form1.drop.selectedIndex].value
因为我需要用Dropdown 选项改变时,随时显示GridView。AutoPostBack="false" ,没法实现。 onchange这个方法也里面没有啊,哎,都快三天了,也改不过来,伤心,help me
总结下:
调用的方法是对的。
错误出在:
① 传值的获取方式写法错误 OnClientClick="Pop1('Led_action.aspx?Organ_name2= document.getElementById("organ_name").value' ,500,300)" ②在js里的取值,取不到,应该是因为回发刷新了吧。
var file='Led_action.aspx?Organ_name2='+ document.getElementById("organ_name").value
}解决:
因为回发,就没有再使用客户端获取值,在服务器端很容易就获得了值。
string _jsEdit = "showModalDialog('Led_action.aspx?Organ_name2="+HttpUtility.UrlEncode( organ_name.Text)+"',null,'dialogWidth:500px;dialogHeight:300px;center:yes;status:no;scroll:no;help:no;resizable:no')";
ImageButton1.Attributes.Add("onclick",_jsEdit);