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. Adding Class file

Adding Class file

Scheduled Pinned Locked Moved C#
questioncsharpdesignhelp
13 Posts 4 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi All, I added a C# class file to the C# project. I want to use the drop down control at runtime. I get an error when I write using System.Web.UI.WebControls; on top of the page. Can't we not use it?? How do I access any control at runtime in a class. Please let me know. Thanks.

    C 1 Reply Last reply
    0
    • L Lost User

      Hi All, I added a C# class file to the C# project. I want to use the drop down control at runtime. I get an error when I write using System.Web.UI.WebControls; on top of the page. Can't we not use it?? How do I access any control at runtime in a class. Please let me know. Thanks.

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

      You're probably trying to use web controls in a project that has not imported the dll that contains them But that's a wild guess, seeing as you've not told us the error. 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
      • C Christian Graus

        You're probably trying to use web controls in a project that has not imported the dll that contains them But that's a wild guess, seeing as you've not told us the error. 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
        #3

        Thanks. The error is The type or namespace name 'UI' does not exist in the class or namespace 'System.Web' (are you missing an assembly reference?)

        C 1 Reply Last reply
        0
        • M MyThread

          Thanks. The error is The type or namespace name 'UI' does not exist in the class or namespace 'System.Web' (are you missing an assembly reference?)

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

          Yep - I'm right then. I'm not sure if you can use the web controls outside an ASP.NET project. They work by generating HTML in conjuction with the ASP.NET ISAPI filter, you realise that, right ? What's wrong with the Windows controls ? 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
          • C Christian Graus

            Yep - I'm right then. I'm not sure if you can use the web controls outside an ASP.NET project. They work by generating HTML in conjuction with the ASP.NET ISAPI filter, you realise that, right ? What's wrong with the Windows controls ? 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. Ok, now I just converted a code from VB.net class file to a C# class file. This works fine in VB.net. But it gave error here.

            C 1 Reply Last reply
            0
            • M MyThread

              Thanks. Ok, now I just converted a code from VB.net class file to a C# class file. This works fine in VB.net. But it gave error here.

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

              OK, in that case your converter sucks. Just add the reference ( there's a references section on the top of the project, just right click and choose add reference, and look for System.Web, or whatever it is you need ) and you should be fine. 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
              • C Christian Graus

                OK, in that case your converter sucks. Just add the reference ( there's a references section on the top of the project, just right click and choose add reference, and look for System.Web, or whatever it is you need ) and you should be fine. 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
                #7

                Thanks a lot. I have added the statment: using System.Web.UI.WebControls; I no longet get the error. But when I write using System. I don't see "Web" in the intellisense. Why?? ANy idea.

                C 1 Reply Last reply
                0
                • M MyThread

                  Thanks a lot. I have added the statment: using System.Web.UI.WebControls; I no longet get the error. But when I write using System. I don't see "Web" in the intellisense. Why?? ANy idea.

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

                  Intellisense is unreliable at the best of times - don't worry about it. :-) 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
                  • C Christian Graus

                    Intellisense is unreliable at the best of times - don't worry about it. :-) 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
                    #9

                    Cool! I have another Q, how do I create an ascx file for a user control. When I click on "Add user control", I get a xyz.cs file and not ascx file. This is the last Q...

                    C 1 Reply Last reply
                    0
                    • M MyThread

                      Cool! I have another Q, how do I create an ascx file for a user control. When I click on "Add user control", I get a xyz.cs file and not ascx file. This is the last Q...

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

                      There are two types of controls, one that has an ascx, and one that is code only. Make sure you're creating a 'web user control'. 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
                      • C Christian Graus

                        There are two types of controls, one that has an ascx, and one that is code only. Make sure you're creating a 'web user control'. 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
                        #11

                        How do I add the ascx file? If I add the Usercontrol file, I get .cs extension file. I then change the extension to .ascx but I can't view the code. What am i doing wrong. This is really bugging.

                        C L 2 Replies Last reply
                        0
                        • M MyThread

                          How do I add the ascx file? If I add the Usercontrol file, I get .cs extension file. I then change the extension to .ascx but I can't view the code. What am i doing wrong. This is really bugging.

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

                          Changing the extension would be a dumb thing to do. For starters, you need a .cs file in a user control as well. Like I said, if I right click on the project and choose 'Add Web User Control', I get an ascx. It's a custom control that doesn't have an ascx file. There is something very screwy about your setup, or how you're going about this. 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
                          • M MyThread

                            How do I add the ascx file? If I add the Usercontrol file, I get .cs extension file. I then change the extension to .ascx but I can't view the code. What am i doing wrong. This is really bugging.

                            L Offline
                            L Offline
                            Luis Alonso Ramos
                            wrote on last edited by
                            #13

                            You probably have a Windows Forms project when you want an ASP.NET project. Can you verify that? How to know: select the project name in the Solution Explorer. The property window should have only two items, project file and project folder. Project folder should be disabled. If project folder is a normal path, it's a Windows Forms project. If it is a URL (http://localhost....) it's an ASP.NET project. -- LuisR


                            Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

                            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