ClientScriptManager.RegisterForEventValidation trouble

Discussion in 'ASP .Net' started by Zac, Nov 7, 2007.

  1. Zac

    Zac Guest

    Hello!

    Maybe someone out there can point me int he correct direction for a
    fix to a problem I'm having. I've setup a user control with two list
    boxes. One starts with a full list of items, the other one completely
    empty. I've setup a client-side javascript function that allows the
    user to move items from one list box to the other and back as a way of
    'selecting' which options they want. The user control is set in a
    server side form. When I click the save button that posts back to the
    server, I get the following error:

    Invalid postback or callback argument. Event validation is enabled
    using <pages enableEventValidation="true"/> 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've been researching the problem on Google for a while now but just
    can't seem to find an example that is similar to what I'm doing, works
    with what I'm doing, or offers a clear explanations of what I need to
    do to make it work. Can anyone out there point me to some good
    resources, or even just in the right direction?

    Thanks!
    Zac
    Zac, Nov 7, 2007
    #1
    1. Advertising

  2. to prevent hacking, asp.net checks that the postback value for a listbox was
    included in the original list. thus your error.

    as the error implies, you can turn off EventValidation on the page.
    (Page.EnableEventValidation = false)

    if you write your own control, and want it to have its data also validated
    you use RegisterForEventValidation. its not used for turning off validation,
    only to add it.

    if you don't want to disable for the page, in OnInit you can add the new
    postback value to the listbox, and it will pass the test.

    -- bruce (sqlwork.com)


    "Zac" wrote:

    > Hello!
    >
    > Maybe someone out there can point me int he correct direction for a
    > fix to a problem I'm having. I've setup a user control with two list
    > boxes. One starts with a full list of items, the other one completely
    > empty. I've setup a client-side javascript function that allows the
    > user to move items from one list box to the other and back as a way of
    > 'selecting' which options they want. The user control is set in a
    > server side form. When I click the save button that posts back to the
    > server, I get the following error:
    >
    > Invalid postback or callback argument. Event validation is enabled
    > using <pages enableEventValidation="true"/> 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've been researching the problem on Google for a while now but just
    > can't seem to find an example that is similar to what I'm doing, works
    > with what I'm doing, or offers a clear explanations of what I need to
    > do to make it work. Can anyone out there point me to some good
    > resources, or even just in the right direction?
    >
    > Thanks!
    > Zac
    >
    >
    =?Utf-8?B?YnJ1Y2UgYmFya2VyIChzcWx3b3JrLmNvbSk=?=, Nov 7, 2007
    #2
    1. Advertising

  3. Zac

    Zac Guest

    On Nov 7, 2:33 pm, bruce barker (sqlwork.com)
    <> wrote:
    > to prevent hacking, asp.net checks that the postback value for a listbox was
    > included in the original list. thus your error.
    >
    > as the error implies, you can turn off EventValidation on the page.
    > (Page.EnableEventValidation = false)
    >
    > if you write your own control, and want it to have its data also validated
    > you use RegisterForEventValidation. its not used for turning off validation,
    > only to add it.
    >
    > if you don't want to disable for the page, in OnInit you can add the new
    > postback value to the listbox, and it will pass the test.
    >
    > -- bruce (sqlwork.com)
    >
    > "Zac" wrote:
    > > Hello!

    >
    > > Maybe someone out there can point me int he correct direction for a
    > > fix to a problem I'm having. I've setup a user control with two list
    > > boxes. One starts with a full list of items, the other one completely
    > > empty. I've setup a client-side javascript function that allows the
    > > user to move items from one list box to the other and back as a way of
    > > 'selecting' which options they want. The user control is set in a
    > > server side form. When I click the save button that posts back to the
    > > server, I get the following error:

    >
    > > Invalid postback or callback argument. Event validation is enabled
    > > using <pages enableEventValidation="true"/> 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've been researching the problem on Google for a while now but just
    > > can't seem to find an example that is similar to what I'm doing, works
    > > with what I'm doing, or offers a clear explanations of what I need to
    > > do to make it work. Can anyone out there point me to some good
    > > resources, or even just in the right direction?

    >
    > > Thanks!
    > > Zac


    Thank you for the reply Bruce, Could you explain the OnInit way a
    little deeper?
    Zac, Nov 8, 2007
    #3
  4. Zac

    Zac Guest

    On Nov 7, 2:33 pm, bruce barker (sqlwork.com)
    <> wrote:
    > to prevent hacking, asp.net checks that the postback value for a listbox was
    > included in the original list. thus your error.
    >
    > as the error implies, you can turn off EventValidation on the page.
    > (Page.EnableEventValidation = false)
    >
    > if you write your own control, and want it to have its data also validated
    > you use RegisterForEventValidation. its not used for turning off validation,
    > only to add it.
    >
    > if you don't want to disable for the page, in OnInit you can add the new
    > postback value to the listbox, and it will pass the test.
    >
    > -- bruce (sqlwork.com)
    >
    > "Zac" wrote:
    > > Hello!

    >
    > > Maybe someone out there can point me int he correct direction for a
    > > fix to a problem I'm having. I've setup a user control with two list
    > > boxes. One starts with a full list of items, the other one completely
    > > empty. I've setup a client-side javascript function that allows the
    > > user to move items from one list box to the other and back as a way of
    > > 'selecting' which options they want. The user control is set in a
    > > server side form. When I click the save button that posts back to the
    > > server, I get the following error:

    >
    > > Invalid postback or callback argument. Event validation is enabled
    > > using <pages enableEventValidation="true"/> 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've been researching the problem on Google for a while now but just
    > > can't seem to find an example that is similar to what I'm doing, works
    > > with what I'm doing, or offers a clear explanations of what I need to
    > > do to make it work. Can anyone out there point me to some good
    > > resources, or even just in the right direction?

    >
    > > Thanks!
    > > Zac


    Thank you for the reply Bruce, Could you explain the OnInit way a
    little deeper?
    Zac, Nov 8, 2007
    #4
  5. Zac

    Zac Guest

    On Nov 7, 2:33 pm, bruce barker (sqlwork.com)
    <> wrote:
    > to prevent hacking, asp.net checks that the postback value for a listbox was
    > included in the original list. thus your error.
    >
    > as the error implies, you can turn off EventValidation on the page.
    > (Page.EnableEventValidation = false)
    >
    > if you write your own control, and want it to have its data also validated
    > you use RegisterForEventValidation. its not used for turning off validation,
    > only to add it.
    >
    > if you don't want to disable for the page, in OnInit you can add the new
    > postback value to the listbox, and it will pass the test.
    >
    > -- bruce (sqlwork.com)
    >
    > "Zac" wrote:
    > > Hello!

    >
    > > Maybe someone out there can point me int he correct direction for a
    > > fix to a problem I'm having. I've setup a user control with two list
    > > boxes. One starts with a full list of items, the other one completely
    > > empty. I've setup a client-side javascript function that allows the
    > > user to move items from one list box to the other and back as a way of
    > > 'selecting' which options they want. The user control is set in a
    > > server side form. When I click the save button that posts back to the
    > > server, I get the following error:

    >
    > > Invalid postback or callback argument. Event validation is enabled
    > > using <pages enableEventValidation="true"/> 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've been researching the problem on Google for a while now but just
    > > can't seem to find an example that is similar to what I'm doing, works
    > > with what I'm doing, or offers a clear explanations of what I need to
    > > do to make it work. Can anyone out there point me to some good
    > > resources, or even just in the right direction?

    >
    > > Thanks!
    > > Zac


    Thank you for the reply Bruce. Could I talk you into elaborating a
    little about the OnInit way?
    Zac, Nov 8, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QW5kcsOp?=

    ClientScriptManager.RegisterForEventValidation

    =?Utf-8?B?QW5kcsOp?=, Nov 10, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,904
  2. stewart
    Replies:
    2
    Views:
    14,401
    stewart
    Dec 7, 2005
  3. n33470
    Replies:
    9
    Views:
    151,427
    AbercrombieLV
    May 30, 2010
  4. Varangian
    Replies:
    7
    Views:
    2,848
    Varangian
    Jul 10, 2006
  5. DNB
    Replies:
    2
    Views:
    1,806
    Michael Nemtsev
    Dec 13, 2007
Loading...

Share This Page