I'm writing a bit of aspx code to call a JavaScript function from a server control. Here's the JavaScript:
<script type="text/javascript">
function checkInfoPortalUnpin(portalareaid) {
if(portalareaid == 1) {
alert('a message');
}
}
</script>
And here's the calling aspx code:
<asp:ImageButton OtherFields="omitted..."
OnClientClick='checkInfoPortalUnpin(<%# Eval("PortalAreaID") %>);' />
When I view the source of that line in the browser (IE8) it is rendering as this:
... onclick="checkInfoPortalUnpin(<%# Eval("PortalAreaID") %>);"
and I get a syntax error when I click on the ImageButton. I know the OnClientClick does work because if I replace the <%# ... %> with a hard-coded '1' the function runs fine. Am I missing something?