如何在点击按钮时触发弹出窗口?
该按钮源自用户控制。 我想在单击该特定按钮时关联一个弹出窗口。 我可以通过单击基本页面上的任何其他按钮来实现此目的,但由于该特定按钮来自用户控件,我无法触发弹出窗口。
$('#btnSendOrder').click(function() {// code here}) // btnSendOrder is from a user control.In this case pop-up is not coming.
$('#btnSendOrder').click(function() { // code here}) // btnSend Order is from the base page itself. In this scenario pop-up comes out.
The button is derived from user control. I want to associate a pop-up window on click of that particular butoon. I can able to achieve this on click of anyother buttons on my base page but as that particular button is coming from a user control I am not able to trigger the pop-up window.
$('#btnSendOrder').click(function() {// code here}) // btnSendOrder is from a user control.In this case pop-up is not coming.
$('#btnSendOrder').click(function() { // code here}) // btnSend Order is from the base page itself. In this scenario pop-up comes out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于按钮是在服务器上呈现的,因此它的客户端 ID 不是您正在使用的
您可以
从您的用户控件执行此操作... ...,并且 <% 和 %> 之间的部分是 将被替换为客户端html中的真实控件id
Since the button is being rendered on the server, its client ID is not what you are using
You can do this...
... from your usercontrol, and the portion between <% and %> will be replaced with the real control id in the client html
如果您使用 .NET,请记住您的控件最终将类似于:
ctl1.UserControlName.ButtonName 或类似的名称。
呈现后检查您的标记代码,然后使用确切的按钮名称,以便您的 jQuery 知道从哪个控件触发。
If you are using .NET, reember that your controls will end up looking something like:
ctl1.UserControlName.ButtonName or something like that.
Check your markup code once it is rendered, then use the exact button name so that your jQuery knows which control to fire from.
使用一点jquery,将按钮与页面加载时的单击事件相关联是相对简单的:
Using a bit of jquery, it would be relatively trivial to associate the button with a click event on load of the page: