Results 1 to 4 of 4

Thread: Declare controls in code-behind

  1. #1

    Thread Starter
    Registered User
    Join Date
    Jul 2002
    Posts
    80

    Declare controls in code-behind

    I am building a web app and learning asp.net as I go along. From what I understand I must declare every control that is on my presentation in my code-behind. My problem is I have many web controls and think it's a big task to declare every control. Is there a quick and easy way that I can declare them in my code-behind? I wanted to use a for loop however, I don't know the best way to use the for loop. Please help.

    James

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    There's not.

    If you use Visual Studio with code-behind, Visual Studio will do it for you.

    Any other setup requires you do it yourself the long way....
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  3. #3

    Thread Starter
    Registered User
    Join Date
    Jul 2002
    Posts
    80
    I am using visual studio but I don't know how Visual Studio will do it for me. I just install VS.NET yesterday. I'm still use to writing code in Notepad. Can someone explain how to do it in VS.NET?

    Thanks,

    James

  4. #4
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    Make sure that the following are true:

    1) You created a project for your application. If not, go to file --> New and create one. When it creates the project, right click Webform1.aspx and REMOVE it. then, right click the name of your project and ADD an EXISTING FILE. Chose your aspx file you already created. Do this again for your aspx.vb file.

    2) Your file is an ASPX file.

    3) The @Page directive has a codebehind attribute pointing to a page ending with .vb

    Then, if you ever add controls in HTML view, switch to design view briefly so that they are added to the code behind page.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width