最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Invoking button click on ASP.net client side programmatically - Stack Overflow

programmeradmin1浏览0评论

I'd like to invoke a button click event on an ASP 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?

I'd like to invoke a button click event on an ASP 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?

Share Improve this question asked Jan 4, 2010 at 11:51 Danny YoffeDanny Yoffe 211 silver badge4 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 3

in your script, call:

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

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!

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.

发布评论

评论列表(0)

  1. 暂无评论