How can I add namespaces to my asp.net page? - asp.net

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:

Related

User Controls not working in Visual Studio 2015

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.

ajaxtool kit - Html editor tools not displayed

I have installed ajaxtoolkit version 4.5 and included below lines in the config under controls tag
<add tagPrefix="ajaxtoolkit"
namespace="AjaxControlToolkit"
assembly="AjaxControlToolKit"/>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %>
<ajaxtoolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxtoolkit:ToolkitScriptManager>
<cc1:Editor ID="Editor1" runat="server" Width="300" Height="400"/>
if i use html editor control getting the below error in IE9
0x800a139e - Microsoft JScript runtime error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the ToolkitScriptManager in AjaxControlToolkit.dll.
and in chrome the editor is displayed with no tools in it.
Please help to resolve this
Please change your code like this:
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></cc1:ToolkitScriptManager>
HTML Markup:
<cc1:Editor ID="Editor1" runat="server" Width="300" Height="400"/>
You can save your HTMLEditor content in database like this:
string lsPageContent = Server.HtmlEncode(Editor1.Content);
Insert into [TableName] (PageContent) Values ('" + lsPageContent + "');
and fetch page content like this:
Editor1.Content = Server.HtmlDecode(YourcolumnValue);

AjaxFileUpload Doesn't Display Correctly or Function: Mysterious Black Button

I found AjaxFileUpload in the toolkit when searching for ways to upload multiple files.
I used NuGet to install.
Added <%# Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%> to the top of the page.
Ensured web.config has the reference:
<pages>
<controls>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
</controls>
</pages>
Where I presume the the upload button should be, I get a black box, when I run the page. The preview does show up correctly.
I did try it in a completely empty page (no master page or anything) and I get the same result.
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="School_Scheduler_2.Associates.test" %>
<%# Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<ajaxToolkit:AjaxFileUpload runAt="server" ID="multiUpload" />
</form>
</body>
</html>
Any suggestions?
Answer Since My Account Is Too Noob to the Post Answer Myself
This explains it: https://ajaxcontroltoolkit.codeplex.com/workitem/27493
Long story short: The Ajax Tool Kit does not like the vanilla ScriptManager. It insists on using their own ToolkitScriptManager.
This causes havoc with my MasterPages (I put the script manager on there to save me from adding it everywhere), but at least I know now and can start scheming possible solutions.
try this
<asp:ToolkitScriptManager ID="ScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<div align="center">
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" AllowedFileTypes="jpg,jpeg,png,gif"
MaximumNumberOfFiles="10" OnUploadComplete="File_Upload"
Width="500px" />
Old question, but make sure to debug any javascript errors. Any errors will cause the described black button.
If you have any client side code that runs on OnClientUploadCompleteAll=, but fail to copy this code to a new page if you are copy/pasting the AjaxFileUpload control, you get a javascript error and it fails to render the control at this point, just leaving you with the black button.

TextBoxWatermarkExtender

i am new to asp.net and i was to work in AjaxControlToolkit and i instaled and performed other operation but it is showing me report...,
error is:
The type name 'TextBoxWatermarkExtender' does not exist in the type 'AjaxControlToolkit'
protected global::AjaxControlToolkit.TextBoxWatermarkExtender TextBoxWatermarkExtender1;
code is:
<asp:TextBoxWatermarkExtender id="TBWEDOB" runat="server" targetcontrolid="txtDOB"
watermarktext="dd/mm/yy" watermarkcssclass="watermarked"> </asp:TextBoxWatermarkExtender>
plz any one pelp me on this flow....,
First Check This
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
in Your Page and see what is the TagPrefix in your page and than use that.like
<asp:TextBoxWatermarkExtender ID="TBWE2" runat="server"
TargetControlID="TextBox1"
WatermarkText="Type First Name Here"
WatermarkCssClass="watermarked" />
it will work defiantly
Why don't you simply try placeholder property to achieve the watermark in input fields.
Yes, There is a restriction of older browser, so if you are working with newer version (suppots HTML 5) then you can use it like this
<asp:TextBox ID="textbox1" runat="server" placeholder="dd/mm/yyyy"></asp:TextBox>
You haven't provided much information so it will be tough to identify where your mistake is, here's a simple step-by-step list of how you can use AJAX in your application, just follow the points below and it will work:
1) Download AJAX from codeplex, save and unzip anywhere on your machine
2) In Visual Studio Toolbox, Right click-> Add Tab, give it a name
3) Right click the newly created tab -> Choose Items...
4) Click Browse, find AjaxControlToolkit.dll and click OK
5) If all is well the controls will be added to your toolbox
6) Drag and drop a ToolkitScriptManager to the .aspx page, doing this will automatically:
6.1) Add a AjaxControlToolkit.dll reference to your project
6.2) Add the following line to the source view of your page
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
7)Drag and drop a TextBoxWatermarkExtender to the .aspx page and you're done:
<asp:ToolkitScriptManager ID="sm" runat="server" />
<asp:TextBoxWatermarkExtender ID="watermark" runat="server" TargetControlID="txtName" WatermarkText="Type name here..." />
<asp:TextBox ID="txtName" runat="server" />
try modifying the tag prefix
on the top of the page register the ajax tool kit.
<%# Register Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" TagPrefix="ajax" %>
<ajax:TextBoxWatermarkExtender id="TBWEDOB" runat="server" targetcontrolid="txtDOB"
watermarktext="dd/mm/yy" watermarkcssclass="watermarked"> </ajax:TextBoxWatermarkExtender>

Cannot see new asp.net user controls

I am feeling like an idiot right now, but I cannot for the life of me figure out why I cannot seem to call user controls from within my asp.net webpage. I'm still learning asp.net but I can't find any information from searching on google.
I'm trying to load a specific control on the page when the user presses a linkbutton. So I created an empty user control via the right click menu:
<%# Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
In other words, I have not touched any part of the created user control. Yet attempting to create this web control and add it to the form seems to not work, as it claims that the WebUserControl class does not exist (I have no other controls in my project):
UserControl blah = new WebUserControls();
produces a "The type or namespace is invalid". Why can none of my asp.net webform pages get the control into scope?
The new control must be added to the site's Web.config file.
<configuration>
<system.web>
<pages>
<controls>
<add tagPrefix="my"
tagName="WebUserControl"
src="~/WebUserControl.ascx"/>
</controls>
</pages>
</system.web>
</configuration>
Use this to place the new control in an .aspx page.
<my:WebUserControl runat="server" ID="MyWebUserControl" />
In addition to registering them one-by-one in web.config, you can also use a <%# Register %> directive in the source of the markup files that reference the control.
Or, you can move your controls into a DLL and include them all by referencing the assembly from your web.config (takes some extra work, though).

Resources