Element “ScriptManager” is not a known element. This can occur if there is a compilation error in the website

22 12 2006
If you are getting the same frustrations as this crew:

http://forums.asp.net/thread/1495802.aspx

And your form.designer.cs is no longer code generating anything, and you are using a master page – then you can probably fix it by doing the following:

  1. Open your master page in the designer by double clicking it in visual studio.
  2. With it left open, open your suspect aspx file
  3. Right click on the toolbox in visual studio and click ‘reset toolbox’
  4. Wait for this to complete, switch to markup view on the aspx file, and drop a new script manager from the ajax extensions group onto the page.
  5. Save the file, check that your designer is now regenerating code.
  6. Delete the script manager you dropped on the aspx

Hope this helps, (It took me a while to work that one out!)

-EDIT:

If you are getting warnings along the lines of “Generation of designer file failed: Unknown server tag ‘ajaxToolkit:’

or ‘asp:ScriptManager’

You should place these registrations in your aspx:

Or, ensure that your controls section in your web config is defined correctly:


<controls>
<add tagPrefix=”asp” namespace=”System.Web.UI” assembly=”System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<add tagPrefix=”asp” namespace=”System.Web.UI.Controls” assembly=”System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″/>
<add tagPrefix=”ajaxToolkit” namespace=”AjaxControlToolkit” assembly=”AjaxControlToolkit”/>
</controls>

This should fix any designer regeneration issues…
Cheers,
Matthew Cosier

Did this post help you? If so, feel free to donate me some cash by clicking here!


Actions

Information

55 responses

3 01 2007
Anonymous

Thanx…
Simple solution fixed my headache ;-)

4 01 2007
preets

This is simply great.i would have never thought about this solution.I guess i installed ,uninstalled various versions of Atlas ,but toolbox has to be refreshed manually it seems .

4 01 2007
Anonymous

Thanks alot!!!! This was stressing me out very badly for a while!

4 01 2007
Anonymous

This used to work for me, but no longer does for some reason. It doesn’t even work in a brand new ajax-enabled web site.

hmmm…

12 01 2007
Anonymous

The System.Web.UI.Controls is not a valid namespace is the error I get. The darn designer.cs keeps trying to add :
protected System.Web.UI.ScriptManager ScriptManager;

to the designer.cs and it throws that error. I was hoping the above would fix it, but it didnt, oh well.

13 01 2007
Matthew Cosier

Have you tried adding the appropriate assembly as a reference in your project?

Also, the only reason it would be adding that is if you had declared a script manager in your markup – so if you don’t want it there, remove it from your markup and let the designer sync up.

Chances are that you have added an assembly reference to the CTP of atlas, or perhaps asp.net ajax pre 1.0 RC, where the namespace was not System.*

Check the version of your referenced assembly – this could be it.

HTH,

Matthew Cosier

25 01 2007
Shea

Hi I have a question about registering the assembly. I’m still a bit new to ASP.NET. I was getting the … “is not a known element” message and I’ve since… installed VS 2005 service pack 1, flushed the intellisense, and tried your fix but I’m still seeing weird behavior. When I drag a ScriptManager control onto the page it also adds this “Register Assembly=”System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″
Namespace=”System.Web.UI” TagPrefix=”asp”" I’ve tried adding the Microsoft ASP.NET 2.0 AJAX Extensions Toolbox Package as a Reference in my website but that didn’t seem to fix the problem (even after a restart of VS). Any ideas what I’m missing? Thanks!

27 01 2007
Anonymous

Thank you so much :)

31 01 2007
Anonymous

Legend!! Thanks so much…was getting rather frustrated.

7 02 2007
Pablogrind

Men rulez, it runs, thanks for your solution

16 02 2007
Anonymous

There’s no need to Reset the toolbox. Just open your master and aspx pages in Design View will fix the problem.

17 02 2007
Anonymous

Would encase ScriptManager like this work
<script>
<asp:ScriptManager runat="server">
</asp:ScriptManager>
</script>

21 02 2007
Anonymous

Hi all, I was getting a
Error 42 Type ‘System.Web.UI.ScriptManager’ is not defined.

I tried everything, made sure everything was set up correctly, web.config was done right etc etc .. Fixed it in the end by simply right clicking on my project and choosing Add Reference. Then browsing to where the System.Web.Extensions.dll was and selecting that. It added the reference into the references folder and the error went away. Just mentioning it here in case anyone else has issues.

2 03 2007
Anonymous

hi,

Solution was really nice but it does not solve my problem actually my page is in nested master page and from there i have applied ur solution but it still shows same problem.

Also after running the project whatever i do on page while parsing the page it gves error “Ambigous match found” however if i remove all ajax stuff from page then it works fine.

can u help regarding these?

Thanx.

10 03 2007
Anonymous

Thanks, it worked.

thekaran.com

14 03 2007
Anonymous

Didn’t work so well for me, after doing this fix all my other pages had numerous errors with unknown controls. Heres how I fixed it:
In the controls tag of web.config

add tagPrefix=”asp” namespace=”System.Web.UI” …etc…

add tagPrefix=”asp” namespace=”System.Web.UI.Controls”…etc…

add tagPrefix=”ajaxToolkit” namespace=”AjaxControlToolkit” assembly=”AjaxControlToolkit”

add tagPrefix=”ajax” namespace=”System.Web.UI”…etc…

add tagPrefix=”ajax” namespace=”System.Web.UI.Controls”…etc…

Then I changed the opening and closing tags for the offending scriptmangager to ajax:ScriptManager

16 03 2007
Anonymous

Awesome! When I open my master page in design view, it fixes it. Thanks to whoever posted that.

20 03 2007
Anonymous

Thanks Dude! Microsoft being Microsoft… always gives me a headache on stuff like this!

27 03 2007
Anonymous

Superb!!! This fixed all the issues in my page..great men!!

4 04 2007
Anonymous

I was getting same error, I tried to convert a project which had a master page. I tried to install on page and master page and did not fix problem.

I looked at the ajaxcontrol samples and noticed the scriptmanager tag did not have an ID.

So if I put asp:ScriptManager runat=”Server” it works fine.

25 04 2007
Anonymous

Thanks!

14 06 2007
Anonymous

Thank you very much :)

11 07 2007
Tom

Great post. The comment about ScriptManager having an ID when it shouldn’t was the cause of my problem as well. Thanks to whoever posted that solution.

Dragging the control from the toolbox automatically puts in the ID, which confused me.

1 08 2007
deusblue

Thanks too!

7 08 2007
Polo

Thank you very much!

14 09 2007
Toby

If you found your way into this thread because you are getting this warning in VS2005 when viewing an aspx page with ScriptManager control on it:
“Namespace or type specified in the Imports ‘System.Web.UI.Controls’ doesn’t contain any public member or cannot be found. ”
It’s because you put both “add tagPrefix…”s in your web.config file as suggested up at the top of this page. You only need the first one near as I can tell.

19 09 2007
jay

Lifesave. How did you figure this out?

16 11 2007
Ryan

Found an easier solution for me.

1. Remove MasterPageFile=”~/YourMasterPageName.master” from the page directive.
2. Switch to design view (yes, I know all of your content controls say ‘Error’)
3. Switch back to Source and put MasterPageFile=”~/YourMasterPageName.master” back in the page directive.
4. Switch to design view.
5. Switch back to Source…. all better.

20 11 2007
Narashiman

Thanks a lot.. htank u very much… i was able to solve the problem

20 11 2007
hamish

make sure system.web.extensions is referencing the correct version

15 01 2008
Tod Birdsall

Thanks for posting this solution. It worked for me.

25 01 2008
Jerry T

You are my guru.
I’ll be naming my son after you.

26 01 2008
Aashish

Thanks
My Problem is solved

31 01 2008
paddy

thanks ryan, your fix was the only one that worked for some reason :S

Ryan (21:10:41) :

Found an easier solution for me.

1. Remove MasterPageFile=”~/YourMasterPageName.master” from the page directive.
2. Switch to design view (yes, I know all of your content controls say ‘Error’)
3. Switch back to Source and put MasterPageFile=”~/YourMasterPageName.master” back in the page directive.
4. Switch to design view.
5. Switch back to Source…. all better.

9 04 2008
Anil Kumar Agrawal

Yes.. this Master Page thing worked nicely for me too…

2 05 2008
Priya

Hi.
Iam getting An error:’ScriptManager’ ia not a known element .

Adding the below statement in web.config solved my problem.
add tagPrefix=”ajax” namespace=”System.Web.UI.Controls”…etc
thanks.

4 05 2008
Derek

Thanks!

22 05 2008
Sue

simple solution. big help.
Thanks a lot.

20 06 2008
slade73

Thank you thank you thank you!!!

Your clearly described steps fixed the problem for me! Thanks again!

6 07 2008
Joe Mordetsky

This blog just saved me big headaches, thanks for posting.

10 07 2008
bryan

what if i’m not using master pages? i’m just using simple .aspx form from a asp.net website. thanks for the input.

16 07 2008
Mugdhali

I did a funny thing.
1. I removed (ctrl+x) the script manager

from the markup.
2. saved and built
3. The error panel demanded for one script manager.
4. I added the same line at the same place. Saved and ran the application.

I was not really hopeful but it worked!

16 07 2008
Mugdhali

And yes, the application I am using does not have master pages. Maybe Bryan could try this.

29 07 2008
Kirun

wow… works like charm. you saved me by hitting my head into my own computer …..

God bless

29 07 2008
Praveen

Excellent work, I really appretiate this, it saved my working weekends

30 07 2008
27 08 2008
sandeep

Thank you. It was very helpful.

7 10 2008
Xribble

This was a great help. I am sure people like you make life of other developers a lot easite. kewl…

12 10 2008
Alan

Thanks from another satisfied customer.

4 11 2008
ferakpeter

thank you, thank you, thank you! banging my head against the wall doesn’t begin to cover it:)

13 11 2008
Tobias

THIS Post fixed my problem:

Anonymous (06:22:00) :
I tried everything, made sure everything was set up correctly, web.config was done right etc etc .. Fixed it in the end by simply right clicking on my project and choosing Add Reference. Then browsing to where the System.Web.Extensions.dll was and selecting that. It added the reference into the references folder and the error went away.

My colleages had a ASP.NET Website, and i have a ASP.NET Web Application.
I had to add this library also as a reference and they did not. And now after HOURS of searching the project compiled immediately and ajax worked!

3 01 2009
Leonardo

Thanks for the tip…. it helps a looot!!!!

28 01 2009
Renga

Simply Fantastic… superb

20 07 2009
Serena

I love u .. u have no idea how much u help me !!!

17 10 2009
HaPN

That’s great !!!

I meet the same problem when use master page.
Now it is OK.
Thanks.

Leave a comment