62,050
社区成员
发帖
与我相关
我的任务
分享
protected void gvMessageEmp_RowDataBound(object sender, GridViewRowEventArgs e)
{
Session["SelectEmpID"] = e.Row.Cells[0].Text.ToString().Trim();
e.Row.Attributes.Add("ondblclick", "window.location.href='MessageEmp.aspx?empID=" + Session["SelectEmpID"] + "'");//这里MessageEmp.aspx就是新窗口页面,这里只是双击能把值保存到session中
}
<script language="javascript" type="text/javascript">
var empID;
empID="<%=Session["SelectEmpID"]%>";
function ajaxRead(empID){
var xmlObj = null;
if(window.XMLHttpRequest){
xmlObj = new XMLHttpRequest();
}
else if(window.ActiveXObject){
xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
}
else {
return;
}
xmlObj.onreadystatechange = function(){
if(xmlObj.readyState == 4){
//updateObj('xmlObj', xmlObj.responseXML.getElementsByTagName('data')[0].firstChild.data);
document.getElementById("txtEmpId").value = empID ;
}
}
xmlObj.open ('GET', MessageEmp.aspx, true);
xmlObj.send ('');
}
</script>
<input type='button' value='设置父窗口的文本'
onclick='window.opener..document.getElementById('txtID').value='';' />
<input type='button' value='设置父窗口的文本'
onclick='window.opener.document.getElementById("txtID").value="";' />
<html>
<body>
要传的值
<input type='text' id='txtID' name='txtName' value='aa' /> <br>
<input type='button' value='open' onclick="window.open('b.html');" />
<script>
function method()
{
alert('a.html');
}
</script>
</body>
</html>
<html>
<script>
function getValue()
{
//document.getElementById('txt').value=window.opener.txtName.value;
document.getElementById('txt').value=window.opener.document.getElementById
('txtID').value;
}
</script>
<body onload='getValue();'>
传过来的值是
<input type='text' id='txt' />
<input type='button' value='调用父窗口的方法' onclick='window.opener.method();' />
<input type='button' value='设置父窗口的文本'
onclick='window.opener..document.getElementById('txtID').value='';' />
</body>
</html>
e.Row.Attributes.Add("ondblclick", "window.opener.document.all."& txtClientID &".value=" & e.Row.Cells[0].Text.ToString().Trim() & ");