Passing Arguments to ASP.net UpdatePanel using __doPostBack()

Hello,

I have an asp.net page that contains an update panel and I am trying to figure out how to pass arguments on it when I call __doPostBack().  I have the following function in my javascript that causes the UpdatePanel to perform an Async Postback and refresh itself:

        function UpdateFoodLogPanel() {
            __doPostBack('<%=FoodLogUpdatePanel.ClientID %>', GetSelectedDate());    
        }

This function is called everytime a user selects a new date from a Datepicker control on the page.  Obviously the second parameter of the __doPostBack() is the date which the user has selected.  I need to access this date in the code behind in order to populate the update panel with specific data based on what date has been passed.

In my codebehind I have tried using Request.Params("__EVENTARGUMENT") retrieve the date from the __doPostBack() yet for some reason it is always showing up as a blank string.  The funny thing is that I am using Firefox with Firebug and I am able to access the POST of the response and it is showing that __EVENTARGUMENT does have the proper date inside of it when it is passed.  Another curious thing going on is that the Page_Load event in the codebehind never seems to register IsPostBack as being true, even though the page IS being posted back when the UpdatePanel is refreshed.

If anyone could help me figure out how to get the date in the code behind it would be VERY much appreciated.

Thanks,

Mike
LVL 3
MClarkCCRAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MrAgileCommented:
Hi There,

Can you post a link to the page so I can take a look at it? Oh and the page won't register the IsPostBack  property as it's not performing one.

Sean
0
ddayx10Commented:
Try it like this:

string eTarget = Request.Params.Get("__EVENTTARGET");
string eArg = Request.Params.Get("__EVENTARGUMENT");

That's C# but it works the same in VB pretty much.
0
MClarkCCRAuthor Commented:
Hello,

Thanks for your responses.  I apologize for the delay in getting back to this question, but I got bogged down with work from several other projects.  

I was actually able to find a solution by switching to a Telerik RadAjaxPanel as opposed to an UpdatePanel.  For those of you that don't know, it's basically Telerik's version of an UpdatePanel but with a more streamlined server and client-side API for working with ajax requests.  

I was able to initiate an AJAX postback manually via my JS code and pass the date as a parameter.  Then I was able to get the value very easily in the server side event.

dday10x:

For some reason those parameters were always registering as "" which was causing my code to fail.  It's strange because when I view the POST through Firebug I would see values for both of those __EVENT variables and they would be the proper ones I expected it to.  It was just impossible to get the values using Request.Params in the server-side.  I'm sure that is in part due to a misunderstanding on my end in regards to the ASP.net lifecycle and how the server treats AJAX-Postback request.  As MrAgile noted, the server doesn't register those request as a postback at all.

Oh well, thanks again for your responses.

Mike
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.