我怎么能只刷新一个GridView中使用JavaScript父窗口? [英] How can I refresh only a GridView in a parent window with JavaScript?
问题描述
我从销售添加/删除产品/双ASPX文件。
- islemler.aspx
- SatisTedarik.aspx
我在islemler.aspx一个GridView,该GridView的名字是 islemlerGridView
当行的 islemlerGridView
选择会出现一个按钮,该按钮的名称为 islemDetayGorButton
。
点击 islemDetayGorButton
SatisTedarik.aspx打开。在SatisTedarik.aspx有很多元素,如标签,文本框,dropdownlists,GridView的,并且通过此SatisTedarik.aspx窗口,用户可以添加/删除产品/出售(销售在 islemlerGridView $所示C $ C>)。
我需要做的是,更新 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
。
例如,
- 假设
islemlerGridView
节目
出售ID,销售总金额。 - 而让我们说我有在销售点¯x
该产品A销售和产品
一个成本10块钱。 - 我选择出售X月
islemlerGridView
和islemDetayGorButton
出现那么我
点击这个按钮,它会打开
SatisTedarik.aspx。 - 在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)
链接我检查,发现好东西:
我创建了一个名为一个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.
- islemler.aspx
- 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,
- suppose
islemlerGridView
shows sale id and sale total money. - And let's say I have Sale X in which Product A is sold and Product A costs 10 money.
- I am choosing Sale X on
islemlerGridView
andislemDetayGorButton
appears then I click this button and it opens SatisTedarik.aspx. - 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:
- Javascript - Refresh Parent Window?
- refresh parent after closing pop up window
- Refreshing parent window
- Refresh the parent window from the child window in javascript
- 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屋!