Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesRegisterForEventValidation: howto?RegisterForEventValidation: howto?
Previous
 
Next
New Post
1/13/2012 11:28 AM
 

Hello,
after upgrading a DNN host to version 6.1.2 a module of mines began giving a bad error when calling __doPostBack() in a javascript function:

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'd like to solve this without affecting web.config, so I added this function to my module code:

Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
            Me.Page.ClientScript.RegisterForEventValidation(btnEditZone.UniqueID)
            MyBase.Render(output)
        End Sub

But nothing changed: I always get that error if I try to call the __dopostpack.

btnEditZone  is an asp:button on my page:

<asp:Button ID="btnEditZone" runat="server" style="display:none;" />

The javascript function:

function EditZone(idSellerProfileZone) {
        __doPostBack('<%=btnEditZone.UniqueID%>', idSellerProfileZone); 
    }

Server side, the postback is processed by this function:

Protected Sub btnEditZone_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEditZone.Click
            Dim idSellerProfileZone As String = Request("__EVENTARGUMENT")
            EditZone(idSellerProfileZone)
        End Sub

I don't know if it's possible to modify the @page directive from within my module, but using a Render() function should be a better solution, am I wrong? The render function is called, but the error is still there: can anybody help? 

Thank you.
Regards,
al.


 
New Post
1/14/2012 8:39 PM
 

Your registerforeventvalidation looks fine to me, I'm not sure what the issue might be except I'm not used to seeing the 2nd parameter in the _dopostback call populated i.e. rather than

__doPostBack('<%=btnEditZone.UniqueID%>', idSellerProfileZone);

it normally looks like:

__doPostBack('<%=btnEditZone.UniqueID%>', '');

i.e. the eventvalue does not have to be passed as when the postback occurs all the server controls selected values are available


Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
1/16/2012 4:10 AM
 
cathal connolly wrote:

Your registerforeventvalidation looks fine to me, I'm not sure what the issue might be except I'm not used to seeing the 2nd parameter in the _dopostback call populated i.e. rather than

__doPostBack('<%=btnEditZone.UniqueID%>', idSellerProfileZone);

it normally looks like:

__doPostBack('<%=btnEditZone.UniqueID%>', '');

i.e. the eventvalue does not have to be passed as when the postback occurs all the server controls selected values are available

 Cathal,
thanks for your answer. I'm passing value this way because I populate a DnnTreeView server-side, and add action buttons on each element to later perform actions on it. Such buttons are actually only A href with javascript to handle the onclick event, where I call my "EditZone" function; this function then postbacks via a unique (hidden) button.

I now tried to assign a value to the button via jquery, but get the same error:

function EditZone(idSellerProfileZone) {
        $("#<%=btnEditZone.ClientID%>").val(idSellerProfileZone);
        __doPostBack('<%=btnEditZone.UniqueID%>'); 
    }

But this is sure wrong, because it acts on the client and does not prepare control for postback.

Any help greatly appreciated! ;-)

Thanks,

al.

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesRegisterForEventValidation: howto?RegisterForEventValidation: howto?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out