替代回发asp.net页面 [英] Alternative to Postback on asp.net page

查看:255
本文介绍了替代回发asp.net页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找的地方用户犯规必须等待在回发一个asp.net页面的替代品。
我的情况:
我有几个下拉我的asp.net页面(11 INFACT)在列表和我有一个复选框。 2下拉列表的级联。即选择第一个下拉改变了第二个下拉内容。我有一些下拉菜单(6下拉菜单)的一个新的选择。如果用户选择此选项,然后在文本框中显示了一个添加按钮。添加文本到文本框,打添加,增加了新的价值,下拉并消失这个文本框和按钮。因此,有可能是使用非回传选项,但有同样的情况怎么回事?用户不喜欢该页面回传11次。什么是我的选择吗?如果您需要了解更多信息,请询问。谢谢

编辑:

 < ASP:的UpdatePanel ID =UpdatePanel1=服务器的UpdateMode =条件>
                                                        <&的ContentTemplate GT;
                                                            < ASP:DropDownList的ID =ddlCustomerContact=服务器DataTextField =全名DataValueField =Customers_SourceIDfk2的AutoPostBack =真的TabIndex =1/>
                                                        < /&的ContentTemplate GT;
                                                    < / ASP:的UpdatePanel>   保护小组ddlCustomerContact_SelectedIndexChanged(发送者为对象,E作为EventArgs的)把手ddlCustomerContact.SelectedIndexChanged
    如果ddlCustomerContact.SelectedIndex = 1,则
        divAddNewCustomerContact.Visible = TRUE
    其他
        divAddNewCustomerContact.Visible = FALSE
    万一
结束小组


解决方案

这是我如何使用更新面板,我创建了一个小部件。

 < ASP:DropDownList的ID =ddlPayrollStores=服务器OnSelectedIndexChanged =ddlPayrollStores_SelectedIndexChanged的AutoPostBack =真>
        < / ASP:DropDownList的>
        < ASP:的UpdatePanel ID =UpdatePanelPayroll=服务器>
            <&触发器GT;
                < ASP:AsyncPostBackTrigger控件ID =ddlPayrollStores事件名称=的SelectedIndexChanged>< / ASP:AsyncPostBackTrigger>
            < /触发器>
            <&的ContentTemplate GT;
                < D​​IV CLASS =dragbox内容>
                    < ASP:标签ID =lblLabelHours=服务器文本=注册时间:WIDTH =350像素>< / ASP:标签>
                    < ASP:标签ID =lblTotalHours=服务器文本=>< / ASP:标签>
                    < BR />
                    < BR />
                    < ASP:标签ID =lblLabelOverTime=服务器文本=总计加班时间:WIDTH =350像素>< / ASP:标签>
                    < ASP:标签ID =lblTotalOvertime=服务器文本=>< / ASP:标签>
                    < BR />
                    < BR />
                    < ASP:标签ID =lblLabelHoliday=服务器文本=假日总:WIDTH =350像素>< / ASP:标签>
                    < ASP:标签ID =lblTotalHoliday=服务器文本=>< / ASP:标签>
                    < BR />
                    < BR />
                    < ASP:标签ID =lblLabelVacation=服务器文本=总建筑:WIDTH =350像素>< / ASP:标签>
                    < ASP:标签ID =lblTotalVacation=服务器文本=>< / ASP:标签>
                    < BR />
                    < BR />
                    < ASP:标签ID =lbllableTotalHours=服务器文本=总计:WIDTH =350像素>< / ASP:标签>
                    < ASP:标签ID =lblTotalStoreHours=服务器文本=>< / ASP:标签>
                    < BR />
                    < BR />
                    < ASP:标签ID =lblLabelPay=服务器文本=总薪酬:WIDTH =350像素>< / ASP:标签>
                    < ASP:标签ID =lblTotalPay=服务器文本=>< / ASP:标签>
                    < BR />
                    < BR />
                    < D​​IV的风格=对齐内容:中心>
                        < ASP:LinkBut​​ton的ID =lbDetailed=服务器文本=详细报告一项PostBackUrl =〜/报告/薪酬/ StorePayroll.aspx>< / ASP:LinkBut​​ton的>
                    < / DIV>
                < / DIV>
            < /&的ContentTemplate GT;
        < / ASP:的UpdatePanel>

这是一个工资的小工具,显示了商店的工资总额。所以,当我选择我想看到下拉用来存储,更新面板会回来后没有回发整个页面。就我而言,它只会显示数字的标签。希望这会导致你在正确的方向,并可能将其清除了一下。

I am looking for an alternative where user doesnt has to wait for postback in an asp.net page. My situation : I have several drop down lists on my asp.net page (11 infact) and I have a checkbox. 2 drop downs are cascading. i.e. selecting 1st drop down changes the 2nd drop down contents. I have a new option in some of the dropdowns (6 drop downs). If user chooses this option then a text box shows up with a "Add" button. Adding text to that text box and hitting "Add" adds the new value to the drop down and disappears this textbox and the button. So is it possible for using a non postback option but have the same situation going on? User does not like that the page postbacks 11 times. What is my alternative? If you need more information, please ask. Thanks

EDIT:

 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                                        <ContentTemplate>
                                                            <asp:DropDownList ID="ddlCustomerContact" runat="server" DataTextField="FullName" DataValueField="Customers_SourceIDfk2" AutoPostBack="true" TabIndex="1" />
                                                        </ContentTemplate>
                                                    </asp:UpdatePanel>  

   Protected Sub ddlCustomerContact_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlCustomerContact.SelectedIndexChanged
    If ddlCustomerContact.SelectedIndex = 1 Then
        divAddNewCustomerContact.Visible = True
    Else
        divAddNewCustomerContact.Visible = False
    End If
End Sub

解决方案

This is how I use an update panel for a widget that I created.

<asp:DropDownList ID="ddlPayrollStores" runat="server" OnSelectedIndexChanged="ddlPayrollStores_SelectedIndexChanged" AutoPostBack="true">
        </asp:DropDownList>
        <asp:UpdatePanel ID="UpdatePanelPayroll" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ddlPayrollStores" EventName="SelectedIndexChanged"></asp:AsyncPostBackTrigger>
            </Triggers>
            <ContentTemplate>
                <div class="dragbox-content">
                    <asp:Label ID="lblLabelHours" runat="server" Text="Reg Hours: " Width="350px"></asp:Label>
                    <asp:Label ID="lblTotalHours" runat="server" Text=""></asp:Label>
                    <br />
                    <br />
                    <asp:Label ID="lblLabelOverTime" runat="server" Text="Total Overtime Hours: " Width="350px"></asp:Label>
                    <asp:Label ID="lblTotalOvertime" runat="server" Text=""></asp:Label>
                    <br />
                    <br />
                    <asp:Label ID="lblLabelHoliday" runat="server" Text="Total Holiday: " Width="350px"></asp:Label>
                    <asp:Label ID="lblTotalHoliday" runat="server" Text=""></asp:Label>
                    <br />
                    <br />
                    <asp:Label ID="lblLabelVacation" runat="server" Text="Total Vacation: " Width="350px"></asp:Label>
                    <asp:Label ID="lblTotalVacation" runat="server" Text=""></asp:Label>
                    <br />
                    <br />
                    <asp:Label ID="lbllableTotalHours" runat="server" Text="Total Hours: " Width="350px"></asp:Label>
                    <asp:Label ID="lblTotalStoreHours" runat="server" Text=""></asp:Label>
                    <br />
                    <br />
                    <asp:Label ID="lblLabelPay" runat="server" Text="Total Pay: " Width="350px"></asp:Label>
                    <asp:Label ID="lblTotalPay" runat="server" Text=""></asp:Label>
                    <br />
                    <br />
                    <div style="align-content: center">
                        <asp:LinkButton ID="lbDetailed" runat="server" Text="Detailed Report" PostBackUrl="~/Reporting/Payroll/StorePayroll.aspx"></asp:LinkButton>
                    </div>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>

This is for a payroll widget that shows the store's total payroll. So when I select which store I want to see with the drop down, the update panel will post back without posting back the entire page. In my case, it will just display numbers as labels. Hopefully this leads you in the right direction and possibly clears it up a bit.

这篇关于替代回发asp.net页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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