I'm reading a book that recommends clicking a check box that says "Place code in separate file" when adding a new Web Form to an existing ASP.NET project. The book is using Visual Studio 2005 and there is a check box for "Place code in separate file" when you open the "Add New Item" dialog.
I am using Visual Studio 2008 and I do not see the "Place code in separate file" checkbox when I try to add a new item. Is there something I need to do to enable this? Was this functionality no longer possible/important in VS 2008?
I believe in 2008 it is the default behaviour.
If you add an apsx file it will add the aspx.cs without any interaction from yourself.
This option depends on the type of project you are building:
If you are building a Web Site (File | New > Web Site, contains an /App_Code folder, the code is not compiled into a .dll in the /bin folder) then you will have the option (ticked by default in VS2008/2010) to "Place code in separate file", and also "Select master page".
If you are building a Web Application (File | New > Project, doesn't have an /App_Code folder, compiles all .cs/.vb files into one .dll in the /bin folder) then you don't have the option to not create a separate code file, and when you add a new item it's either a "Web Form" or a "Web Form using Master Page".
VS 2008 adds a code behind file by default.
Related
I have an old ASP.NET website. need to exclude folder from publishing , but keep that folder on server.
Folder: img contains many images marked as "content"
Publish method: FTP
In setting I have "Delete all existing file prior to publish" UNCHECKED, yet files are still being when publish.
For Visual Studio go to the Solution Explorer, right-click on the file you do not want to copy and then click on properties. Set the "Copy to Output Directory" to "Do not copy."
I'm facing out a strange problem while using ASP.NET MVC 4.
I have 2 "Web Site" projects:
The first named "MyWebSite"
The second named "MyWebSite.Support"
I need to include the scripts under MyWebSite into MyWebSite.Support, so i thought to create a bundle in MyWebSite.Support and to reference that directory (MyWebSite/Scripts) inside that bundle by using "IncludeDirectory"
The problem is that i didn't found a way to correctly do that. It simply doesn't work because the starting path for the IncludeDirectory should be "~", which is the project virtual root path.
PS: If you have another solutions they are welcome!.
I don't even know if it's a good solution (i usually am not a everything_related_microsoft developer)
You could add the scripts as a link to the other project. This will assure you that they are copied when you deploy and you can use them in bundles. To do that, right-click on your scripts folder and select "Add existing item". In the dialog box select the files you want to add. Instead of clicking "Add Item", click on the little arrow next to it and select "Add as a link".
This will not actually copy the files, but include them as a linked file.
This has several advantages:
Files are shared between projects at Design time
You only need to share the files you want, not everything
You don't need any IIS configuration
You can easily edit the same file from each project (without copying it)
Is typescript supported on web forms?
I have an existing asp.net 4.5 web forms project where typescript does not seem to be working.
I cannot create a new file, but even if I rename an existing to .ts it does not seem to be working. No build, no intellisense, nothing!
Found the answers to my problems:
I was trying to find "Typescript file" in Web folder of the "Add New Item" dialog, although it is in the "Visual C#" folder ..... Why?
Unless you have a .ts file created with "Add New Item" in your project, the option "TypeScriptCompile" on the "Build Action" of the file properties is not available and it raises an exception. After the first file is created, then you find this option and can manually set it to a .ts file.
The option "Typescript file" is not available in the "Add File" options unless you have a .ts file created with "Add New Item" in your project and you are in a "Scripts" folder (if you name differently the folder where you want to add this file, this option wont be available). Of course you can add a .ts file from "Add New Item".
You cannot easily create a ts file by your own, you must use "New Typescript file" from menu. That is because: A) The code page of the file must not be Unicode (I was trying to figure out that problem for many hours). if you try to compile a unicode .ts file with tsc, nothing happens!! After I saved the .ts file as Greek(Windows) - in my case-, everything worked fine! B) The .csproj properties that must be set for each file to work correctly are quite complex. (I was trying to create a .ts file starting from a .js file and renaming afterwards.... and then playing with .csproj)
I just created a new Web Application using web forms (empty project).
I found I have to add the Target to my project file...
<Target Name="BeforeBuild">
<Exec Command=""$(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\tsc" #(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
</Target>
You need to right-click and select "Unload project", then right-click and select "Edit". This block can go right at the end, just before the </Project> tag.
I didn't have any problems adding a TypeScript file in Visual Studio 2012.
Whenever I update a small part of my website I have to upload whole website again.
If i upload only edited part it throw me exception.
The way I upload my website:
For example if I have 4 pages (home, register, about me, contact me) and if I update home.aspx, I publish whole website in a local address, and then I compress it with zip format and upload it manually.
Is it possible to publish only updated part?
It is not possible to publish only a part of website, but what you can do is to choose Single-File Assembly build option ,by this you can get single assembly for your page.so intead of updating whole application you can update only the pages you change
read more
What I always do when publish ASP.Net Webform project, I complate it with two steps. Maybe this way suitable for you.
When you use publishing tool on visual studio by selecting Build menu -> Publish, you can choose "File System" as "Publish Method", type your "Target Location", and select "Replace matching files with local copies". It mean the project will publish modified files only.
After publishing have done, Open defined "Target Location" using windows explore and sort by "Modified Date" and just copy newer modified files for each directory recursively to your server.
If you build the website pages into dll. You can not published only the aspx. there are many other dll and compiled files in bin folder, we don't know which matches which aspx.
If you only edited the "view", i mean, the html and markup part of <%%> code, and no code behind (.aspx.cs) change, you can published only this aspx. But remember to set website as updatable in the publish dialog.
I suggest you to compile the aspx into one dll. according to #Buzz 's answer. Then, your aspx files would be only an empty file. All you need to do is upload only one dll to the bin folder.
in my application when i type sqlconnection it is not showing any intellisence, i added the namespace System.Data.Sqlclient not only sqlconnection even i am not getting Page calss can u help me.
actually i am sharing this application from my company server.
in our company previously there was .net 2.0 frame work when this project was developed(one year back).
yesterday our company installed 3.0 .net frame work is this any problem for previous project which are developed in 2.0 how can i go through this problem
You should check if your intellisense works at all first. You can try :-
1) Start your visual studio using the following :-
devenv.exe /resetskippkgs
2) Go to Tools > Option > Text Editor > All Languages . Make sure all the checkbox related to "Statement Completion" are "checked" (not just filled).
3) Close Visual Studio, delete the .suo (user option file) which is located at teh same directory as your solution file. Note that that file might be hidden. Open Visual Studio again and check for intellisense.
EDIT :- To see the hidden .suo file (or any other hidden files), follow below steps:-
1.Open My Computer.
2.From the Tools menu, choose Folder Options....
3.Click on the View tab in the Folder Options window.
4.In the Advanced settings: text area, locate the Hidden files and folders category.
Note: The Hidden files and folders category should be viewable at the bottom of the Advanced settings: text area without scrolling down. You'll see two options under the folder.
5.Choose the Show hidden files and folders radio button under the Hidden files and folders category.
6.Click OK at the bottom of the Folder Options window.