OnClientClick event doesn't register javascript alert from code-behind
<p>Alright, I have an embarrassingly simple question that hopefully has an embarrassingly simple answer. I am trying to get an asp:ImageButton to display an alert message that contains variables from my codebehind. Here's the overly simplified version of the code:</p>

<pre><code>public string AlertMe
{
    get
    {
        return "alert('hi');";
    }
}
</code></pre>

<p>Now when I try and access it this way:</p>

<pre><code>&lt;asp:ImageButton ID="btn" runat="server" ImageUrl="/Images/img.ico" OnClientClick='&lt;%=AlertMe%&gt;'/&gt;
</code></pre>

<p>I see a postback, but no alert message, as if it can't access my property at all. Meanwhile, these 2 lines:</p>

<pre><code>&lt;%=AlertMe%&gt;&lt;br /&gt;
&lt;a onclick="&lt;%=AlertMe%&gt;"&gt;click this&lt;/a&gt;
</code></pre>

<p>both work fine and dandy. (The first displays the code for the javascript alert, and the second fires the alert with no issues.)</p>

<p>So my big question is: why does the OnClientClick event for an asp control fail to register the alert? Is there an obvious flaw I'm missing, or do I really need to register the entire event from code-behind?</p>
