|
||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionThis article basically describes how to get a BackgroundThere are scenarios when we have to populate fields from a child window to a parent window after selecting a particular row from a Using the codeI have created a scenario in which the parent window has some fields that can be populated from the child window. After getting the search results on the This can be done by using the private void dgEmployee_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
e.Item.Attributes["onmouseover"] = "javascript:setMouseOverColor(this);";
e.Item.Attributes["onmouseout"] = "javascript:setMouseOutColor(this);";
string FirstName = e.Item.Cells[0].Text.ToString();// first column value
string LastName = e.Item.Cells[1].Text.ToString() ;// Second
string HireDate = e.Item.Cells[2].Text.ToString() ;// third
string Job = e.Item.Cells[3].Text.ToString() ;// fourth
string Publisher = e.Item.Cells[4].Text.ToString() ; // fifth
string City = e.Item.Cells[5].Text.ToString() ; // sixth
e.Item.Attributes["onclick"] =
"javascript:setMouseClick('"+FirstName+"','"+LastName+"','" +
HireDate+"','"+Job+"','"+Publisher+"','"+City+"');";
}
}
Now, we have a JavaScript function that passes the parameters to parent window on the //JavaScript Function
function setMouseClick(first_name,last_name,hire_date,job,publisher,city ) {
var array = new Array();
array[0]=first_name;
array[1]=last_name;
array[2]=hire_date;
array[3]=job;
array[4]=publisher;
array[5]=city;
window.returnValue=array;
window.close();
}
On the parent window side, we have a JavaScript function that accepts the return value from the child window and shows up the return value on text boxes. The //JavaScript Function
function OnSearch()
{
var value = window.showModalDialog('\Popup.aspx','','');
if(value != null)
{
document.getElementById('txtFirstName').value = value[0];
document.getElementById('txtLastName').value = value[1];
document.getElementById('txtHireDate').value = value[2];
document.getElementById('txtJob').value = value[3];
document.getElementById('txtPublisher').value = value[4];
document.getElementById('txtCity').value = value[5];
}
}
That's all. Thanks!
|
|||||||||||||||||||||||||||||||||||||||||||||||