EncoderType AntiXssEncoder 与 DevExpress 控件冲突
当 web.config 中给出编码器类型时,DevExpress 控件 ASPxComboBox 返回 -1 作为选定索引
这是我的 DevExpress 控件:
<dx:ASPxComboBox ID="txtPaymentProvider" runat="server" Width="170px">
<ClientSideEvents SelectedIndexChanged="function(s, e) { Common.PerformCallback(gvProviderSettings, 'Refresh'); Common.PerformCallback(gvOptionalSettings, 'Refresh'); }" />
<Items>
<dx:ListEditItem Text="Worldpay" Value="Web.PaymentProviders.HotelWorld, Library.Web.PaymentProviders" />
<dx:ListEditItem Text="RealEx" Value="Web.PaymentProviders.HotelReal, Library.Web.PaymentProviders" />
</Items>
</dx:ASPxComboBox>
这是后面的代码:
private void LoadProviderSpecificSettings()
{
if (txtPaymentProvider.SelectedIndex > -1)
{
HotelPaymentProvider provider = SessionManager.CurrentOperator.GetPaymentProvider(txtPaymentProvider.Items[txtPaymentProvider.SelectedIndex].Value.ToString());
}
}
如果我禁用编码器类型,则一切都会按预期工作。
<httpRuntime enableVersionHeader="false" requestValidationMode="2.0" maxRequestLength="4096" executionTimeout="110" encoderType="System.Web.Security.AntiXss.AntiXssEncoder" requestPathInvalidCharacters="<,>,*,:" />
DevExpress control ASPxComboBox is returning -1 as selected index when encoderType is given in web.config
Here is my DevExpress control:
<dx:ASPxComboBox ID="txtPaymentProvider" runat="server" Width="170px">
<ClientSideEvents SelectedIndexChanged="function(s, e) { Common.PerformCallback(gvProviderSettings, 'Refresh'); Common.PerformCallback(gvOptionalSettings, 'Refresh'); }" />
<Items>
<dx:ListEditItem Text="Worldpay" Value="Web.PaymentProviders.HotelWorld, Library.Web.PaymentProviders" />
<dx:ListEditItem Text="RealEx" Value="Web.PaymentProviders.HotelReal, Library.Web.PaymentProviders" />
</Items>
</dx:ASPxComboBox>
And here is the code behind:
private void LoadProviderSpecificSettings()
{
if (txtPaymentProvider.SelectedIndex > -1)
{
HotelPaymentProvider provider = SessionManager.CurrentOperator.GetPaymentProvider(txtPaymentProvider.Items[txtPaymentProvider.SelectedIndex].Value.ToString());
}
}
If I disable the encoderType, everything then works as expected.
<httpRuntime enableVersionHeader="false" requestValidationMode="2.0" maxRequestLength="4096" executionTimeout="110" encoderType="System.Web.Security.AntiXss.AntiXssEncoder" requestPathInvalidCharacters="<,>,*,:" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于面临此问题的人,我通过删除
的 value 属性中的空格解决了此问题。我目前使用的是旧版本的 DevExpress,它导致了此问题,因此您可以更新到较新的版本,也可以像这样修复此错误。作为参考,我附上了 DevExpress 的链接,其中报告了类似的错误。https://supportcenter.devexpress.com/ticket/details/T284458/aspxcombobox-selectedindex-is-always-1-when-text-contains-a-new-line
For someone facing this issue, I resolved this by removing the space in value attribute of
<dx:ListEditItem />
. I am currently using an older version of DevExpress which is causing this issue so either you can update to newer one or can fix this bug like this. For reference I am attaching the link to DevExpress where a similar bug was reported.https://supportcenter.devexpress.com/ticket/details/T284458/aspxcombobox-selectedindex-is-always-1-when-text-contains-a-new-line