Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 19th, 2008, 02:31 AM
Authorized User
 
Join Date: Nov 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Delimeters problem in asp.net 3.5

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.

 
Old April 19th, 2008, 08:17 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Use the RegisterStartupScript method to emit dynamic javascript to the page. That will eliminate embedded code blocks.

-Peter
peterlanoie.blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom HTTP 404 Problem w/ASP to ASP.NET kwilliams ASP.NET 2.0 Professional 7 November 26th, 2007 04:17 PM
Problem Converting C# to VB.NET in ASP.NET kwilliams ASP.NET 2.0 Basics 0 February 9th, 2007 06:22 PM
Problem with Exercise in Beg. asp.net for VB.net! mrfella71 BOOK: Beginning ASP.NET 1.0 1 October 23rd, 2005 12:06 PM
ASP.NET problem btls ASP.NET 1.0 and 1.1 Basics 1 July 19th, 2004 08:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.