Subject: Delimeters problem in asp.net 3.5
Posted By: jijish Post Date: 4/19/2008 2:31:44 AM
I wrote the following code in aspx page in visualstudio2008 using asp.net 3.5

<script  type="text/javascript">
  
  <%
  int RecordsPerPage =GridView1.PageSize;
   %>  
 var RecordsPerPage =<%=RecordsPerPage %>;
</script>
This code works perfectly in asp.net 2.0
But when I run it it gives runtime error

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

How to solve it.

Regards,
Jijish.

Reply By: planoie Reply Date: 4/19/2008 8:17:05 AM
Use the RegisterStartupScript method to emit dynamic javascript to the page.  That will eliminate embedded code blocks.

-Peter
peterlanoie.blog

Go to topic 70737

Return to index page 1