• Register
1 vote
85 views

Problem :

I want to create the simple user control that should be the slider. When I try to add the AjaxToolkit SliderExtender to my user control I usually get below error:

Server Error in '/' Application. The Controls collection cannot be modified because the control contains code blocks (i.e. `<% ... %>`). Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. `<% ... %>`).
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. `<% ... %>`).]    System.Web.UI.ControlCollection.Add(Control child) +8677432    AjaxControlToolkit.ScriptObjectBuilder.RegisterCssReferences(Control control) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\ExtenderBase\ScriptObjectBuilder.cs:294 AjaxControlToolkit.ExtenderControlBase.OnLoad(EventArgs e) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs:307 System.Web.UI.Control.LoadRecursive()
+60    System.Web.UI.Control.LoadRecursive()
+241    System.Web.UI.Control.LoadRecursive()
+241    System.Web.UI.Control.LoadRecursive()
+241    System.Web.UI.Control.LoadRecursive()             
+241    System.Web.UI.Control.LoadRecursive()
+241    System.Web.UI.Control.LoadRecursive()
+241    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +628
Version Information: Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.3074

I have already tried putting the placeholder in my user control and also tried adding the textbox and the slider extender to my placeholder programmatically but I am still facing the above error.

7.5k points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Please place your javascript under the div tag as shown below :

<div runat="server"> //div tag must have runat the server
  //Your Jave script code should go here....
</div>

It will surely work for you !!

38.6k points

Related questions

0 votes
1 answer 12 views
12 views
Problem: Is there a way to get this to work : Collection was modified enumeration operation might not execute?
asked Jun 21 Florina Gulnar 106k points
0 votes
1 answer 7 views
7 views
Problem: Word the resource DLL cannot be loaded
asked Jul 26 Sawyer Parviz 168k points
0 votes
1 answer 17 views
17 views
Problem: Why I am getting an error > Powershell cannot be loaded because running scripts is disabled on this system.
asked Apr 28 ummeshani 10.8k points
0 votes
1 answer 291 views
291 views
Problem : I have recently installed a website on my local machine using IIS 7 successfully. But when I tried to deploy it on the live server, I got a following error: "The page cannot be displayed because an internal server error has occurred" Nothing else. Using a same IIS 7 on live and also set to have the Detailed errors in Error Pages module, but still getting a same. What can be the reason?
asked Jan 28, 2020 jwilliam 3.9k points
0 votes
1 answer 47 views
47 views
Problem I am newbie to C# I am confused by .Net Garbage Collection logic. When does GC free memory?
asked Oct 8, 2020 alexh 2.6k points
0 votes
1 answer 110 views
110 views
Problem : I am facing below error if I try to export datagrid to the excel. &ldquo;Control 'gridview1' of type 'gridview' must be placed inside a form tag with runat=server.&rdquo; Please find below my code : <form runat="server" id="form1"> <div runat="server" id=" ... TextBox> </form> My GridView is within the from tag with the runat="server", but still I am facing above error. How to fix this?
asked Feb 17, 2020 mphil 2.3k points
0 votes
1 answer 9 views
9 views
Problem: I am using Paging to show data in datagridview, but when I try to Update any data with updatebutton data should be updated In datagridview as well as in the database. But I get this error: Update requires a valid UpdateCommand when passed DataRow collection with modified rows
asked Apr 24 ummeshani 10.8k points
0 votes
1 answer 4 views
4 views
Problem : Hi, Is there a way to solve it: Cannot open database requested by the login because the login failed?
asked Jun 22 Sifat55 108k points
0 votes
1 answer 20 views
20 views
Problem: I am trying to download an excel file which for which I am giving the proper path. But after downloading it when I am trying to open I get error as excel cannot open the file because the file format or file extension is not valid. Verify that ... .RegisterStartupScript(this.GetType(), "Exception", "alert('Template downloaded.');", true); } } Please suggest what is wrong in this
asked Apr 23 ochena 23.3k points
0 votes
1 answer 32 views
32 views
Problem : cannot drop database because it is currently in use
asked Feb 24 Sabbir Hossain 14.6k points