简体   繁体   English

如何在Javascript onClientClick中传递Eval参数?

[英]How to pass Eval parameter in Javascript onClientClick?

Hello I saw some examples on how to this but unfortunately I end up with an error 您好,我看到了一些有关此操作的示例,但不幸的是我最终遇到了错误

**Description:** An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The server tag is not well formed.

I want to use javaquery on a linkbutton placed in Gridview using the below code: 我想使用下面的代码在放置在Gridview中的linkbutton上使用javaquery:

<asp:LinkButton ID="hlHierarchy" runat="server" OnClientClick= "return windowpop('~/../../..<%#Eval("NavigateURL") %>', 545, 433)">
<pre Class="td-heading" style="display: inline; font-weight:bold"><%# ((string)Eval("Name")).Replace("-", " ") %></pre>
</asp:LinkButton>

Please help me rectify any syntax error if there is, below is the jquery: 请帮助我纠正任何语法错误(如果有),以下是jquery:

<script language="javascript" type="text/javascript">

function windowpop(url, width, height) {
        var leftPosition, topPosition;
        //Allow for borders.
        leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
        //Allow for title and status bars.
        topPosition = (window.screen.height / 2) - ((height / 2) + 50);
        //Open the window.
        window.open(url, "Window2", "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
    }
</script>

So i figured out what was wrong, the corrected code: 所以我找出了错误的地方,更正了代码:

<asp:LinkButton ID="hlHierarchy" runat="server" OnClientClick= <%# "return windowpop('../.."+((string)Eval("NavigateURL")).Replace("~", "") +"', 1024, 768)" %>>
<pre Class="td-heading" style="display: inline; font-weight:bold"><%# ((string)Eval("Name")).Replace("-", " ") %></pre>
</asp:LinkButton>

Reference 参考

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

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