使用ajax和java脚本刷新部分页面 [英] Partial Page refresh using ajax and java script

查看:122
本文介绍了使用ajax和java脚本刷新部分页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

-------------------------------

我对更新面板有误解。我以为它正在进行部分回发。但实际情况是,它将整个视图状态发送到服务器,整个控制树发送到服务器,但只更新更新面板内部的页面部分。



http://msdn.microsoft.com/en-us/magazine/cc163413.aspx [ ^ ]



因此,在重页上使用更新面板,我需要更新页面的一部分是性能问题。



我的问题我可以通过一些java脚本/ xml更新一个页面面板(其中包含gridview)。有没有出路



详情

-------------------- ----

我有一个显示类别的网格。内部类别网格中有项目网格。在内部项目网格中有子项目网格。在subitems网格中有添加按钮。单击此按钮可将项目添加到第四个网格(订单)。但响应时间很晚。所以我想发送行的子项的id,其中按钮被单击到服务器以将其添加到会话,然后更新订单网格。





Hello there
-------------------------------
I was having misconception towards update panel. I thought it is doing partial postbacks. But actual story is that it sends whole viewstate to the server, whole control tree to the server but updates only the part of page that is inside of the update panel.

http://msdn.microsoft.com/en-us/magazine/cc163413.aspx[^]

So by using update panel on a heavy page where i need to update a portion of page is having performance issue.

My question is can i update just one panel of page (that is having gridview in it) by some java script/xml. is there a way out

Details
------------------------
I have a grid displaying categories. inside categories grid there is items grid. and inside items grid there is subitems grid. in subitems grid there is add button. clicking on this button add item to the fourth grid (Orders). but the response time is late. so i want to send just id of the subitem of the row in which button is clicked to server to add it to session and then update orders grid.


<asp:GridView ID="grdItems" runat="server" AutoGenerateColumns="false" CssClass="active-grid"

                                            DataKeyNames="Item" OnRowDataBound="grdItems_RowDataBound" ShowHeader="false"

                                            EnableViewState="false">
                                            <Columns>
                                                <asp:TemplateField>
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblItem" runat="server" Text='<%#Eval("Item") %>' Visible="false"></asp:Label>
                                                        <asp:Label ID="lblItemX" CssClass="title" runat="server" Text='<%#Eval("ItemX") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField>
                                                    <ItemTemplate>
                                                        <asp:GridView ID="grdSubItems" runat="server" AutoGenerateColumns="false" CssClass=""

                                                            DataKeyNames="SubItem" ShowHeader="false" EnableViewState="false">
                                                            <HeaderStyle HorizontalAlign="Left" />
                                                            <Columns>
                                                                <asp:TemplateField>
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblItem" runat="server" Text='<%#Eval("Item") %>' Visible="false"></asp:Label>
                                                                        <asp:Label ID="lblSubItem" runat="server" Text='<%#Eval("SubItem") %>' Visible="false"></asp:Label>
                                                                        <asp:Label ID="lblNoofOptions" runat="server" Text='<%#Eval("NumofOptions") %>' Visible="false"></asp:Label>
                                                                        <asp:Label ID="lblSubItemX" CssClass="qty" runat="server" Text='<%#Eval("SubItemX") %>'></asp:Label>
                                                                    </ItemTemplate>
                                                                </asp:TemplateField>
                                                                <asp:TemplateField>
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblPrice" runat="server" CssClass="price" Text='<%#String.Format("£{0}",Eval("SellingCost")) %>'></asp:Label>
                                                                    </ItemTemplate>
                                                                </asp:TemplateField>
                                                                <asp:TemplateField>
                                                                    <ItemTemplate>
                                                                        <asp:LinkButton ID="lnkOrder" runat="server" OnClick="lnkOrder_Click">Order</asp:LinkButton>
                                                                    </ItemTemplate>
                                                                    <ItemStyle CssClass="add"></ItemStyle>
                                                                </asp:TemplateField>
                                                            </Columns>
                                                        </asp:GridView>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                        </asp:GridView>

推荐答案

是的,更新面板执行回发但页面部分呈现。如果您想避免这种情况并且可以直接访问,可以使用Callback或PageMethods。



以下将帮助您:

1. Web应用程序的ClientCallback自定义控件 [ ^ ]& 回调 [ ^ ]

2. PageMethod [ ^ ]



试试你认为合适的。
Yes, update panel does a postback but page is partially rendered. If you want to avoid this and have direct access, you can use Callback or PageMethods.

Following will help you:
1. ClientCallback custom control for web applications[^] & Callback[^]
2. PageMethod[^]

Try that you find fit.


这篇关于使用ajax和java脚本刷新部分页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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