Rafay
Rafay

Reputation: 601

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:

<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:

<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>

Upvotes: 0

Views: 2541

Answers (1)

Rafay
Rafay

Reputation: 601

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

Upvotes: 1

Related Questions