I am developing small web application in that "Patient Registration" acts as parent page and "Insurance Search Page" acts as child page. when user clicks on search button in parent page( for selecting insurance) Insurance Search Page opens in new window (it displays all insurance details in gridview when user click on particular row page has to close (here i am getting insurance id) based on the insurance id i have to get the insurance name ,address, phone no etc from database and i have to fill the values in respected fields in the "Patient Registration page".
HERE IS MY CODE "Patient Registration page"
"Calling java script in Imagebutton Click event"
<td class="style277"> <asp:ImageButton ID="Btn_Search" runat="server" Height="16px"ImageUrl="~/Images/mag_glass_256x256x32.png"Width="25px" OnClientClick="javascript:openChild();return false;"
style="margin-top: 0px" />
"Java script for calling insurancesearch page and setting insurance id to textbox"
function openChild()
{
childWindow = open('InsuranceSearch.aspx', 'Search', dialogWidth = 500, dialogHeight = 400);
}
function setValue(myVal)
{
document.getElementsByName('Txtbx_InsID')[0].value = myVal;
PageMethods.GetInsuranceDetails(myVal);
}
c#
[WebMethod]
public static void GetInsuranceDetails(string Id)
{
cls_DAL obj = new cls_DAL();
DataTable ds = obj.GetInsuranceDetailsbasedonID(Id);
}
HERE IS MY CODE "Insurance Search page"
protected void Page_Load(object sender, EventArgs e)
{
cls_DAL obj = new cls_DAL();
DataTable dt = obj.LoadInsuranceDetails();
GV_Insurance.DataSource = dt;
GV_Insurance.DataBind();
for (int i = 0; i < GV_Insurance.Columns.Count; i++)
{
GV_Insurance.Columns[i].ControlStyle.Width = 100;
}
}
protected void GV_Insurance_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.Add("onmouseover", "this.style.cursor='hand';this.style.backgroundColor='DarkGray'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#F7F6F3'");
string ID = e.Row.Cells[0].Text;
e.Row.Attributes.Add("onclick","javascript:return CloseChildWindow('"+ ID +"')");
}
}
// java script //
<script type = "text/javascript">
function CloseChildWindow(ID) {
var resultdata = ID
window.opener.setValue(ID);
window.close();
return false;
}
</script>
In the above code i am getting Insurance Id from child page to parent page, through web method i am getting insurance details from database (because webmethod is static i can't assign a datatable values to textboxes) now how to assign the values to respected textboxes.
Please help me..