我有这个JS函数,只要页面加载就会加载:
B=[I 0 0;
0 0 0;
0 0 0]
如何从asp:LinkButton点击调用此函数?链接按钮名为filtroCombinado:
<script type="text/javascript">
window.onload = function () {
<asp:Literal ID="LiteralGraph01" runat="server"></asp:Literal>
<asp:Literal ID="LiteralGraph_ft01" runat="server"></asp:Literal>
</script>
感谢您的帮助!
答案 0 :(得分:1)
<asp:LinkButton...
呈现为锚点(<a href=...
)。如果你想运行一些JS onload
和 onclick
做这样的事情。
<script type="text/javascript">
window.onload = function myFunc () {//nobody blames you when you name the function
<asp:Literal ID="LiteralGraph01" runat="server">some data I fill in from server (and replace this text)</asp:Literal>
<asp:Literal ID="LiteralGraph_ft01" runat="server"></asp:Literal>
return false; //avoid sending request to the server
}//close the function
</script>
...
//do something before sending request to the server
<asp:LinkButton ID="filtroCombinado" runat="server" OnClientClick="return myFunc();"></asp:LinkButton>
答案 1 :(得分:1)
试试这个:
<script type="text/javascript">
var onLoadFunction = function () {
<asp:Literal ID="LiteralGraph01" runat="server"></asp:Literal>
<asp:Literal ID="LiteralGraph_ft01" runat="server"></asp:Literal>
</script>
<asp:LinkButton ID="filtroCombinado" runat="server" onClientClick="onLoadFunction()"></asp:LinkButton>