刚接触jquery
遇到问题了。
想用jquery实现这样一个功能:例如当father页面的一个文本框(txtEmployee)输入控件获得焦点的时候。
弹出一个子页面child.aspx:
child页面中放的是一个repeater控件绑定的Employee表中的数据,
双击repeater控件某一行的时候,将这行数据的Name值返回到
father页面的txtEmployee文本框中。同时关闭child页面。代码如下:father.aspx
<head runat="server">
<title>无标题页</title> <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#txtEmployeeID").focus(function() {
parent.openDialog("child", "?page=father&custID=hidEmployeeID&custName=txtEmployee");
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtEmployee" runat="server"></asp:TextBox>
<asp:HiddenField ID="hidEmployeeID" runat="server" />
</div>
</form>
/////////////////
child.aspx
js代码
<script src="../js/jquery-1.3.2.min.js" type="text/javascript"></script> <script type="text/javascript">
$("document").ready(function() {
$(".rept tr").dblclick(function() {
var id = $(this).attr("id");
var name = $(this).attr("title");
var custID = '<%= Request["custID"] %>';
var custName = '<%= Request["custName"] %>';
parent.document.getElementById(custID).value = id;
parent.document.getElementById(custName).value = name;
parent.closeDialog("EmployeeSelect");
});
});
</script>
绑定repeater主要代码
<div class="rept" style="width: 530px; height: 268px;">
<table cellpadding="0" cellspacing="0">
<tr id="0">
<th style="width: 10%">员工编号</th>
<th style="width: 10%">员工所属部门</th>
<th style="width: 9%">姓名</th>
<th style="width: 9%">职务</th>
<th style="width: 9%"> 性别</th>
</tr>
<asp:Repeater ID="reptE" runat="server">
<ItemTemplate>
<tr id="<%# Eval("Employee_ID") %>" title='<%# Eval("Name") %>'>
<td><%#Eval("Employee_ID")%></td>
<td><%#Eval("Dept_ID")%></td>
<td><%#Eval("Name")%></td>
<td><%#Eval("Duty")%></td>
<td><%#Eval("Gender")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
现在问题:1、在father页面中txtEmployee获得焦点的时候不弹出子页面。
2、我在子页面中写的能否实现双击repeater某行的时候如何获取到相应的Name值和ID值。
遇到问题了。
想用jquery实现这样一个功能:例如当father页面的一个文本框(txtEmployee)输入控件获得焦点的时候。
弹出一个子页面child.aspx:
child页面中放的是一个repeater控件绑定的Employee表中的数据,
双击repeater控件某一行的时候,将这行数据的Name值返回到
father页面的txtEmployee文本框中。同时关闭child页面。代码如下:father.aspx
<head runat="server">
<title>无标题页</title> <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#txtEmployeeID").focus(function() {
parent.openDialog("child", "?page=father&custID=hidEmployeeID&custName=txtEmployee");
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtEmployee" runat="server"></asp:TextBox>
<asp:HiddenField ID="hidEmployeeID" runat="server" />
</div>
</form>
/////////////////
child.aspx
js代码
<script src="../js/jquery-1.3.2.min.js" type="text/javascript"></script> <script type="text/javascript">
$("document").ready(function() {
$(".rept tr").dblclick(function() {
var id = $(this).attr("id");
var name = $(this).attr("title");
var custID = '<%= Request["custID"] %>';
var custName = '<%= Request["custName"] %>';
parent.document.getElementById(custID).value = id;
parent.document.getElementById(custName).value = name;
parent.closeDialog("EmployeeSelect");
});
});
</script>
绑定repeater主要代码
<div class="rept" style="width: 530px; height: 268px;">
<table cellpadding="0" cellspacing="0">
<tr id="0">
<th style="width: 10%">员工编号</th>
<th style="width: 10%">员工所属部门</th>
<th style="width: 9%">姓名</th>
<th style="width: 9%">职务</th>
<th style="width: 9%"> 性别</th>
</tr>
<asp:Repeater ID="reptE" runat="server">
<ItemTemplate>
<tr id="<%# Eval("Employee_ID") %>" title='<%# Eval("Name") %>'>
<td><%#Eval("Employee_ID")%></td>
<td><%#Eval("Dept_ID")%></td>
<td><%#Eval("Name")%></td>
<td><%#Eval("Duty")%></td>
<td><%#Eval("Gender")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
现在问题:1、在father页面中txtEmployee获得焦点的时候不弹出子页面。
2、我在子页面中写的能否实现双击repeater某行的时候如何获取到相应的Name值和ID值。
不知道这个是什么东西? 难道是jquery的?
我只知道
window.showModalDialog("child.aspx?page=father&custID=hidEmployeeID&custName=txtEmployee");
可以弹出模式对话框的
现在关键是1.弹不出页面。
2、获取到子页面的值然后传递回去。回zhujiazhi:
我写的那个是从别人那里找的一个例子。呵呵。我也不知道怎么是这样的。按你写的window.showIModalDialog();像我要的功能该怎么从子页面传值过去呢,麻烦详细点。谢谢。
window.open("child.aspx?page=father&custID=hidEmployeeID&custName=txtEmployee");
child.aspx修改
opener.document.getElementById(custID).value = id; opener.document.getElementById(custName).value = name;
opener.closeDialog("EmployeeSelect");
试一下
$(document).ready(function() {
$("#txtEmployeeID").focus(function() {
parent.openDialog("child", "?page=father&custID=hidEmployeeID&custName=txtEmployee");
});
});
里面的代码啊
先解决这个问题,谢谢各位了
$(document).ready(function() {
$("#txtEmployee").focus(function() {
window.open ("child.aspx?page=father&custID=hidEmployeeID&custName=txtEmployee");
});
});
window.showModalDialog()可以弹出来了。但是只有一个很小的窗口。都显示不出来数据。怎么控制弹出窗口的大小呢。望解答。谢谢了
就因为是rp 楼主就另外弹出个.aspx页面吗一个<%#Eval("")%>+DIV 楼主要解决很多东西啊
最近一个项目 我就是这样做的
jquery说的不专业也就是js嘛
就还剩一个。就是在关闭了子页面之后同时刷新父页面该怎么写呢?
弹出问题,我没有用Onfocus了。在旁边加了个button。呵呵。