Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Web control

Web control

Scheduled Pinned Locked Moved C#
helpdesign
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MyThread
    wrote on last edited by
    #1

    Hi, Can we create a webcontrol like WebControl ctrl = new WebControl() ; The above code is in a class that inherits from "System.Web.UI.UserControl" It gives me error 'System.Web.UI.WebControls.WebControl.WebControl()' is inaccessible due to its protection level Thanks for your help!

    C C 2 Replies Last reply
    0
    • M MyThread

      Hi, Can we create a webcontrol like WebControl ctrl = new WebControl() ; The above code is in a class that inherits from "System.Web.UI.UserControl" It gives me error 'System.Web.UI.WebControls.WebControl.WebControl()' is inaccessible due to its protection level Thanks for your help!

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Well, you got your answer then, didn't you ? :-) What were you hoping to do with this 'webcontrol' ?? From MSDN: Serves as the base class that defines the methods, properties and events common to all controls in the System.Web.UI.WebControls namespace. It's a base class. It's empty contstructor is protected, although it has one that is public: WebControl Constructor (HtmlTextWriterTag) Initializes a new instance of the WebControl class using the specified HTML tag. It took be 5 seconds to find all this out with google. Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer

      M 1 Reply Last reply
      0
      • M MyThread

        Hi, Can we create a webcontrol like WebControl ctrl = new WebControl() ; The above code is in a class that inherits from "System.Web.UI.UserControl" It gives me error 'System.Web.UI.WebControls.WebControl.WebControl()' is inaccessible due to its protection level Thanks for your help!

        C Offline
        C Offline
        Charlie Williams
        wrote on last edited by
        #3

        WebControl's parameterless constructor is protected, meaning that is only accessable to classes deriving from WebControl, which UserControl does not. Charlie if(!curlies){ return; }

        M 1 Reply Last reply
        0
        • C Charlie Williams

          WebControl's parameterless constructor is protected, meaning that is only accessable to classes deriving from WebControl, which UserControl does not. Charlie if(!curlies){ return; }

          M Offline
          M Offline
          MyThread
          wrote on last edited by
          #4

          Thanks for response. That's why I worte like this: public class MyControl: System.Web.UI.WebControls.WebControl instead of public class MyControl: System.Web.UI.UserControl I was able to get rid of the error. I am not sure if that's the correct solution. By default, ascx control inherits from System.Web.UI.UserControl

          1 Reply Last reply
          0
          • C Christian Graus

            Well, you got your answer then, didn't you ? :-) What were you hoping to do with this 'webcontrol' ?? From MSDN: Serves as the base class that defines the methods, properties and events common to all controls in the System.Web.UI.WebControls namespace. It's a base class. It's empty contstructor is protected, although it has one that is public: WebControl Constructor (HtmlTextWriterTag) Initializes a new instance of the WebControl class using the specified HTML tag. It took be 5 seconds to find all this out with google. Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer

            M Offline
            M Offline
            MyThread
            wrote on last edited by
            #5

            Thanks for your response. :) I found about it on MSDN but I dont want to pass HtmlTextWriterTag. Will passing this as a parameter and passing nothing make a difference?

            C 1 Reply Last reply
            0
            • M MyThread

              Thanks for your response. :) I found about it on MSDN but I dont want to pass HtmlTextWriterTag. Will passing this as a parameter and passing nothing make a difference?

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              I can only imagine that it would end in disaster. If you're creating your own control, just derive from UserControl, which is what you should do anyhow. Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups