473,385 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Custom CodeBehind File?

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
7 1346
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Joe Bloggs | last post by:
Does anyone know if its possible to pass parameters or the values of Request.QueryString from a web page to a custom control class? I'm using a C# Web Application. For Example I have Web Page1...
0
by: adam | last post by:
i have custom user control and i'm trying to pass values to custom user control......I need help it seems to me i cannot pass the value to user control from dropdownlist. I have property in a...
3
by: nevets2001uk | last post by:
Hi. I've just started my second ASP.NET (VB) app and I'm using codebehind this time. I'm not using visual studio but am instead coding it all in notepad (HTML, ASP.NET and CSS) I'm trying to...
2
by: Technical Support | last post by:
Good afternoon, I created a custom control, compiled it into a DLL, and added it to the BIN directory. I placed an instance of the control in a webForm and am trying to programatically change its...
2
by: MAG | last post by:
Hi, After using an assembly compiled into a DLL and added to the assembly cache for several months, we decided that it was too much trouble to maintain because of all the steps involved with...
3
by: David Freeman | last post by:
Hi There! I'm having trouble dynamically adding custom controls. My custom controls does not use code-behind but only <script /> block for programming. So as a result, I don't need to compile my...
4
by: Matt Jensen | last post by:
Howdy Relatively new to .NET, I'm trying to create custom a namespace for use in creating some utility classes, which I seem to have done OK, however, I'm having a problem trying to use the class...
5
by: bryan | last post by:
If I understand correctly, I can write a custom handler for a given extension (say .abcd files) by writing a class that implements the IHttpHandler interface and then registering it in my web...
0
by: Nathan Baulch | last post by:
How do I apply a custom attribute to a page that doesn't have a CodeBehind file? I've tried the following but my attribute ends up on the default public constructor rather than the Page class...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.