Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,
On click of button in child window I perform some operations that update the database.
So this change is to be reflected in parent window textboxes after the performance of operation only.

For this I wrote a javascript function and on button click(attribute.add("onclick".....") I call this javascript which, in turn, calls server side function in order to get 2 values from database and pass these parameters to the javascript function.
Then I update the hiddenfield values with the given 2 parameters and then call the parent window function to update the values.

But the problem is the parent window is not being updated on when the button is clicked first click. When I click the second time it is updated, but i need to do this on immediate click of the button.

parent window javascript :
function GetSubTotalGrandTotalFromChild(SubTotal,GrandTotal)
 {
  document.getElementById(ctl00_ContentPlaceHolder1_frmPurchaseOrder_SubTotalAmountTextBox).value=SubTotal;
        document.getElementById(ctl00_ContentPlaceHolder1_frmPurchaseOrder_GrandTotalTextBox).value=GrandTotal;
        return true;
    }


child window javascript :

function SendSubTotalGrandTotalToParent()
    {        
        PageMethods.CallGetSubTOtalGrandTotalForPO(purchaseOrderId,OnGetMessageSuccess, OnGetMessageFailure);
        var SubTotal = document.getElementById(ctl00_ContentPlaceHolder1_hideSubTotal).value;
        var GrandTotal = document.getElementById(ctl00_ContentPlaceHolder1_hideGrandTotal).value;
        window.opener.GetSubTotalGrandTotalFromChild(SubTotal,GrandTotal);
        return true;
    }



serverside procedure

[WebMethod(EnableSession = true)]
    public static string CallGetSubTOtalGrandTotalForPO(string queryStringPoId)
    {
        string subTotalQty;
        string grandTotalQty;
        int purchaseorderid;
        purchaseorderid = Convert.ToInt32(queryStringPoId);
        GetSubTOtalGrandTotalForPO1(purchaseorderid,out subTotalQty, out grandTotalQty);
        return string.Format("{1}{0}{2}{0,subTotalQty,grandTotalQty);
    }
Posted
Updated 24-Oct-10 21:46pm
v2
Comments
Dalek Dave 25-Oct-10 3:47am    
Edited for Grammar, Syntax and Code Blocks.

try with "onpropertychange" option
 
Share this answer
 
Try this code.

JavaScript
function SendSubTotalGrandTotalToParent()
{           PageMethods.CallGetSubTOtalGrandTotalForPO(purchaseOrderId,OnGetMessageSuccess, OnGetMessageFailure);
 return false;
}

function OnGetMessageSuccess(_strResult)
{
      _strResult=_strResult.split('|');
      SubTotal=_strResult[0];
      GrandTotal=_strResult[1];alert(SubTotal);
      window.opener.GetSubTotalGrandTotalFromChild(SubTotal,GrandTotal);
}

function OnGetMessageFailure(_strResult)
{
  alert(_strResult.get_message());
}
 
Share this answer
 
v2
Comments
Ankur\m/ 25-Oct-10 5:14am    
Use PRE tags (code block) to surround your code snippet for better readability.

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