473,799 Members | 3,185 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1366
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\ItemTempla tesCache\Web\CS harp\1033\WebFo rm.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.gm ail.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\ItemTempla tesCache\Web\CS ha*rp\1033\WebF orm.zip

Update the file CodeBeside.cs

--
Happy Hacking,
Gaurav Vaish |http://dwt.sourceforge .nethttp://blogs.mastergau rav.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******** *************** ***********@j22 g2000hsf.google groups.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******** *************** ***********@i76 g2000hsf.google groups.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.gm ail.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\ItemTempla tesCache\Web\CS ha*rp\1033\WebF orm.zip

Update the file CodeBeside.cs

--
Happy Hacking,
Gaurav Vaish
|http://dwt.sourceforge .nethttp://blogs.mastergau rav.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.netNoS pamMwrote in
message news:uO******** ******@TK2MSFTN GP05.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******** *************** ***********@j22 g2000hsf.google groups.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="{afhad fhadgashgjwsagg asgh34}" ID="3062"/>

To this:

<Name Package="{afhad fhadgashgjwsagg asgh34}" 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.netNoS pamMwrote:
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.s paces.live.com/lists/feed.rss

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

*************** *************** **************
| Think outside the box! * * * * * * * * * * * * * * * |
*************** *************** **************
"Cowboy (Gregory A. Beamer)" <NoSpamMgbwo... @comcast.netNoS pamMwrote in
messagenews:uO* *************@T K2MSFTNGP05.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******** *************** ***********@j22 g2000hsf.google groups.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
10837
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 which has to parameters passed to it from another Web page Parameter # 1 dbid and Parameter # 2 reportid. I know that I can access the values of the parameters from the code behind .aspx.cs using Request.QueryString so
0
1910
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 control. In a default.aspx page <SkinExample:Hello id="HelloControl" SkinName="red" runat="server" /> i can pass the value, it works fine, but from the dropdownlist in a codebehind page i can't pass the value. Could some one help me out with...
3
1589
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 understand how to best use codebehind to do what I want to achieve. Basically, so far I have a codebehind file for one page which works as I wanted but I want other pages to share that codebehind file. That's no problem except I want each one to...
2
1691
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 properties via the Page_Load subroutine in a code-behind file. Can someone please tell me the proper procedure for declaring the new custom control in the code-behind file? I have supplied all of the code associated with this very basic example...
2
1126
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 every minor change (e.g. making the change, compiling, uploading the dll to the production server, opening vnc and running gacutil, etc...). I have 2 questions associated with the problem, and depending on the answers, we'll decide what's best:
3
6295
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 custom controls to dll for them to work. But I wonder, if I don't compile to dll, can I still dynamically add that custom control? If so how? Below is how I've tried (and failed). At top of the page...
4
1447
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 with the error the namespace can't be found. I've really got no idea what I'm doing, I'm coding in C# and essentially using notepad, and trying to get my code behind file to use the class in my custom namespace.
5
1809
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 config file. Once I do that, how do I differentiate between different pages with the abcd extension, and write specific code for each page? (And keep that code with the page, similar to codebehind.?) Thanks, Bryan
0
803
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 itself. <%@ Page Language="C#" %> <script runat="server"> </script> <html>
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9538
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10470
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10214
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9067
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7561
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2935
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.