Reputation: 173
I'm trying to create something almost similar to this [1]: http://weblogs.asp.net/infinitiesloop/archive/2007/09/17/inline-script-inside-an-asp-net-ajax-updatepanel.aspx
The problem I ran into is that if I use an inline tag, the page property ClientID it's resolved as "__Page" although this doesn't happen with child controls of that page. So for example if I use the control like this
<tag:InlineScript runat="server">
<script type="text/javascript">
alert('<%= ClientID %>');
alert('<%= SomeLabelInTheSamePage.ClientID %>');
</script>
</tag:InlineScript>
the page is rendered as:
<script type="text/javascript">
alert('__Page');
alert('MainContent_CorrectLabelId');
</script>
Any idea why?
[1] the diference is that I'm using a user control (instead of server control) decorated with ParseChildren(false), same code as the page I linked.
Upvotes: 0
Views: 750
Reputation: 25803
Try this:
<tag:InlineScript id="myInlineScript" runat="server">
<script type="text/javascript">
alert('<%=myInlineScript.ClientID %>');
alert('<%=SomeLabelInTheSamePage.ClientID %>');
</script>
</tag:InlineScript>
Upvotes: 1