[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Passing Arguments to ASP.net UpdatePanel using __doPostBack()

Posted on 2009-07-03
3
Medium Priority
?
6,314 Views
Last Modified: 2012-05-07
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
0
Comment
Question by:MClarkCCR
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Expert Comment

by:MrAgile
ID: 24776599
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
 
LVL 20

Expert Comment

by:ddayx10
ID: 24820575
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
 
LVL 3

Accepted Solution

by:
MClarkCCR earned 0 total points
ID: 24870723
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

Featured Post

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question