pass the value as the second parameter for showModalDialog, then assign window.dialogArguments to your textbox inside 2.aspxor
use a querystring like ("2.aspx?value="+dropdown.value) to pass the value to 2.aspxfor example:
1.aspx:
<form runat="server">
<asp:DropDownList id="DropDownLis1" runat="server">
<asp:ListItem Value="1" Text="1" />
<asp:ListItem Value="2" Text="2" />
<asp:ListItem Value="3" Text="3" />
</asp:DropDownList>
<asp:TextBox id="txt1" runat="server" />
<input type="button" value="open new" onclick="openDialog()">
</form>
<script language="javascript">
function openDialog()
{
var dropdown = document.all("DropDownLis1");
if (dropdown.selectedIndex < 0)
{
alert("select something first");
return;
}
var sValue = dropdown.value;//or use dropdown.options[dropdown.selectedIndex].text;
var ret = showModalDialog("2.aspx",sValue);
//var ret = showModalDialog("2.aspx?value="+sValue);
if (ret != null)
document.all("txt1").value = ret;
}
</script>
2.aspx:
<form runat="server">
<asp:TextBox id="txt1" runat="server" />
<input type="button" value="OK" onclick="CloseWin(true)">
<input type="button" value="Cancel" onclick="CloseWin(false)">
</form>
<script language="javascript">
var bNeedReturn = false;function window.onload()
{
if (typeof(window.dialogArguments) != "unknown")
document.all("txt1").value = window.dialogArguments;
}function CloseWin(bRet)
{
bNeedReturn = bRet;
window.close();
}function window.onunload()
{
if (bNeedReturn)
window.returnValue = document.all("txt1").value;
}
</script>
<script language="C#" runat="server">
void Page_Load(Object o, EventArgs e)
{
if (Request.QueryString["value"] != null)
txt1.Text = Request.QueryString["value"].ToString();
}
</script>
use a querystring like ("2.aspx?value="+dropdown.value) to pass the value to 2.aspxfor example:
1.aspx:
<form runat="server">
<asp:DropDownList id="DropDownLis1" runat="server">
<asp:ListItem Value="1" Text="1" />
<asp:ListItem Value="2" Text="2" />
<asp:ListItem Value="3" Text="3" />
</asp:DropDownList>
<asp:TextBox id="txt1" runat="server" />
<input type="button" value="open new" onclick="openDialog()">
</form>
<script language="javascript">
function openDialog()
{
var dropdown = document.all("DropDownLis1");
if (dropdown.selectedIndex < 0)
{
alert("select something first");
return;
}
var sValue = dropdown.value;//or use dropdown.options[dropdown.selectedIndex].text;
var ret = showModalDialog("2.aspx",sValue);
//var ret = showModalDialog("2.aspx?value="+sValue);
if (ret != null)
document.all("txt1").value = ret;
}
</script>
2.aspx:
<form runat="server">
<asp:TextBox id="txt1" runat="server" />
<input type="button" value="OK" onclick="CloseWin(true)">
<input type="button" value="Cancel" onclick="CloseWin(false)">
</form>
<script language="javascript">
var bNeedReturn = false;function window.onload()
{
if (typeof(window.dialogArguments) != "unknown")
document.all("txt1").value = window.dialogArguments;
}function CloseWin(bRet)
{
bNeedReturn = bRet;
window.close();
}function window.onunload()
{
if (bNeedReturn)
window.returnValue = document.all("txt1").value;
}
</script>
<script language="C#" runat="server">
void Page_Load(Object o, EventArgs e)
{
if (Request.QueryString["value"] != null)
txt1.Text = Request.QueryString["value"].ToString();
}
</script>
解决方案 »
- 关于页面菜单问题(2级?3级?4级?服务器控件?),不知道用什么技术,所以来这里问一下吧。
- 紧急啊,IIS提示错误。
- CodeBehind和Codefile 区别
- JS如何调服务端的Dll【100000 Fire Hurry!!!】
- treeView的AutoPostBack的问题请教
- 执行一个存储过程,可以返回DateSet么? 好象只能通过ExecuteReader返回SqlDataReader
- 在网页上嵌入wmv视频,不用media server 难道就不可以拖动进度条进行点播???????
- 版主来给看一下用户控件引用问题!别人解决不了!
- ftp上传求助
- Webform下的TreeView中的任意节点,可不可以通过程序指定为默认的?
- asp.net与C#结合的好书,请推荐,谢了.
- 使用ADO连接一个本地的MDB数据库,进行读写删除等操作,有个例子看看吗?给一下提示也好哦!
不好意思,我现在才来,有问题再散分给大家你.好了结贴!