ASP.NET GridView row click open a new window and update value of parent window
IN PARENT PAGE
IN C# CODE
protected void gvIndent_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes[
"onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';";
e.Row.Attributes[
"onmouseout"] = "this.style.textDecoration='none';";
e.Row.Attributes[
"onclick"] = ClientScript.GetPostBackClientHyperlink(this.gvIndent, "Select$" + e.Row.RowIndex);
e.Row.Attributes.Add(
"onclick", "openPopUp('" + DataBinder.Eval(e.Row.DataItem, "indent_no") + "');");
}
}
In Page Load Event
string updateValuesScript = @"function updateValues(popupValues)
{
document.getElementById('ctl00_PlaceHolderLeft_txtIndentNo').value = popupValues[0];
}";
this.ClientScript.RegisterStartupScript(Page.GetType(), "UpdateValues", updateValuesScript.ToString(), true);
IN ASPX
<script type="text/javascript">
function openPopUp(strUser) {
var popUrl = 'indent_status.aspx?Value='+strUser;
var name = 'popUp';
var appearence = 'dependent=yes,menubar=no,resizable=yes,' +
'status=no,toolbar=no,titlebar=no,' +
'left=100,top=80';
var openWindow = window.open(popUrl, name, appearence);
openWindow.focus();
}
</script>
IN CHILD ASPX PAGE
protected void Page_Load(object sender, EventArgs e)
{
string updateParentScript = @"function updateParentWindow(ides)
{
var ide=ides;
var arrayValues= new Array(ide);
window.opener.updateValues(arrayValues);
window.close();
}";
//document.getElementById('lblID.ClientID').value;
this.ClientScript.RegisterStartupScript(this.GetType(), "UpdateParentWindow", updateParentScript, true);
btnClose.Attributes.Add("onclick", "updateParentWindow(parameter value)");
}