My question is quite simple, I have a website developed in Asp.Net. I wan't to pass a parameter from server (aspx file) to client (javascript file).
Lets say I have a asp:Button, and when OnClientClick event fires I want to call javascript function with parameter from the server.
Let simplify the example, and lets say this is my webpage:
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form id="form" runat="server">
<div runat="server" id="divID" >div text here...</div>
<br />
<asp:Button runat="server" text="click1"
OnClientClick='<%= "alert(" + this.divID.ClientID + "); return false;" %>'
/>
<asp:Button runat="server" text="click2"
OnClientClick="alert('<%= this.divID.ClientID %>'); return false;"
/>
</form>
</body>
</html>
The first button throw an client side error.
The 2nd button alert the string "<%= this.divID.ClientID %>" and not the actual value.
What I'm missing??