views:

264

answers:

2

I want to use ICallBackEventHandler however when I use it to call back to the server I find that my form control objects don't have the latest form values. Is there a way to force populate the values with the form data?

Thanks.

+2  A: 

Have a look at http://msdn.microsoft.com/en-us/magazine/cc163863.aspx.

In short, you have to clear the variable '__theFormPostData', and call the 'WebForm_InitCallback()' before the 'CallbackEventReference' script. This updates the form values with the user input values. Something like this:

// from the above link
string js = String.Format("javascript:{0};{1};{2}; return false;", 
    "__theFormPostData = ''",
    "WebForm_InitCallback()",
    Page.GetCallbackEventReference(this, args, "CallbackValidator_UpdateUI", "null"));
sandesh247
A: 

You obviously still dont have the same issue but wha you need to do is recall WebForm_InitCallback() prior to your JavaScript Callback Code. This will get the page to refresh the POST values in your Request.Form object.

When you now do a PostBack the values modified during Callbacks will be available. It goes without saying they will be available during Callbacks.

etc

function SomeCode()
{
    __theFormPostCollection.length = 0;
    __theFormPostData = "";
    WebForm_InitCallback();

    ExecuteMyCallbackMethod("yaday", "yadya");
}
Jonathan