Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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"

XML
<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"

JavaScript
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#
C#
[WebMethod]
      public static void GetInsuranceDetails(string Id)
      {
          cls_DAL obj = new cls_DAL();
          DataTable ds = obj.GetInsuranceDetailsbasedonID(Id);
         // return ds;
      }



HERE IS MY CODE "Insurance Search page"

C#
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;
           }
       }



C#
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'");
             //  e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.GV_Insurance, "Select$" + e.Row.RowIndex);

               string ID = e.Row.Cells[0].Text;
               e.Row.Attributes.Add("onclick","javascript:return CloseChildWindow('"+ ID +"')");
           }
       }


// java script //

XML
<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..
Posted
Updated 29-Jan-14 22:57pm
v3

1 solution

Hai
use session variable in child page,i mean if u search insurance in insurance page and get that details in grid view row ,in this place u add session variable and store id and close child page and open reg page,in reg page load event u get that session variable and check it empty or not,if not empty based on insurance id in session variable u can fill the details in reg page,

i think based on insurace id ,in registration page automatically fills details.
pls read about session variable,how to declare and pass,how to get that value in other page


Regards
Aravind
 
Share this answer
 
Comments
Member 8653959 30-Jan-14 5:26am    
Thanks for your answer.

Can i access the session variable without refreshing the reg page?
Is there any limit and length in session variable?
Aravindba 30-Jan-14 5:33am    
session is like a string,what u store in session that same values can get,yes can access without refresh the page,for e.g,if u store session variable in first line in next line u can get that value from session.
Member 8653959 30-Jan-14 5:44am    
i am having address & comment fields, when i pass the value through session (for these fields there is no character limit) do u think session variable can hold that much data..
Aravindba 3-Feb-14 21:56pm    
sorry for late reply,can u clear me address and comment fields are not store in database ? u mention in ur description is,in child page if u click row in a gridview,that ID need to pass in parent page,why u pass whole vlaues(like address,comments ect..) form grid-view(child page) to parrent page.Just store id in session variable and pass to parent page,in parent page load event u can get detalis like address,comments from database based on ID in session and show in parent page.

i think based on insurance id u can get all details,that id u passed in seesion,then why u agin pass all details,

The mail purpose of session is store ID's,name's,flags ,unique values ect... and based on session values u can get data's form databse
Member 8653959 5-Feb-14 5:24am    
thnks very much..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900