views:

85

answers:

1

I am using this drop list filter on my Asp.Net Form.
jQuery plugin DropListFilter

The filter on the dropdownlist list works perfecty.

<script type="text/javascript">
 $(document).ready(function() {
  $('select').droplistFilter();
});
</script>
<asp:DropDownList ID="ddlMonth" runat="server" CssClass="ddlStyle"></asp:DropDownList>
<asp:RequiredFieldValidator ID="rfv_ddlMonth" runat="server" ControlToValidate="ddlMonth"
                    CssClass="warning" Display="Dynamic" ErrorMessage="*" ForeColor=""></asp:RequiredFieldValidator>

<asp:Button ID="btnRun" runat="server" CssClass="btnStyle" OnClick="btnRun_Click" Text="Run Report" />

CodeBehind

protected void btnRun_Click(object sender, EventArgs e)
{
    Response.Write(ddlMonth.SelectedValue.ToString());
    return;
}

If I do a search on the dropdownlist using the jQuery filter and click run report, the debugger does not stop at the above Response.Write statement.

On application of the filter and pressing Run the debugger does not even hit the load method below.

protected void Page_Load(object sender, EventArgs e)
{
  // Bind Month if !PostBack
}

Upon further investigating I am getting the following error on the Application_Error:

Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

I do not want to disable the event validation, so what can I do to make the filter work?

A: 

The droplistFilter is changing what is being expected by ASP.

ASP doesn't like it when things are changed without it's explicit written consent.

ASP is expecting that dropdown to contain what it put in the dropdown, when you change what is in that with javascript asp sees that as a security risk and is giving you the validation error.

Aaron