English 中文(简体)
问题 - Update Panel 中的任何隐藏字段均未得到更新
原标题:Problem - any hidden field in Update Panel does not get updated
  • 时间:2010-02-08 12:18:43
  •  标签:
  • asp.net

我正在使用C#进行编程。

我面对的问题是,当隐藏变量在更新面板内时,其值未得到更新。请参见下面的aspx代码:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:Timer ID="Timer1" runat="server" Interval="10000" OnTick="Timer1_Tick">
        </asp:Timer>
        <input type="hidden" runat="server" id="hidCurrentDate" value="" />
        <input type="hidden" runat="server" id="hidTripIds" value="" />
        <input type="hidden" runat="server" id="hidTripDetails" value="" />

<asp:UpdateProgress ID="uprogTrips" runat="server">
            <ProgressTemplate>
                <span style="display: block; text-align: center">
                    <p style="font-family: Verdana; font-size: larger; font-weight: bold;">
                        <img src="../../Images/ajax-loader.gif" alt="Processing..." /><br />
                        <br />
                        Processing...</p>
                </span>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <asp:UpdatePanel ID="upTripsGrid" runat="server" UpdateMode="Always">
            <ContentTemplate>
                <asp:GridView ID="gvAllTrips" runat="server" OnRowDataBound="gvAllTrips_RowDataBound"
                    OnPageIndexChanging="gvAllTrips_PageIndexChanging" AllowPaging="true" AutoGenerateColumns="false">
                    <PagerSettings Mode="NumericFirstLast" PageButtonCount="35" Position="TopAndBottom" />
                    <PagerStyle CssClass="GridPager" />                    
                </asp:GridView>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
                <asp:AsyncPostBackTrigger ControlID="ddSortBy" EventName="SelectedIndexChanged" />
                <asp:AsyncPostBackTrigger ControlID="ddFilterBy" EventName="SelectedIndexChanged" />
                <asp:AsyncPostBackTrigger ControlID="cbPageOptions" EventName="CheckedChanged" />
            </Triggers>
</asp:UpdatePanel>

以下是我正在尝试使用我的 CS 代码更新其中一个隐藏字段的代码。

有趣的是,当我试图贬低它显示了所有价值时,尽管我看到它出现在页头上,它却没有任何价值。

这里是我的牛肉法典:

protected void Timer1_Tick(object sender, EventArgs e)
{
    DataTable dtTrips = null;
    WEX.Prototype.Data.TripDA tripDA = new WEX.Prototype.Data.TripDA();
    string tID = hidTripIds.Value;
    string[] tripIDs = new string[1000];
    tripIDs = tID.Split( , );


    foreach (string tripID in tripIDs)
    {
        TripSummaryBO tripSummaryBO = tripDA.getTripSummary(Convert.ToInt32(tripID));
        if (tripSummaryBO.tripLastEditedOnDate > Convert.ToDateTime(hidCurrentDate.Value))
        {

            WEX.Prototype.Service.WSProxies WSProxies = new WEX.Prototype.Service.WSProxies();
            dtTrips = WSProxies.Build();
            Session["AllTrips"] = dtTrips;
            dtTrips = (DataTable)Session["AllTrips"];
            if (dtTrips != null)
            {
                if (cnt==0)
                {
                    hidTripDetails.Value = ("Trip name-" + tripSummaryBO.tripName + " was modified by user " + tripSummaryBO.tripLastEditedBy);
                }
                else
                {
                    hidTripDetails.Value = hidTripDetails.Value + " <br/> " + ("Trip name-" + tripSummaryBO.tripName + " was modified by user " + tripSummaryBO.tripLastEditedBy);
                }
                BuildGridViewControl(dtTrips);
                cnt = cnt + 1;
            }
        }
        else
        {
            //upTripsGrid.Triggers.Clear();
            PageInit();
        }            
    }
}

请建议。

谢谢。 (xiè xiè.)

最佳回答

你隐藏的投入领域不属于更新后的小组控制范围。 对服务器的任何同步回航只能导致在<条码>上查询<>条码/代码”内进行这些控制,以更新《国际统一标准》,即使密码背后操作和更新隐蔽领域,在头端,由于它们坐在小组之外,它们保持相同。

在<代码><ContentTemplate>栏内转移隐蔽领域:

<asp:UpdatePanel ID="upTripsGrid" runat="server" UpdateMode="Always">
    <ContentTemplate>
        <input type="hidden" runat="server" id="hidCurrentDate" value="" />
        <input type="hidden" runat="server" id="hidTripIds" value="" />
        <input type="hidden" runat="server" id="hidTripDetails" value="" />
        ....
    </ContentTemplate>
</asp:UpdatePanel>
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签