.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Error with Control.ControlCollection

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :Windows Application

This code is giving me the error :Can anyone help me with it? VS 2005 .net 2

Error    1    Class, struct, or interface method must have a return type   

 public static SetEventHandlerInput(Control.ControlCollection cc)
      foreach (Control ctrl in cc)
        //Common to all controls
        ctrl.Enter -= new EventHandler(this.hnEnter);//set the color
        ctrl.Enter += new EventHandler(this.hnEnter);

        ctrl.Leave -= new EventHandler(this.hnLeave);//reset the color
        ctrl.Leave += new EventHandler(this.hnLeave);

        ctrl.KeyPress -= new KeyPressEventHandler(this.hnOnly_Keypress);//handle the enter key
        ctrl.KeyPress +=  

View Complete Post

More Related Resource Links

Custom Control Design-Time SiteMap Provider Error


Greetings - I was referred here by MSDN forums hope this is the right place -  

I have a custom control (:WebControl) that renders web.sitemap in a specific way. While it runs error free and produces the expected result, at Design-Time it complains

Error Creating Control - MyControl  The provider 'AspNetXmlSiteMapProvider' specified for the defaultProvider does not exist in the providers collection.

I have discovered that the error is cause by this line of code:

string div = string.Format("<div class='{0}' id='{1}'>{2}</div>", this.CssClass, this.ID.ToString(), EnumerateNodesRecursive(SiteMap.RootNode, level));

or more specifically, by the reference to SiteMap.RootNode - I am not clear what is missing thoough because I have configured the SiteMapProvider in web.config as this:

        <add name="AspNetXmlSiteMapProvider" 
             type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 

"Type ASP.x is not defined" error for dynamic user control when publishing updateable


I have a user control (ContainerCtrl) which programmatically instantiates another user control (SimpleCtrl) in OnLoad. It builds and runs fine, but when I publish it I get the error "error BC30002: Type 'ASP.SimpleCtrl' is not defined." (If I publish without the "updateable" option there's no error, but I need the site to be updateable.)

I assume this has to do with the particulars of how the assembly(ies) are built for the different compiler options. My question is, how can I get it to work properly for "updateable" publishing?

VS 2008 / .NET 3.5 sp1

The code follows (web.config is the default from Visual Studio).

Many thanks, Dave


<%@ Control Language="VB" ClassName="SimpleCtrl" CodeFile="SimpleCtrl.ascx.vb" Inherits="_SimpleCtrl" %>

    Simple control


Partial Class _SimpleCtrl
    Inherits UserControl

    'Nothing to see here.

End Class


<%@ Control Language="VB" CodeFile="ContainerCtrl.ascx.vb" Inherits="_ContainerCtrl"

Custom Control Design view error



I have created a custom control from scratch and it works fine as in you can build the project that uses it and it works fine at runtime. Problem is when you go to design view the control shows an error in the place of where the control should be rendered.

Error: '<SomeValue>' Could not be set to '<SomeProperty>'

This shows up on all my custom set properties. These properties are created as basic as possible. I can give the properties values in Source view and run the app just fine. I can even add a Onclick event. If I don't set any custom properties the control will render fine in Design view. It's only when I set a value to a custom property.

Property Code Example:

public string Text
                string ret = "";
                object obj = ViewState["Text"];
                if (obj != null)
                    ret = obj.ToString();
                return ret;
                ViewState["Text"] = value;

I've even removed the Category and Description tags with no difference.

I don't know if what I said makes sens, but I hope it

Using tabs from the AjaxControlToolkit causes error: ...control contains code blocks (i.e. <% ... %>


I'm getting the error:

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

When attempting to add the tabs from the AjaxControlToolkit.  A little background..Theres an existing aspx page in a microsite which used the accordion control and the tabbed control ...I need to modify this page to use a different masterpage. 

The original site was .Net Framework 2.0 and the page in question used AjaxControlToolkit 1.0. which I manually installed originally.  Some of the site has been further developed using the .Net Framework 3.5.  (Come with AjaxControlToolkit) Now I have come to update this aspx page and I get the error above.

I have narrowed the down to the TabContainer (I think)  Does anyone have any experience with this sort of problem?  Also what version of the AjaxControlToolkit should be with the .Net Framework 3.5? I have 1.0.20229.20821. 

I also tried to browse to the AjaxControlToolkit.dll to add the tools to the tool box as they're missing... thinking this may be an indicator as to why it wasn't working. I get the error: 'There was an error loading types from assembly C:\inetpub\wwwroot\project\Bin\AjaxControlToolkit.dll Could not load file or assembly 'System.Web.Extensions. Version=

Report Viewer Control Error

Hi All, I am adding a report datasource dynamically to report view web server control and getting the following eroor when i open the page. The DataSourceID of the ReportDataSource 'DataSet1_employees' of the ReportViewer 'ReportViewer1' must be the ID of a control of type IDataSource. A control with ID 'DataSet1_employees' could not be found.     Please help me where i am going wrong. The code is given below: protected void Page_Load(object sender, EventArgs e)    {        ReportViewer1.ProcessingMode = ProcessingMode.Local;        ReportViewer1.LocalReport.ReportPath = "Report2.rdlc";         ReportDataSource rdS = new ReportDataSource("Employees", GetData());        rdS.DataSourceId = "DataSet1_employees";        //this..Add(rdS);                ReportViewer1.LocalReport.DataSources.Add(rdS);        ReportViewer1.LocalReport.DataSources["Employees"].DataSourceId = "DataSet1_employees";        ReportViewer1.LocalReport.DataSources["Employees"]

Getting an error using FileUpload Control on a server.

Hello FriendsI m getting a problem while executing the following code for my website.This code works perfactly on localhost but when I use d same code on my webpage on the server it does nothing...even it doesnt return any error msg.Plz help me...protected void BtnUpload_Click(object sender, EventArgs e) {        int intFileSizeLimit = 1000;               string strFileNameWithPath = FileUpload1.PostedFile.FileName;               string strExtensionName = System.IO.Path.GetExtension(strFileNameWithPath);              string strFileName = System.IO.Path.GetFileName(strFileNameWithPath);           int intFileSize = FileUpload1.PostedFile.ContentLength / 1024;                              strExtensionName = strExtensionName.ToLower();        if (strExtensionName.Equals(".doc") || strExtensionName.Equals(".txt") || strExtensionName.Equals(".docx"))        {      

error provider control in aspx pages?

how can i add error provider control in an asp.net page using c#..  for example,if i am using a textbox control which prompts the user to fill it on clicking the submit button,how should i make the textbox control to prompt the user. someone help me with this!!! and also reply me if v can use status strip control in aspx pages

AjaxToolkit's CascadingDropDown control is throwing Method Error 404 in Hybrid system environment (

Hi Experts, We have an Asp.net web application, which is deployed in shared hosting environment. On shared hosting environment initial request to this web application is handled by Linux server and then based on the requested page the Linux server is redirecting request to web server on windows OS. Now, in our web application, we have used ajaxToolkit's CascadingDropDown control to populate three levels of categories. In the hybrid system described above, the CascadingDropDown control is throwing Method Error 404. I would appreciate if some body can guide on how to resolve this issue. The sample of code snap shot is mentioned below. ********************************************************************* Aspx file. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ <asp:DropDownList ID="ddlMajorLevelCategory" runat="server" Width="250px" ToolTip="Select Major Level Category" TabIndex="1"                            SkinID="h6BlueArial"> </asp:DropDownList>   <ajaxToolkit:CascadingDropDown ID="ccMajorCategory" runat="server" TargetControlID="ddlMajorLevelCategory" Category="M" PromptText=&qu

Error Creating Control - 'asp:UpdatePanelAnimationExtender' could not be set on property 'Animati

It doesn't seem to matter what I try to make the animation do, I keep getting this shown in the designer. No one else on google seems to be getting that problem either. Note: it doesn't cause debugging or runtime issues... in fact, the only negative thing it does is make it extremely annoying when I look at the designer... I'm going to have about 12 of these updatepanelanimations firing everytime the timer ticks too :(. MasterPage file has the toolkitscriptmanager on it. Here is my designer code for the page I'm having the issue on:<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/MasterPage.Master" CodeBehind="TimeLine.aspx.vb" Inherits="TimeLine.WebForm1" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <asp:Timer ID="Timer1" runat="server" Interval="7000"> </asp:Timer> <asp:Panel ID="Panel1" runat="server" Height="285px" HorizontalAlign="Center" Width="970px" BackImageUrl="~/Images/Img.jpg"> <br />

Ajax Control Toolkit Error Creating Control

Error Creating Control - ToolkitScriptManager1Unknown server tag 'asp:ToolkitScriptManager'.Error Creating Control - ComboBox1Unknown server tag 'asp:ComboBox'.I encountered this error, very annoying becasue it would shut off design view rendering of ComboBoxes as well as entire parent containers like ListViews.  It took me a lot of efforts to hunt down the cause, which would seem very illogical if not weird.  So I am suspecting that it is just happening to me, but would appreciate if somebody could care to reproduce and see if it is actually a bug.Cause: HtmlHead title tag has textFix: Delete text in HtmlHead title tagSteps to reproduce and verify error:1. Have AjaxControlToolkit.Binary.NET4 Instructions: http://www.asp.net/ajaxlibrary/act.ashx Download: http://ajaxcontroltoolkit.codeplex.com/releases/view/43475#DownloadId=1165342. Start Visual Studio 2010 Ultimate Open new project ASP.NET Web Application Default name WebApplication13. Keep Default.aspx open Add Ajax Control Toolkit in Toolbox Close Default.aspx4. Add new folder in WebApplication1 Default name NewFolder15. Add new nested master page in NewFolder1 Default name NestedMasterPage1.master Select Site.Master as master page6. Open NestedMasterPage1.master Add ContentPlaceHolder in Content2 Default ID ContentPlaceHolde

Error when i add an ajax control

Hello guys,i get the error, below when i add an ajax control to either my masterpage or webform. funny, am not using any external controls, as am building it from scratchtnxEhiServer Error in '/' Application. Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Unknown server tag 'asp:ScriptManager'.Source Error:  Line 43: <asp:SiteMapDataSource ID="main1" runat="server" SiteMapProvider="main" /> Line 44: Line 45: <asp:ScriptManager ID="ScriptManager1" runat="server"> Line 46: </asp:ScriptManager> Line 47: Source File: /codes/default.master    Line: 45 

help with error when using css friendly control adapter

I have installed the CSS friendly control adapters for my menus and treeview because the designer did the entire job in with <div><ul><li> instead of tables   so to adapt I installed the CSS adapter. Tyat worked great for my menu and treeview. Really. The thing is that I dont need the adapter for anything else then my menu and treeview But when I navigate to a page that has a regular wizard control (not a create user wizard) then it gets stuck on 1 line of code and gives the following error:  Unable to cast object of type 'System.Web.UI.WebControls.WizardStep' to type 'System.Web.UI.WebControls.TemplatedWizardStep'. What can I do? can I dissable part of the adapters to not adapt my wizard? When I get the error It is normally stuck on that line opf code below which is underlined and bold. Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter) If (Extender.AdapterEnabled) Then Dim wizard As CreateUserWizard = Control If (Not IsNothing(wizard)) Then Dim activeStep As TemplatedWizardStep = wizard.ActiveStep If (Not IsNothing(activeStep)) Then If (Not IsNothing(activeStep.ContentTemplate)) Then activeStep.RenderControl(writer) If (wizard.CreateUserStep.Equals(activeStep)) Then WriteCreateUserButtonPanel(writer, wizard) End If ' Might need to add logic here to render nav buttons for other kinds of ' steps (besides t

SSIS Execute Process Task Give "Access is Denied" error but it is not related to access control.

Hello All - I have a very weired SSIS problem. I am using BIDS in two machines - Windows 7 Professional Edition x64 bit (development workstation) and Windows 2003 Standard Edition x32 bit SP2 (server) . The visual studio version on both the machines are Version 2.0.50727 SP2. I found that my package's ExecuteProcessTask fails with "Access is denied" error in Windows2003 but runs ok in Windows 7 dev box. I then tried to debug the package in the Windows 2003 environment itself. The package failed in debug mode too with the same message. After looking for a while I found that when I shorten the Argument length of the failing ExecuteProcessTask the task did seem to work. So in Windows2003 environment if my argument exceeds 1846 characters the ExecuteProcessTask fails with message "Access is Denied". If the argument string is less than 1846 it works ok. In Windows 7 environment there is no problem at all. It does not seem like access problem but I may be wrong. Has anyone seen this? I will appreciate any reply. Thanks, Niben  

ASP:Upload control . Uploading into a SharePoint Document Library Subfolder and FILE NOT FOUND error

RE: ASP:Upload control . Uploading into a SharePoint Document Library Subfolder and FILE NOT FOUND error Two Issues, apparently unrelated. I have subfolders like this /ApplicantDocuments/20 and /ApplicantDocuments/21 (where 20 and 21 are my subfolders and ApplicantDocuments is my library. 1. The below function is erroring with file not found, but I confirmed I'm sending the fully qualify path (i.e c:\test.txt) to System.IO.FileStream content = System.IO.File.Open(documentFileName, System.IO.FileMode.Open); 2. Even if it worked, looking at the code, I'm not using argument foldername.  I'm passing 20 to the argument. How can I make sure it uploads into subfolder 20 of ApplicantDocuments? Thank you.     Just testing in test environment. Will tighten code once it works.   public void UploadDocumentToSite(string foldername, string documentFileName) {      SPSite siteCollection = new SPSite("https://xxxxxx");      SPWeb web = siteCollection.OpenWeb();      //SPSite.AllowUnsafeUpdates = true;      //Web.AllowUnsafeUpdates = true;      string Lib = "ApplicantDocuments";      SPFolder destFolder = web.GetFolder(Lib);      sendmail(documentFileName+" "+foldername);  

windows form control library error in asp.net

Can some tell me what is this problem?my windows form control library have the drag and drop.when i open in web, the below error pop out.

Gridview control Delete error -- Must declare the scalar variable "@GradeID"

 Hi All,Pardon me if this seems redundant. I have searched the archives and found many references to this type of error. Most (all?) boil down to a mismatch between the token for the databound field and the sql parameter. I have stared at this code for a long time and can see nothing wrong with it. In fact, it is so simple that I started over from scratch using only the designer (ie I wrote no code), so I don't see how it possible to have a name mismatch. I would very much appreciate any help figuring out what is the problem here. Thank you very much in advance.-Roger   Server Error in '/ssp/inet220a06' Application. Must declare the scalar variable "@GradeID". Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Must declare the scalar variable "@GradeID". Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Object Reference Error While Rendering Menu Control


I am having a problem with rendering a menu control inside a server control. I am getting an error in the RenderContents override method when I try to render the Menu Control. The error I am getting is an Object Reference error. The code is below...

[ToolboxData("<{0}:Login runat=server></{0}:Login>")]
    public class Login : CompositeControl
        #region Members

        Label tst;
        Menu loginMenu;
        MenuItem mainLoginItem;
        MenuItem loginItem;
        MenuItem usernameItem;
        MenuItem passwordItem;
        SubMenuStyle subMnuStyleControl;
        SubMenuStyle subMnuStyleMenu;

        bool isLoggedIn = false;


        #region Properties

        public bool IsLoggedIn
            get { return isLoggedIn; }

            set { isLoggedIn = value; }


        #region Overridden Events

        protected override void RenderContents(HtmlTextWriter writer)



        protected override void OnInit(EventArgs e)

            #region Add CSS references
            string cssUrl = Page.ClientScript.GetWebResourceUrl(this.Ge
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend