Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of __EVENTARGUMENT in postback

This may be a basic question. I know __doPostback() function accepts 2 arguments, eventtarget and eventargs. eventtarget is used to identify the control that causes postback. Then what is the use of eventargs in __doPostback function?

I saw the __doPostback function always set the __EVENTARGUMENT hidden field to nothing for any postbacks caused by controls with even autopostback to true or a control like linkButton.

Please give me your input.

like image 765
DotnetLearner Avatar asked Dec 13 '25 12:12

DotnetLearner


2 Answers

If you want to assign the _EVENTARGUMENT you can manually invoke the postback with javascript:

  javascript:__doPostBack('MyControl', 'myArgument');

This site explains how ASP.NET uses the postback mechanism: http://aspalliance.com/895_Understanding_the_JavaScript___doPostBack_Function.5

like image 114
David Neale Avatar answered Dec 16 '25 12:12

David Neale


The __EVENTARGUMENT is any relevant event arguments regarding the control performing the postback. For most controls, there are no specialized event arguments, and since event arguments are different for every control, null is passed to represent a default argument should be created during the event sequence.

Try watching the __EVENTARGUMENT that gets passed when you have a specialized control (such as a linkbutton in a gridview that has commandname/commandargument/etc assigned). You should begin to see values getting passed.

like image 45
Joel Etherton Avatar answered Dec 16 '25 11:12

Joel Etherton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!