AjaxFileUpload Issue not showing up properly - asp.net

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>

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.

Controlling the page from reaching the top of the page

I have a registration page with many fields and DDl's when i scroll down and select the ddl value then the page going to top of the page and again i have to scroll to the control and have to select the page.How to control the page by stopping at the control even though the value is changed.
Use MaintainScrollPositionOnPostback="true" in Page directive
Something like this
<%# Page MaintainScrollPositionOnPostback="true" %>
to know more about this Go here.
Alternatively you can, put this in Web.config to make this setting global, By this
<?xml version="1.0"?>
<configuration>
<system.web>
<pages maintainScrollPositionOnPostBack="true">
</pages>
</system.web>
<configuration>

ASP.NET error: The page Y.ascx cannot use the user control X.ascx

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).

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).

HTML in an ASP.NET Dynamic Data MultilineText Control

I'm trying to enter a little bit of HTML into an ASP.NET Dynamic Data MultilineText_Edit control, just a couple of <br> tags to have line breaks when I output the value of the column on a web page.
However, when I try to click the "Update" link on the Dynamic Data edit page, nothing happens. I don't even get an error message, which I would expect if HTML input were not allowed via some rule the control has built in. As soon as I remove the tag, the update link works correctly. It's not a column size issue, I can add a bunch more characters to the input and everything works fine.
Is HTML input not allowed in these controls, or is there something else going on? If there is some kind of validation rule, can it be turned off? Or is there something in the database that I need to set? Should I use something other than the default multiline text template?
Input validation is a built in feature in ASP.NET 2.0 or later. I don't know why you are not getting an error, but check this out to see if it helps:
http://www.asp.net/learn/whitepapers/request-validation/
Check these settings, on the page:
<%# Page validateRequest="false" %>
or the web.config:
<configuration>
<system.web>
<pages validateRequest="false" />
</system.web>
</configuration>

Resources