简体   繁体   English

如何从VB代码背后调用ASP链接,而不是用户单击链接?

[英]How do I call an ASP link from VB code-behind instead of user clicking link?

I have a link here that works perfect for calling the postback close that I need to happen: 我这里有一个链接非常适合调用我需要发生的回发关闭:

<a href="javascript:parent.__doPostBack('Close','')"><asp:Label ID="Label5" runat="server" Text="Close Me"></asp:Label></a> 

However, I would like to be able to call the *javascript:parent.__doPostBack('Close','')* method from the code-behind file rather than the user clicking the link. 但是,我希望能够从代码隐藏文件而不是用户单击链接的情况下调用* javascript:parent .__ doPostBack('Close','')*方法。 Ie, when I have completed my tasks in the application code, call parent.doPostBack as my last function call, which closes the window in question. 即,当我完成了应用程序代码中的任务后,请调用parent.doPostBack作为我的最后一个函数调用,这将关闭有问题的窗口。

Any ideas how to call this client-side javascript method from the server side? 有什么想法如何从服务器端调用此客户端javascript方法吗?

I think you're looking for how to generate script to link to event handlers on the server (page). 我认为您正在寻找如何生成脚本以链接到服务器(页面)上的事件处理程序。 See these methods of this.Page.ClientScript : 请参阅this.Page.ClientScript这些方法:

GetCallbackEventReference
GetPostBackClientHyperlink
GetPostBackEventReference
GetWebResourceUrl

Also, explore other methods of the page's ClientScript property. 另外,探索页面的ClientScript属性的其他方法。 There are some interesting ones beginning with "Register". 有一些有趣的以“ Register”开头的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM