我怎么能只刷新一个GridView中使用JavaScript父窗口? [英] How can I refresh only a GridView in a parent window with JavaScript?

查看:91
本文介绍了我怎么能只刷新一个GridView中使用JavaScript父窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从销售添加/删除产品/双ASPX文件。


  1. islemler.aspx

  2. SatisTedarik.aspx

我在islemler.aspx一个GridView,该GridView的名字是 islemlerGridView 当行的 islemlerGridView 选择会出现一个按钮,该按钮的名称为 islemDetayGorButton

点击 islemDetayGorButton SatisTedarik.aspx打开。在SatisTedarik.aspx有很多元素,如标签,文本框,dropdownlists,GridView的,并且通过此SatisTedarik.aspx窗口,用户可以添加/删除产品/出售(销售在 islemlerGridView )。

我需要做的是,更新 islemlerGridView 时,一些有关的销售通过SatisTedarik.aspx被改变。

我发现这个问题,<一个href=\"http://stackoverflow.com/questions/2091772/passing-value-from-popup-window-to-parent-forms-textbox\">Passing从弹出的窗口中值父窗体的文本框
并试图用JavaScript的东西,我得说我没有JavaScript的经验。
我试图刷新首战窗口,并在我的病情首战窗口islemler.aspx我用下面的code对SatisTedarik.aspx:

 &LT;脚本类型=文/ JavaScript的&GT;
        函数f2(){
            。opener.document.getElementById(TextBox1中)值=的Hello World; //这是刚刚从那个例子中的链接            opener.document.location.reload(真); //这就是我刷新islemler.aspx        }
&LT; / SCRIPT&GT;

这是使用 F2()

按钮

 &LT;输入类型=按钮值=重返世界你好的onclick =F2(); /&GT;

这是code刷新islemler.aspx而是通过SatisTedarik.aspx作出canges不会反映在 islemlerGridView

例如,


  1. 假设 islemlerGridView 节目
    出售ID,销售总金额。

  2. 而让我们说我有在销售点¯x
    该产品A销售和产品
    一个成本10块钱。

  3. 我选择出售X月
    islemlerGridView
    islemDetayGorButton 出现那么我
    点击这个按钮,它会打开
    SatisTedarik.aspx。

  4. 在SatisTedarik.aspx我加入
    产品B花费5钱
    销售X和保存。

最后,我点击它采用键F2()并刷新islemler.aspx但销售X的销售总金额的细胞仍然是10块钱,但是我需要它为15钱,我添加了一个新的产品上销售。

所以,我的第一个问题是我应该怎样做才能得到预期的结果?的(解决

问:其次,有没有什么办法可以只刷新islemlerGridView而不是整个页面

确定事实证明,这是在为我的第一个问题

  window.opener.location.href = window.opener.location.href;

所以我的第一个问题有一个答案了。

问:有什么办法,我可以只刷新 islemlerGridView 而不是整个页面

(我尝试了所有这些IE9和Mozilla Firefox 4)

链接我检查,发现好东西:


  1. 使用Javascript - 刷新父
    窗口?

  2. 关闭弹出后
  3. 刷新父
    窗口

  4. 刷新父窗口

  5. Refresh从父窗口
    在JavaScript子窗口

  6. Refresh从子父窗口
    窗口使用JavaScript


解决方案

我创建了一个名为一个UpdatePanel GridRefreshPanel ,我把格成面板,并使用该

 函数f2(){
              window.opener .__ doPostBack('GridRefreshPanel.ClientID','');
              //window.opener.__doPostBack('islemlerGridView.ClientID',''); //这也是工作不GridRefreshPanel
        }

I have two aspx files for adding/deleting products to/from a sale.

  1. islemler.aspx
  2. SatisTedarik.aspx

I have a GridView in islemler.aspx, this gridView's name is islemlerGridView when a line is selected on islemlerGridView a button appears, and name of this button is islemDetayGorButton.

When islemDetayGorButton is clicked SatisTedarik.aspx is opened. On SatisTedarik.aspx there are many elements such as labels, textboxes, dropdownlists, gridviews and via this SatisTedarik.aspx window user can add/delete a product to/from sale(sales are shown in islemlerGridView).

What I need to do is, to update islemlerGridView when something about the sale is changed via SatisTedarik.aspx.

I found this question Passing value from popup window to parent form's TextBox and tried something with JavaScript and I gotta say I do not have JavaScript experience. I tried refreshing the opener window, and in my condition opener window is islemler.aspx I used the below code on SatisTedarik.aspx:

<script type="text/javascript">
        function f2() {
            opener.document.getElementById("TextBox1").value = "hello world";//this is just from that example in the link

            opener.document.location.reload(true);//that is how I refresh islemler.aspx

        } 
</script> 

And this is the button which uses f2()

<input type="button" value="return hello world" onclick="f2();" />

Yes this code refreshes islemler.aspx but the canges made via SatisTedarik.aspx is not reflected on islemlerGridView.

For example,

  1. suppose islemlerGridView shows sale id and sale total money.
  2. And let's say I have Sale X in which Product A is sold and Product A costs 10 money.
  3. I am choosing Sale X on islemlerGridView and islemDetayGorButton appears then I click this button and it opens SatisTedarik.aspx.
  4. In SatisTedarik.aspx I am adding Product B which costs 5 money to Sale X and save it.

At last, I click the button which uses f2() and it refreshes islemler.aspx but Sale X's sale total money cell is still 10 money, however I need it to be 15 money as I added a new product on that sale.

So my first question is what am i supposed to do to get expected result?(solved)

Question : Secondly, is there any way I can refresh only islemlerGridView but not the whole page?

Ok it turns out this is working for my first question

window.opener.location.href = window.opener.location.href; 

so my first question has an answer now.

Question : is there any way I can refresh only islemlerGridView but not the whole page?

(I tried all those in IE9 and Mozilla Firefox 4)

Links I've checked and found something good:

  1. Javascript - Refresh Parent Window?
  2. refresh parent after closing pop up window
  3. Refreshing parent window
  4. Refresh the parent window from the child window in javascript
  5. Refresh parent window from child window using javascript

解决方案

I created an UpdatePanel named GridRefreshPanel and I put the grid into that panel and used this

function f2() {
              window.opener.__doPostBack('GridRefreshPanel.ClientID', '');    
              //window.opener.__doPostBack('islemlerGridView.ClientID', ''); //this is also working without GridRefreshPanel 
        } 

这篇关于我怎么能只刷新一个GridView中使用JavaScript父窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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