2

I'd like to invoke a button click event on an ASP.net page programmatically, using c#. I don't have access to the server-side of the page, so i can't invoke the function directly. Is it possible at all?

Danny Yoffe
  • 21
  • 1
  • 4

3 Answers3

3

in your script, call:

__doPostBack("<%= your_button_id.UniqueID %>", "");

Ray
  • 21,485
  • 5
  • 48
  • 64
  • worked a treat. if you use `ClientIdMode="Static"` on the control you're trying to simulate a click on, you can just drop the actual ID name in there: `` and in the JS: `__doPostBack("myLink", "");` – Jason Jul 13 '12 at 22:58
1

As far a s I understand your question:

  • you cannot really generate a serverside event call from the client side.
  • you can force post back by using a submit button
  • BUT using
    javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(...))
    may fit your need. This is the JS call that an ASP control use. copying that call may "invoke" the method you need

read more here: WebForm_PostBackOptions documentation

Enjoy!

Community
  • 1
  • 1
David Salzer
  • 872
  • 1
  • 7
  • 24
0

Thanks for the answers,
I've used "Tamper Data" add-on for Firefox to see how the generated Post looks like, and built HttpWebRequest of my own.

Danny Yoffe
  • 21
  • 1
  • 4