By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,153 Members | 960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,153 IT Pros & Developers. It's quick & easy.

automatic insertion of controls on codebehind

P: n/a

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?

Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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" <St***@Orr.net> wrote in message news:OQ**************@TK2MSFTNGP11.phx.gbl...
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:g6******************@newssvr14.news.prodigy.c om...

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?

Nov 17 '05 #2

P: n/a
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:4B*****************@newssvr14.news.prodigy.co m...
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" <St***@Orr.net> wrote in message news:OQ**************@TK2MSFTNGP11.phx.gbl...
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:g6******************@newssvr14.news.prodigy.c om...

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?

Nov 17 '05 #3

P: n/a
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" <sj*****@aboutfortunate.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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:4B*****************@newssvr14.news.prodigy.co m...
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" <St***@Orr.net> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl...
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.
Nov 17 '05 #4

P: n/a

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" <sj*****@aboutfortunate.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...
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:4B*****************@newssvr14.news.prodigy.co m...
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" <St***@Orr.net> wrote in message news:OQ**************@TK2MSFTNGP11.phx.gbl...
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:g6******************@newssvr14.news.prodigy.c om...

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?

Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.