当事件发生时,Web 控件如何知道要使用哪个方法?
我在 Web 控件中有一个 LinkButton,我想在使用此 Web 控件的页面上绑定该事件。
LinkButton 的 href 属性呈现如下。
javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl00$CoreContent$Content$scale1", "", false, "", "/thema/fi/product/reviews.aspx", false, true))
它不会触发我在网页中附加的事件。
我的问题是这个 LinkButton 如何知道它应该转到我绑定的事件方法。
谢谢。
PS:我不是问如何将事件绑定到链接按钮。
I have a LinkButton in a web control and I want to bind the event at the page where I use this web control.
LinkButton's href attribute is renderedas below.
javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl00$CoreContent$Content$scale1", "", false, "", "/thema/fi/product/reviews.aspx", false, true))
It doesn't fire the event that I have attached in the web page.
My question is how this LinkButton is supposed to know that it should go to the event method I binded.
Thanks.
PS: I'm not asking how to bind an event to a linkbutton.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是由 __doPostBack javascript 函数处理的,该函数设置 __EVENTTARGET 和 __EVENTARGUMENT 隐藏字段。在服务器端生命周期处理期间,从这些字段中提取值并搜索目标控件。该控件必须实现 IPostBackEventHandler 接口,该接口定义了 RaisePostBackEvent 方法。该方法引发一个事件并调用事件处理程序。对于链接按钮,事件是 OnClick。
This is handled by __doPostBack javascript function which sets __EVENTTARGET and __EVENTARGUMENT hidden fields. During server side life-cycle processing values from those fields are extracted and target control is searched. This control has to implement IPostBackEventHandler interface which defines RaisePostBackEvent method. The method raises an event and event handler is called. For link button the event is OnClick.
对于我们的第一点,liken 按钮事件不会触发。
您必须在
onclientclick
事件中调用 JavaScript 函数。例子:
For our first point saying that the likn button event does not fire.
You have to call your javascript function in
onclientclick
event.Example: