【问题标题】:UpdatePanel Repeater ObjectDataSource getting ErrorUpdatePanel 中继器 ObjectDataSource 出现错误
【发布时间】:2014-04-22 05:56:40
【问题描述】:

我开发了一个应用程序,其中使用了 UpdatePanel、Repeater 和 ObjectDataSource。

问题是当我使用这三个时,我收到一个错误,例如 “Sys.WebForms.PageRequestManagerServerErrorException:调用的目标已抛出异常。”

问题仅在 IE8 中出现,而不在本地发生。我的意思是我在 IE8 中的本地机器运行良好,但是当我在 IIS 上托管应用程序时,IE8 创建了一个问题,所有浏览器都运行良好。

下面提到的代码

<asp:HiddenField runat="server" ID="hdnKey" Value="mainAlt" />

        <qfx:label runat="server" ID="Label1" CssClass="subHeading" Text="term_Shares"></qfx:label>
        <asp:Repeater ID="rptShareTypeList"  runat="server">
            <HeaderTemplate>
            </HeaderTemplate>
            <ItemTemplate>
                <div class="shareItem">
                <span class="shareItemButton"></span>
                <span class="shareItemLabel">
                <%#IRAppMgr.Translate(Convert.ToString(Eval("title"))) %>
                <input style="display: none" class="ShareTypeCheckBox" type="checkbox" name='<%#  Eval("key")  %>' value="<%#Eval("Code") %>" <%# Eval("checked12") %> />
                <input class="ShareColor" type="hidden" value="<%#Eval("Color") %>" />
                <input class="ShareCurrency" type="hidden" value="<%#Eval("Currency") %>" />
                </span>
                </div>
            </ItemTemplate>
            <FooterTemplate></FooterTemplate>
        </asp:Repeater>
       <asp:ObjectDataSource ID="SharesTypeDS" runat="server" DataObjectTypeName="Qfx.DataClasses.Config.Option"
            SelectMethod="SelectShareType" TypeName="Qfx.Bases.data.DataManager">
            <SelectParameters>
                <asp:ControlParameter ControlID="ClientMarker" Name="appConfig" PropertyName="Config"
                    Type="Object" />
                <asp:ControlParameter ControlID="ClientMarker" Name="client" PropertyName="Client" />
                <asp:Parameter Name="selection" DefaultValue="ShareType" />
            </SelectParameters>
        </asp:ObjectDataSource>

上述代码在我的 InstrumentSelectionBox.ascx 控件中

在我的 Qfx.Bases.data.DataManager 类中

public List<Option> SelectShareType(object appConfig, string client, string selection, string ShareKey)
    {
        AppConfig config = (AppConfig)appConfig;
        List<Option> Options = null;
        if (config.getSelectionByKey(ShareKey + selection) != null)
            Options = config.getSelectionByKey(ShareKey + selection).Options;
        if (Options != null && Options.Count > 0)
        {
            foreach (Option option in Options)
            {
                if (option.Currency == null && IRAppManager.Manager != null)
                {
                    DataClasses.Share.Instrument inst = IRAppManager.Manager.GetInstrument(option.Key);
                    option.Currency = (inst != null) ? IRAppManager.Manager.Translate(inst.Currency) : "";
                }
                if (option.VolumeDivisor == null || option.VolumeDivisor.Trim() == string.Empty)
                    option.VolumeDivisor = option.VolumeValue;
                option.Code = (config.GetDataSourceByKey(option.Key) != null) ? config.GetDataSourceByKey(option.Key).Code : "";
                if (option.Code != string.Empty)
                {
                    option.TimeStamp = GetTimeStampDetail(option.Code);
                }
            }
        }
        return (config.getSelectionByKey(ShareKey + selection) != null) ? config.getSelectionByKey(ShareKey + selection).Options : new List<Option>();
    }

我已经在更新面板中使用了它

<asp:UpdatePanel ID="upTab" runat="server">
                <ContentTemplate>
                    <uc:InstrumentSelectionBoxrunat="server" ID="UTCInstrumentSelectionBox"></uc:InstrumentSelectionBoxrunat>
                </ContentTemplate>
            </asp:UpdatePanel>

在浏览器控制台中进行一些调试后,我认为由于 ObjectDataSource 发生了错误,所以我删除了 ObjectDataSource 并将转发器正常绑定到 Id 然后它在 IE8 中工作正常。

所以任何人都可以帮助我在使用 ObjectDataSource 时在 IE8 中是否有任何限制,或者我的代码有错误。 你的回应应该得到高度评价。 谢谢

【问题讨论】:

    标签: asp.net ajax updatepanel asprepeater


    【解决方案1】:

    ObjectDataSource 使用反射来调用函数/方法。在特殊情况下,您的方法可能会给出异常。这里是reference thread,请通过调试你的方法。

    【讨论】:

    • 我已经对其进行了测试,该应用程序无法仅在 IE8 上运行,我是否需要为其添加任何元标记。
    • 你的方法调试了吗,调用中没有任何异常/内部异常。
    • 是的,我已经对其进行了调试,但在一个地方我遇到了错误,例如对象引用未设置为 IE8 中的对象实例,而没有进入其他浏览器
    • 能否设置EnableCaching=True,我不确定,但这与缓存或更新面板有关。请试一试。
    • 嘿嘿,谢谢你的帮助,现在已经解决了,因为一个 js 导致了问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-16
    • 2011-01-25
    • 2013-02-19
    • 1970-01-01
    相关资源
    最近更新 更多