hiddenfiels更改的事件.将子窗口参数传递给父窗口文本框 [英] hiddenfiels changed event. pass child window parameters to parent window textboxes

查看:164
本文介绍了hiddenfiels更改的事件.将子窗口参数传递给父窗口文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在子窗口中单击按钮时,我将执行一些操作来更新数据库.
因此,仅在执行操作后,此更改才会反映在父窗口文本框中.

为此,我编写了一个javascript函数,并在按钮上单击了click(attribute.add("onclick" .....),我将此脚本称为javascript,依次调用了服务器端函数,以便从数据库中获取2个值并传递这些值javascript函数的参数.
然后,我使用给定的2个参数更新hiddenfield值,然后调用父窗口函数来更新这些值.

但是问题是,在第一次单击按钮时,父窗口没有更新.当我第二次单击时,它已更新,但是我需要在立即单击该按钮时执行此操作.

父窗口javascript:

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



子窗口javascript:



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);
    }

推荐答案

尝试使用"onpropertychange"选项
try with "onpropertychange" option


尝试以下代码.

Try this code.

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());
}


这篇关于hiddenfiels更改的事件.将子窗口参数传递给父窗口文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆