1

I have created a big form witch is being loaded as a usercontrol. On the initial page load there is an automatic postback when the page is fully loaded.

Is there a way to find what control is triggering this postbac and why.

Thanx in advance!

PieterSchool
  • 499
  • 4
  • 15

2 Answers2

1

Stop on a breakpoint in Page_Load under if(IsPostBack) and inspect Request["__EVENTTARGET"] and Request["__EVENTARGUMENT"] values.

Igor
  • 15,833
  • 1
  • 27
  • 32
0

Finally found the answer, the other answer didn't work for me since it was a linkbutton. These apparently don't show up using the method suggested by @Igor

Solved the problem using the following javascript:

<script>
    var postbackControl = null;
    var parm = Sys.WebForms.PageRequestManager.getInstance();
    parm.add_beginRequest(BeginRequestHandler);

    function BeginRequestHandler(sender, args) {
        postbackControl = args.get_postBackElement();
        console.log(postbackControl);
    }
</script>

It sends the control triggering the postback to the browserconsole, including all the objects attributes.

PieterSchool
  • 499
  • 4
  • 15
  • hi dear @pieter ,how it works ? how i get value in code behind?? tanx :) – R.Akhlaghi Apr 12 '15 at 11:04
  • @farid This code posts it in the Javascript console log. The postbackControl value is the Control that triggerd the postback. If you want the id in the code behind you could set the id tag to a hidden field and read it from the code behind. – PieterSchool Apr 12 '15 at 11:31
  • i'll test this solution , tanx dear @pieter from ur reply – R.Akhlaghi Apr 13 '15 at 03:21