我已經使用ASP.NET MVC,當我有例如下拉列表 - 我必須檢查選定的值是否正確,因爲用戶可以使用例如Firebug更改下拉列表上的值。DropDownList/RadioButtonList - 我不需要驗證選定的值?
我是ASP.NET Web Forms中的新成員。我有例如:
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="1">One</asp:ListItem>
<asp:ListItem Value="2">Two</asp:ListItem>
</asp:DropDownList>
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="1" Selected="True">One</asp:ListItem>
<asp:ListItem Value="2">Two</asp:ListItem>
</asp:RadioButtonList>
我在螢火蟲選擇的值已經改變在DropDownList1 3和RadioButtonList1 3和提交表單。然後我有錯誤: 回發或回調參數無效。事件驗證在配置中啓用,或在頁面中啓用<%@ Page EnableEventValidation =「true」%>。爲了安全起見,此功能驗證回發或回調事件的參數來自最初呈現它們的服務器控件。如果數據是有效的和預期,使用ClientScriptManager.RegisterForEventValidation方法,以註冊VA回發或回調數據...
這是否意味着我不需要驗證,因爲用戶可以選擇的值不改變它?
你是什麼意思用戶不能改變它?你剛剛做到了。只有當你知道你在做什麼時,它基本上只會告訴你將'EnableEventValidation'設置爲'false'。 – nphx
所以我很安全,我不需要檢查選定的值是否在列表中? – michael
閱讀@Tallmaris答案,我意識到你問你是否需要做服務器端驗證。檢查他的答案;)。 – nphx