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

Custom CodeBehind File?

P: n/a
When I create a new aspx page, VS automatically creates the assocaited
codebehind file also. Is there a way to specifiy what goes in that
codebehind file by default? I mean, if I wanted to see a couple lines
reserved at the top for comments, every time a new codebehind file is
generated, can I do that? How hard is it to do?
Jul 22 '08 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hello Chris,

Not sure that you can inject into codebehind creation, but is comments the
only thing you need to do?!
What about creating template for your project?

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
CWhen I create a new aspx page, VS automatically creates the
Cassocaited codebehind file also. Is there a way to specifiy what goes
Cin that codebehind file by default? I mean, if I wanted to see a
Ccouple lines reserved at the top for comments, every time a new
Ccodebehind file is generated, can I do that? How hard is it to do?
C>
Jul 23 '08 #2

P: n/a
codebehind file by default? I mean, if I wanted to see a couple lines
reserved at the top for comments, every time a new codebehind file is
Very much.

Go to
<Visual-Studio-Installation-Folder>\Common7\IDE\ItemTemplatesCache\Web\CSharp\ 1033\WebForm.zip

Update the file CodeBeside.cs

--
Happy Hacking,
Gaurav Vaish | http://dwt.sourceforge.net
http://blogs.mastergaurav.com | http://eduzine.edujini-labs.com
--------------------------------


Jul 23 '08 #3

P: n/a
Thanks guys for the tips. I took the WebForm.zip and made a copy of
it, and changed the codebeside file the way I wanted it to look. It's
working great, but when I go to add a new item in my project
(ASP.NET), under custom templates, it still says 'Web Form'. Is there
any way to change the name? i.e., 'My Custom WebForm'. I'm guessing
it's somewhere in the TemplateData tag in the vstemplate file, but I'm
not sure where to go from there.

On Jul 23, 12:10*am, "Gaurav Vaish \(a.k.a. MasterGaurav\)"
<gaurav.nospam.va...@nospam.gmail.comwrote:
codebehind file by default? *I mean, if I wanted to see a couple lines
reserved at the top *for comments, every time a new codebehind file is

Very much.

Go to
<Visual-Studio-Installation-Folder>\Common7\IDE\ItemTemplatesCache\Web\CSha*rp \1033\WebForm.zip

Update the file CodeBeside.cs

--
Happy Hacking,
Gaurav Vaish |http://dwt.sourceforge.nethttp://blogs.mastergaurav.com|http://eduzine.edujini-labs.com
--------------------------------
Jul 23 '08 #4

P: n/a
Edit the templates. I have not done this with VS 2008 yet, so they may have
moved the templates (most likely into the user directories), but it was
under the Visual Studio directory (under Program Files) before. You simply
find the correct project and then edit the code behind template, which will
end in .language (.vb for VB and .cs for C#). Look at other templates for
tags to automagically fill in your own FUD.

If this is not enough customization, you can get the SDK and start creating
your own templates and wizards.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
"Chris" <co*****@gmail.comwrote in message
news:3a**********************************@j22g2000 hsf.googlegroups.com...
When I create a new aspx page, VS automatically creates the assocaited
codebehind file also. Is there a way to specifiy what goes in that
codebehind file by default? I mean, if I wanted to see a couple lines
reserved at the top for comments, every time a new codebehind file is
generated, can I do that? How hard is it to do?
Jul 23 '08 #5

P: n/a
Look at a few of them and you will see what tags are available to have it
automagically mark up the file with file name, class name, etc. I wish I had
a list of them to share, but I don't.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
"Chris" <co*****@gmail.comwrote in message
news:d9**********************************@i76g2000 hsf.googlegroups.com...
Thanks guys for the tips. I took the WebForm.zip and made a copy of
it, and changed the codebeside file the way I wanted it to look. It's
working great, but when I go to add a new item in my project
(ASP.NET), under custom templates, it still says 'Web Form'. Is there
any way to change the name? i.e., 'My Custom WebForm'. I'm guessing
it's somewhere in the TemplateData tag in the vstemplate file, but I'm
not sure where to go from there.

On Jul 23, 12:10 am, "Gaurav Vaish \(a.k.a. MasterGaurav\)"
<gaurav.nospam.va...@nospam.gmail.comwrote:
codebehind file by default? I mean, if I wanted to see a couple lines
reserved at the top for comments, every time a new codebehind file is

Very much.

Go to
<Visual-Studio-Installation-Folder>\Common7\IDE\ItemTemplatesCache\Web\CSha*rp \1033\WebForm.zip

Update the file CodeBeside.cs

--
Happy Hacking,
Gaurav Vaish
|http://dwt.sourceforge.nethttp://blogs.mastergaurav.com|http://eduzine.edujini-labs.com
--------------------------------
Jul 23 '08 #6

P: n/a
After hitting send, I got curious.

It is a bit more complex with Visual Studio 2008 (and I have not yet tested
this). The files are located at:

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\
64-bit
C:\Program Files (x86)\Microsoft Visual Studio
9.0\Common7\IDE\ItemTemplates\

They are organized by language and type. IN this release, all are held in
zip files. If I were doing this, I would back up the current files first and
then edit the files inside the zip and replace the zip on the drive. I doubt
there is a checksum, but if there is, it will fail (thus the backup).

If I get a chance to test, I will repost.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:uO**************@TK2MSFTNGP05.phx.gbl...
Edit the templates. I have not done this with VS 2008 yet, so they may
have moved the templates (most likely into the user directories), but it
was under the Visual Studio directory (under Program Files) before. You
simply find the correct project and then edit the code behind template,
which will end in .language (.vb for VB and .cs for C#). Look at other
templates for tags to automagically fill in your own FUD.

If this is not enough customization, you can get the SDK and start
creating your own templates and wizards.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
"Chris" <co*****@gmail.comwrote in message
news:3a**********************************@j22g2000 hsf.googlegroups.com...
>When I create a new aspx page, VS automatically creates the assocaited
codebehind file also. Is there a way to specifiy what goes in that
codebehind file by default? I mean, if I wanted to see a couple lines
reserved at the top for comments, every time a new codebehind file is
generated, can I do that? How hard is it to do?
Jul 23 '08 #7

P: n/a
I figured it out. In the vstemplate file, I changed this line:

<Name Package="{afhadfhadgashgjwsaggasgh34}" ID="3062"/>

To this:

<Name Package="{afhadfhadgashgjwsaggasgh34}" ID="3062">My test
template</Name>

And when I go to use it in my project, the name I designated shows
up. Working splendidly.

On Jul 23, 10:15*am, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamMwrote:
After hitting send, I got curious.

It is a bit more complex with Visual Studio 2008 (and I have not yet tested
this). The files are located at:

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\
64-bit
C:\Program Files (x86)\Microsoft Visual Studio
9.0\Common7\IDE\ItemTemplates\

They are organized by language and type. IN this release, all are held in
zip files. If I were doing this, I would back up the current files first and
then edit the files inside the zip and replace the zip on the drive. I doubt
there is a checksum, but if there is, it will fail (thus the backup).

If I get a chance to test, I will repost.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my bloghttp://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! * * * * * * * * * * * * * * * |
********************************************
"Cowboy (Gregory A. Beamer)" <NoSpamMgbwo...@comcast.netNoSpamMwrote in
messagenews:uO**************@TK2MSFTNGP05.phx.gbl. ..
Edit the templates. I have not done this with VS 2008 yet, so they may
have moved the templates (most likely into the user directories), but it
was under the Visual Studio directory (under Program Files) before. You
simply find the correct project and then edit the code behind template,
which will end in .language (.vb for VB and .cs for C#). Look at other
templates for tags to automagically fill in your own FUD.
If this is not enough customization, you can get the SDK and start
creating your own templates and wizards.
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss
or just read it:
http://gregorybeamer.spaces.live.com/
********************************************
| Think outside the box! * * * * * * * * * * * * * * * |
********************************************
"Chris" <coz1...@gmail.comwrote in message
news:3a**********************************@j22g2000 hsf.googlegroups.com....
When I create a new aspx page, VS automatically creates the assocaited
codebehind file also. *Is there a way to specifiy what goes in that
codebehind file by default? *I mean, if I wanted to see a couple lines
reserved at the top *for comments, every time a new codebehind file is
generated, can I do that? *How hard is it to do?
Jul 23 '08 #8

This discussion thread is closed

Replies have been disabled for this discussion.