automatic insertion of controls on codebehind

Discussion in 'ASP .Net' started by Boban Dragojlovic, Jul 23, 2003.

  1. I create a new webform (I always use codebehind), and I insert some server-side controls into the form (the ASPX)

    Later, I switch to codeview, and I notice that some (sometimes all) of the controls I created have been automatically defined for me in the
    #Region " Web Form Designer Generated Code "
    section

    Later, when I add more controls this no longer happens.


    First, I'm wondering which of my actions causes it to no longer do this;

    and

    is there a command I can issue to force it to "review" the ASPX page and re-synchronize the codebehind form?
    Boban Dragojlovic, Jul 23, 2003
    #1
    1. Advertising

  2. Actually, I type all my controls in HTML View because I don't like to work with the form designer. Yet in spite of that, VS often manages to "see" them and place them into the codebehind.

    "Steve C. Orr, MCSD" <> wrote in message news:...
    If you drag the control from the toolbox then it should always put the declaration in the code behind for you, assuming such an action is valid for that control. For instance, if you drag an HTML control instead of a webform and you don't mark it as a server control then the definition will not be in the code behind because it's not valid to be there.
    Also, if you type in the control definition into the HTML view of your page (instead of dragging it from the toolbar onto the designer view of your form) then I wouldn't expect VS.NET to automatically put the definition into the code behind for you.

    --
    I hope this helps,
    Steve C. Orr, MCSD
    http://Steve.Orr.net


    "Boban Dragojlovic" <news@_N_O_S_P_AM_dragojlovic.org> wrote in message news:g6ETa.47$...

    I create a new webform (I always use codebehind), and I insert some server-side controls into the form (the ASPX)

    Later, I switch to codeview, and I notice that some (sometimes all) of the controls I created have been automatically defined for me in the
    #Region " Web Form Designer Generated Code "
    section

    Later, when I add more controls this no longer happens.


    First, I'm wondering which of my actions causes it to no longer do this;

    and

    is there a command I can issue to force it to "review" the ASPX page and re-synchronize the codebehind form?
    Boban Dragojlovic, Jul 24, 2003
    #2
    1. Advertising

  3. Boban,

    I've noticed similar happenings. I have an untested theory. Could you sometimes be switching directly from the html view to the codebehind? And other times switching from the html view to the design view and THEN to the codebehind?

    My theory is that if you switch from html view to design view the page gets processed and your objects are added to the codebehind.



    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche
    "Boban Dragojlovic" <news@_N_O_S_P_AM_dragojlovic.org> wrote in message news:4BETa.51$...
    Actually, I type all my controls in HTML View because I don't like to work with the form designer. Yet in spite of that, VS often manages to "see" them and place them into the codebehind.

    "Steve C. Orr, MCSD" <> wrote in message news:...
    If you drag the control from the toolbox then it should always put the declaration in the code behind for you, assuming such an action is valid for that control. For instance, if you drag an HTML control instead of a webform and you don't mark it as a server control then the definition will not be in the code behind because it's not valid to be there.
    Also, if you type in the control definition into the HTML view of your page (instead of dragging it from the toolbar onto the designer view of your form) then I wouldn't expect VS.NET to automatically put the definition into the code behind for you.

    --
    I hope this helps,
    Steve C. Orr, MCSD
    http://Steve.Orr.net


    "Boban Dragojlovic" <news@_N_O_S_P_AM_dragojlovic.org> wrote in message news:g6ETa.47$...

    I create a new webform (I always use codebehind), and I insert some server-side controls into the form (the ASPX)

    Later, I switch to codeview, and I notice that some (sometimes all) of the controls I created have been automatically defined for me in the
    #Region " Web Form Designer Generated Code "
    section

    Later, when I add more controls this no longer happens.


    First, I'm wondering which of my actions causes it to no longer do this;

    and

    is there a command I can issue to force it to "review" the ASPX page and re-synchronize the codebehind form?
    S. Justin Gengo, Jul 24, 2003
    #3
  4. I would agree with this theory as the HTML code gets "tidied up" when
    switching to design and back to HTML (tables and other elements get
    indented, etc).

    "S. Justin Gengo" <> wrote in message
    news:%...
    Boban,

    I've noticed similar happenings. I have an untested theory. Could you
    sometimes be switching directly from the html view to the codebehind? And
    other times switching from the html view to the design view and THEN to the
    codebehind?

    My theory is that if you switch from html view to design view the page gets
    processed and your objects are added to the codebehind.



    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche
    "Boban Dragojlovic" <news@_N_O_S_P_AM_dragojlovic.org> wrote in message
    news:4BETa.51$...
    Actually, I type all my controls in HTML View because I don't like to work
    with the form designer. Yet in spite of that, VS often manages to "see"
    them and place them into the codebehind.

    "Steve C. Orr, MCSD" <> wrote in message
    news:...
    If you drag the control from the toolbox then it should always put the
    declaration in the code behind for you, assuming such an action is valid for
    that control. For instance, if you drag an HTML control instead of a
    webform and you don't mark it as a server control then the definition will
    not be in the code behind because it's not valid to be there.
    Also, if you type in the control definition into the HTML view of your page
    (instead of dragging it from the toolbar onto the designer view of your
    form) then I wouldn't expect VS.NET to automatically put the definition into
    the code behind for you.
    news.public.microsoft.com, Jul 24, 2003
    #4
  5. Interesting. You may have hit it on the head.

    I just added a control in HTML view (as I always do). I then switched to Design view, and back to HTML view. Then I switched back to codeview, and voila - there it was.

    Aaaaahhhhh. What a delight. It is SUCH a pain having to manually define them all in codeview.

    Thanks, Justin

    "S. Justin Gengo" <> wrote in message news:%...
    Boban,

    I've noticed similar happenings. I have an untested theory. Could you sometimes be switching directly from the html view to the codebehind? And other times switching from the html view to the design view and THEN to the codebehind?

    My theory is that if you switch from html view to design view the page gets processed and your objects are added to the codebehind.



    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche
    "Boban Dragojlovic" <news@_N_O_S_P_AM_dragojlovic.org> wrote in message news:4BETa.51$...
    Actually, I type all my controls in HTML View because I don't like to work with the form designer. Yet in spite of that, VS often manages to "see" them and place them into the codebehind.

    "Steve C. Orr, MCSD" <> wrote in message news:...
    If you drag the control from the toolbox then it should always put the declaration in the code behind for you, assuming such an action is valid for that control. For instance, if you drag an HTML control instead of a webform and you don't mark it as a server control then the definition will not be in the code behind because it's not valid to be there.
    Also, if you type in the control definition into the HTML view of your page (instead of dragging it from the toolbar onto the designer view of your form) then I wouldn't expect VS.NET to automatically put the definition into the code behind for you.

    --
    I hope this helps,
    Steve C. Orr, MCSD
    http://Steve.Orr.net


    "Boban Dragojlovic" <news@_N_O_S_P_AM_dragojlovic.org> wrote in message news:g6ETa.47$...

    I create a new webform (I always use codebehind), and I insert some server-side controls into the form (the ASPX)

    Later, I switch to codeview, and I notice that some (sometimes all) of the controls I created have been automatically defined for me in the
    #Region " Web Form Designer Generated Code "
    section

    Later, when I add more controls this no longer happens.


    First, I'm wondering which of my actions causes it to no longer do this;

    and

    is there a command I can issue to force it to "review" the ASPX page and re-synchronize the codebehind form?
    Boban Dragojlovic, Jul 24, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marc Hoeppner

    Re: User Controls and CodeBehind

    Marc Hoeppner, Jul 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    365
  2. Nehal Shah
    Replies:
    6
    Views:
    731
    Jacob Yang [MSFT]
    Nov 14, 2003
  3. Guest
    Replies:
    1
    Views:
    748
    Guest
    Jun 29, 2004
  4. Antoine
    Replies:
    0
    Views:
    2,996
    Antoine
    Nov 8, 2004
  5. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    Dynamic, Run-Time Insertion of Controls

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Jul 1, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    384
    Steven Cheng[MSFT]
    Jul 5, 2006
Loading...

Share This Page