AjaxToolkit for 3.5 not working

时间秒杀一切 提交于 2019-12-24 01:19:14

问题


I am trying to use ajaxtool kit downloaded from here for colorpicker.

When i tries to use this on any of my page, it shows me an error

        This page is missing a HtmlHead control which is required for the CSS
 stylesheetlink that is being added. Please add <head runat="server" />. 

What can be the reason. I am using ToolScriptManager rather than Script Manager as said in the documentation. I am using Asp.net 3.5 and using colorPicker control under a content page and adding ToolScript Manager in the same place.

As said by rafel

<head>
<title>l</title>
    <link href="<%= ResolveUrl("~/css/style.css") %>" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="<%= ResolveUrl("~/css/chromestyle.css") %>"/>
    <script src="<%= ResolveUrl("~/js/JScript.js") %>" type="text/javascript"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/js/chrome.js") %>"></script>


    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>

If I adds runat in head i starts getting this error

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

回答1:


I am getting the same sequence of events that Shantanu was getting. It tells me to add the runat=server to the HEAD when I add the AJAX Control Toolkit ComboBox. So I did that and then it started saying

"The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)." again just like in Shantanu's case.

If I am reading this correctly, is it saying I cannot use the AJAX Control Toolkit's ComboBox if I have lots of inline code in this aspx file (both in java/inline vb as well as HTML/inline vb)? I mean hey I know our aspx pages are ugly and barely hanging on, but seriously?




回答2:


You can't use <%= ResolveUrl %> when defining your javascript includes when using the Toolkit. Add the references to the header in your code behind instead.




回答3:


Ajax control is trying to add its styles to the head section of your page, but cannot do that because it cannot find it. Here's how to fix this:

<head runat="server">


来源:https://stackoverflow.com/questions/3350572/ajaxtoolkit-for-3-5-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!