A user control that was working is no longer being picked up in the ASPX file.
ASPX File
<%# Register TagPrefix="Uc1" TagName="ContactForm" Src="~/Controls/VFEmailForm.ascx" %>
<uc1:VFEmailForm ID="VFEmailForm" runat="server" />
It was working but now isn't. A green line appears under the uc1:VFEmailForm and when you type Uc intellisense doesn't show Uc1. It is as though the register statement does not work - well it obviously doesn't. This was all working prior to upgrading to Visual Studio 2015.
I've shown part of my web.config file as ancient posts have suggested this may be the cause.
Web.config
<pages>
<namespaces>
<add namespace="System.Web.Optimization" />
</namespaces>
<controls>
<add tagPrefix="webopt" assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" />
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
</controls>
</pages>
If there is a guru out there who can fix this I would appreciate it.
I had the same problem when building under x64. I switched to x86, rebuilt the project and VS 2015 worked as expected.
I was also in your situation a bit time ago.
1 .Try using the same tag name in both lines :
As in your case
<%# Register TagPrefix="uc1" TagName="ContactForm" Src="~/Controls/VFEmailForm.ascx" %>
<uc1:ContactForm ID="VFEmailForm" runat="server" />
If it helps then ok, otherwise after making this change , try restarting the visual studio.
This procedure helped me out.
I use Visual studio 2017, and faced a similar problem: Having green, wavy lines under the tagName instead the whole line, i.e., <Uc1:***ContactForm*** ...>. As part of this, I was getting this error:
Element ContactForm is not a known element.
A solution posted by #mitoutsnd on ASP.NET solved the problem by suggesting that I use:
Build > Rebuild Solution
This solved my problem.
Related
We are upgrading our project from .Net2.0 to .net4.5.1.
The aspx page contains iframe tag as follows,
<iframe id="doc_preview" runat="server" src="" style="DISPLAY:inline; VISIBILITY:hidden"></iframe>
while building the project im getting the build error like "the type system.web.ui.htmlcontrols.htmliframe is not defined"
how can i resolve this?
Change the iframe to:
<asp:HtmlIframe id="doc_preview" runat="server" />
Rather than adding runat="server" to your iframe.
If it still throws issues then you'll want to add this to your web.config to make sure htmlcontrols are reference:
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.HtmlControls" assembly="System.Web"/>
</controls>
I've just added Ajax Control Toolkit with NuGet, and I want to add the following piechart:
<ajaxToolkit:PieChart ID="pieChart1" runat="server" ChartHeight="300"
ChartWidth="450" ChartTitle="Widget Production in the world"
ChartTitleColor="#0E426C">
<PieChartValues>
<ajaxToolkit:PieChartValue Category="United States" Data="45"
PieChartValueColor="#6C1E83" PieChartValueStrokeColor="black" />
<ajaxToolkit:PieChartValue Category="Europe" Data="25"
PieChartValueColor="#D08AD9" PieChartValueStrokeColor="black" />
<ajaxToolkit:PieChartValue Category="Asia" Data="17"
PieChartValueColor="#6586A7" PieChartValueStrokeColor="black" />
<ajaxToolkit:PieChartValue Category="Australia" Data="13"
PieChartValueColor="#0E426C" PieChartValueStrokeColor="black" />
</PieChartValues>
</ajaxToolkit:PieChart>
However, my page has no clue what PieChart is, how can I add ajaxToolkit and link it to the dll file in the aspx page?
Mine looks like this:
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
If you drop an ajax control onto the form, it should create the registration for you. Mine above is an auto generated reference to the ajax toolkit. You also have to add a reference to the Ajax dll through the project references (although Nuget might have done this already, not sure).
I hope the following images will be useful. And download the needed AJAX .dll file.
Add this:
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
Step 1:
Step 2:
Step 3:
Step 4:
I've recently started working on a new project and have come across some difficulties using the AjaxControlToolkit (more specifically the AjaxFileUpload control). I've used this toolkit and control on other projects successfully but I'm not sure what's going on in this one. I've referenced the AjaxControlToolkit, put the required lines in my web.config, put the required lines in my aspx pages and set up a script manager and everything seems to be good. The site launches without error and it sort of shows up but it's not working properly. Basically what's showing up is a blacked out box that looks like the "Upload" button, which when clicked allows me to select a file. However none of the other functionality of the control is working. The first two blocks in the image are two seperate FileUploadControls and the 3rd block is an asyncfileupload control....Anyone have any idea what's going on!?!
see image here: http://img571.imageshack.us/img571/3417/screenshot20130223at111.png
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControlToolkit" %> //at top of page
<AjaxControlToolkit:ToolkitScriptManager ID="tsm1" runat="server"></AjaxControlToolkit:ToolkitScriptManager> //on page
<AjaxControlToolkit:AjaxFileUpload ID="ajaxupload1" runat="server" />//on page
<pages>//web.config
<controls>
<add tagPrefix="AjaxControlToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
</controls>
</pages>
As I've said the project builds and launches fine, no errors, and as you can see in the screenshot it attempts to build the controls but something is off...
It was something in my web.config, not 100% sure what but I was messing around with it and got it working fine. So if anyone else has this issue it's probably something in your web.config :)
I had to add this to my web.config file:
<handlers>
<add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
</handlers>
I am getting the error below when trying to build the web site project in Visual Studio 2010:
The page '/WebSite/controls/C2.ascx' cannot use the user control '/WebSite/controls/C1.ascx', because it is registered in web.config and lives in the same directory as the page.
I have 2 web user controls:
controls/C1.ascx
controls/C2.ascx
The controls have been registered in web.config:
<configuration>
<system.web>
<pages>
<controls>
<add src="~/controls/C1.ascx" tagPrefix="my" tagName="C1"/>
<add src="~/controls/C2.ascx" tagPrefix="my" tagName="C2"/>
</controls>
</pages>
</system.web>
</configuration>
C1.ascx contains just a static HTML, C2.ascx is trying to include C1:
C1.ascx contains just some plain static simple HTML. C2.ascx is trying to include C1.ascx:
<%# Control Language="VB" %>
<my:C1 runat="server" />
<p>Hello from C2</p>
When trying to build the project, I am getting the error message at the top. I realise this issue can be fixed by adding another Register directive to C2.ascx...:
<%# Register Src="~/controls/C1.ascx" TagPrefix="ctl" TagName="C1" %>
...but I'm wondering if there's a cleaner solution and why am I getting the error in the first place?
Your only possible solutions are to:
Move the control out of the directory its currently sharing with outer.ascx, or
Re-register the control inside of the outer.ascx like you already mentioned
Re-write them in code as controls in a separate library
I personally think moving is the easiest, if it will work for your solutions. Second would be re-registering, even though annoying. Abstracting them out into a full code library is probably not worth the effort if this is the only reason you are doing it.
You could also put the controls into different folders. But I don't think this is much cleaner or better.
BTW: this behavior is by design, as you can read on this MSDN page (look for the yellow note almost at the end of the page).
The MvcReCaptcha library looks very solid, and appears to have some good developer adoption, but when I tried it for the first time today, using the supplied HTML helper, my app won't run. I have the helper in a partial view as follows:
<fieldset>
<legend>3. Verify that you are a human.</legend>
#Html.GenerateCaptcha()
</fieldset>
I have the namespace included in web.config as instructed:
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="MvcReCaptcha.Helpers"/>
</namespaces>
</pages>
(Other namespaces removed for brevity)
And I have my private and public keys defined in appSettings. I can see no way that I deviate from the examples on the CodePlex page except that I am using Razor. Can anyone offer some insight into what I may be doing wrong?
If you are using Razor you need to add the MvcReCaptcha.Helpers namespace to the <namespaces> section of ~/Views/web.config file and not the one in ~/web.config.