Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi,

I am using below javascript method to pass data from one page to another and reading it there:

JavaScript
function GotoActivity(accountNumber, noteID) {

    var url = "/ActivitySearch/Activity.aspx";
    document.forms[0].action = url;
    document.forms[0].Data1.value = accountNumber;
    document.forms[0].Data2.value = noteID;
    document.forms[0].__VIEWSTATE.name = 'NOVIEWSTATE';
    document.forms[0].submit();
}


I am able to get the values of Data1 and Data2 successfully on my second page but I am facing two problems here:

1) When it navigates to the second page it gives the yellow page with the 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."

If I declare EnableEventValidation="false" this error goes but I have seen it written in almost all the places that it is not recommended.

2) On the secong page the "IsPostBack" property always comes as True even for the first time the page load after navigation.

Thanks in Advance,
Deepti
Posted

 
Share this answer
 
Comments
deeptibansal 30-Dec-13 9:48am    
Yes I read that link, but it does not help in my situation and does not provide any reason for Point#2 of my question at all.

I did the basic google for my problem before putting it here.
I used the jquery method Post to post the data and then redirect to the page. It worked well.
 
Share this answer
 
Check this Link
 
Share this answer
 
Recent days, I got the same problem. the cause is the windows security updates.
refer to https://technet.microsoft.com/library/security/2905247[^]

You might insert below code, can resolve your issue.

C#
var objForm = document.forms[0]

if (objForm) {
    var hid__VIEWSTATE = objForm.elements['__VIEWSTATE'];
    var hid__EVENTARGUMENT = objForm.elements['__EVENTARGUMENT'];
    var hid__EVENTTARGET = objForm.elements['__EVENTTARGET'];

    if (hid__VIEWSTATE) {
        hid__VIEWSTATE.disabled = true;
    }

    if (hid__EVENTARGUMENT) {
        hid__EVENTARGUMENT.disabled = true;
    }

    if (hid__EVENTTARGET) {
        hid__EVENTTARGET.disabled = true;
    }
}


Reference http://www.dotblogs.com.tw/rainmaker/archive/2014/09/23/146668.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900