在JavaScript中进行更改后,隐藏字段值未在Codebehind上更新

时间:2014-02-26 10:23:39

标签: javascript asp.net vb.net telerik radajaxmanager

<asp:Panel runat="server" ID="mainPnl">
    <asp:Calendar FirstDayOfWeek="Monday" WeekendDayStyle-CssClass="weekendStyle" ID="TCInBound"
        runat="server" CssClass="calendar" DayStyle-CssClass="DayStyle" DayHeaderStyle-CssClass="DayHeaderStyle"
        CellPadding="0" CellSpacing="0" TitleStyle-CssClass="TitleStyle" OnDayRender="TCInBound_DayRender"
        OnVisibleMonthChanged="TCInBound_VisibleMonthChanged" NextPrevFormat="CustomText"
        NextPrevStyle-HorizontalAlign="Left" TitleForvermat="MonthYear" Width="100%" Visible="false"
        UseAccessibleHeader="false"></asp:Calendar>
    <asp:HiddenField ID="hdnPrefAirlineCodes" runat="server" />
</asp:Panel>
<telerik:radajaxmanager id="RadAjaxManager1" runat="server" clientevents-onrequeststart="start">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="TCInBound">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="mainPnl" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:radajaxmanager>

以下是JavaScript

function start(sender, args) {
    var hdnPrefAirlineCodes = '<%=hdnPrefAirlineCodes.ClientID %>';
    $('#' + hdnPrefAirlineCodes).val('');
}

当我点击日历上的任何事件时,它工作正常但隐藏值在代码隐藏时未设置为null。我想在代码隐藏时更新隐藏字段值。

2 个答案:

答案 0 :(得分:0)

使用标准的微软和dom技术可能更好,试试这个:

function start(sender, args) {
    $get("<%= hdnPrefAirlineCodes.ClientID %>").value = "";
}

告诉我它是否有效!

答案 1 :(得分:0)

以下是在JavaScript中将隐藏字段设置为null的方法:

function start(sender, args) {
    document.getElementById("hdnPrefAirlineCodes").value = null;
}