弹出页面显示TreeView,点击节点(NavigateUrl)把选择的值赋给父窗体
2010-07-14 17:03 海蓓娜楽 阅读(556) 评论(0) 编辑 收藏 举报第一步:在HTML页面增加:
I.添加控件:
<asp:TextBox ID="txtKnowDot" runat="server" Columns="40" MaxLength="50" ReadOnly="True" ></asp:TextBox>
<input type="button" id="btnKnowDot" runat="server" onclick="SelectKnowDot()" value="选取..." />
II.添加JS代码:
<script language="javascript" type="text/javascript">
var newwindow = '';
function SelectKnowDot()
{
var url = '../tkkmtest/TestKnowDotTree.aspx?kmid=<%=KMID %>&KMName=<%=KMName %>';
var sfeatures = "left=400,top=200,height=400,width=300";
popitup(url,"_blank",sfeatures);
}
function popitup(url,target,sfeatures)
{
if (!newwindow.closed && newwindow.location)
{
newwindow.location.href = url;
}
else
{
newwindow=window.open(url,target,sfeatures);
if (!newwindow.opener) newwindow.opener = self;
}
if (window.focus) {newwindow.focus()}
return false;
}
</script>
第二步:在类里面定义属性:KMID 和KMName :
private int _kmid;
private string _kmname;
/// <summary>
/// 科目名称
/// </summary>
public string KMName
{
get
{
return _kmname;
}
set
{
_kmname = value;
}
}
/// <summary>
/// 科目ID
/// </summary>
public int KMID
{
get
{
return _kmid;
}
set
{
_kmid = value;
}
}
第三步:利用TreeView的NavigateUrl属性重定向父窗体:
TreeNode node = new TreeNode();
*****
***
node.NavigateUrl = "javascript:opener.form1.txtKnowDot.value='"+要赋给父窗体txtKnowDot 的值+"';parent.window.close()";
注:
parent.window.close();:关闭窗体.
******:JS调用的方法.
******:要定义的参数.
******:父窗体的控件.
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/kissqi/archive/2008/07/28/2726506.aspx