There is no Default.aspx.cs file into my webapplications project - c#

Before telling you anything i'd like to clear, I'm a completely beginner in ASP.NET. In fact, I started learning today ASP.NET.
So, I'm making an event that would bind my code with C# files. Well I'm good in C#.
But the problem is as I find into projects, there is no Default or any aspx.cs files here. Can you please help? Where can I find it?
This tutorial says that to bind events, you need to write code in .cs files.
Here is my how my project is setup:

I think you have choosen a wrong project type while creating your project.For your purpose you need to do following
File>New>Project
On the left panel Go Visual C# > Web
Select ASP.NET Web Forms Application
Looking at your screenshot it seems you selected "ASP.NET Empty Web Application".You can add files to this as well but since you are a beginner its better to follow above steps.

Related

ASP.NET Web Application Project only shows VB options, not C#

I'm working on a project and I'm fairly new to ASP (not to C#).
We have a solution for a whole web application consisting of several projects and I want to add a couple of ASP WebForms to one of the projects. However, when I right click on the folder of the project and select Add element, it only shows me VB options.
But if I try to add other project to the solution, then all the other options are displayed.
The project in which I'm trying to add new Web Forms is entirely written in C#, so I don't know well what's happening back there. I cannot stop thinking it might a dumb mistake I'm making.
I'm working under Visual Studio 2017 and .NET Framework 4.7.2. It is there some kind of requirement I'm missing?
Thanks in advance for your time and sorry if it's something simpler, but I really don't know what's going on here.
As noted, this looks like that one application was created as a vb.net application.
You can freely consume say c# code (assemblies) in a vb.net project. And of course you can do the reverse.
However, for a given project created? You can't at the IDE level mix vb.net and c# code modules and general writing of code between c# and vb.net.
However, as in your example, you can certainly "include" multiple mixes of vb.net and c# projects into one same project. However, each part and section will still be limited to the chosen language used to build that application. So mixing is allowed at the project level - but not below that level.
So, it looks to be that project was created and developed with vb.net. You can't really change that unless you create a new project as c#, and then pull in all the forms, code etc. and re-factor the vb.net to c#.
So your practical project language choice is really limited to the project level. Multiple projects of different languages can be included overall, but each part will remain in its given language choice. The fact that you can do this in .net is amazing enough, but that language choice is really set in stone at the project level.
While you're figuring it out, if you need to press on and get some work done just copypaste another file that is already in the solution, and is of the type you require, then change its contents. This can usually be a time saver anyway, as the "new product" form isn't so hugely different from the "new user" form, just a different bunch of labels and textboxes..
There is nothing magical about the "add new item" dialog, it just adds files with pre filled templated content. For a cs class (for example) that's a file that basically has a detected namespace and the name you specified in the add dialog. You could even add a VB file of the type you want and then change the contents and name of the file to be right for C# - it would essentially be adding a couple of curly brackets and changing the case of Namespace and Class (and maybe changing Imports to using)
You cannot mix languages in the same assembly in .Net. Create another assembly you can put your C# code in there and use it in the VB.Net project.
Or use VB.Net it's not that bad.

Seeing different 'Button' codes from tutorials in VS 2013

I am trying to insert data to SQL server table with using C# ASP.NET. I watched a lot of tutorial video. If I create a button and double click on it, I see quite different codes from videos and other tutorials.
To make clear my problem, I added my and tutorials' code screenshots.
What shoud be the reason and how can I fix it?
This is from tutorials:
This is from my VS 2013
You used a Visual Basic template to create your project. Notice the source file in your screenshot is Default.aspx.vb. You'll need to create the project using the C# template.
Edit: I changed the screenshot to New Web Site instead of New Project.

Get Html from Web page and create Setup project for Wpf Application (C#)

I'm trying to create a wpf application such as a movies library because i would like to manage and sort out my movies with a pretty interface.
I'd like to create a library with all my movies getting information from the web, but i don't know how very well.
I thought to get the information from a web site, for example imdb, but i don't know if it's legally to capture html from page to get the nested information.
It's my first desktop application and I would also like to know if it is necessary to create a database within the project and then create a setup project with specified script for deploy it.
Sorry for the confusion but i would like to know too much things :)
Thanks a lot in advance.
The legality of web scraping is a grey area. See my question, "Legality of Web Scraping vs Normal Use" and the corresponding answers for some insight.
Even if the legality is not a problem, web scraping is a flimsy approach because the webpage structure may change without notice, making your application suddenly useless until you update it to the new format. You are much better off using some sort of web API (if the site providing the information offers it).
Whether you need a database or not depends entirely on what your application will be doing and how you design it - it's not something any of us can tell you.
Same goes for the setup project - in fact I wouldn't worry about that until you actually have a working application. Take it step by step and keep the scope within control.
Yes I did not think about api.
It's a great idea, maybe use "themoviedb".
But if i create an application based on it, that has to show all the movies that you have stored on your hdd and get , for example, the posters, the description and the ranking, i have to create a database according to you?
Thanks a lot.

Can I design a webPAGE with asp.net?

I work with c# for a while now for programming.And I know this may be a stupid question,but is it possible to design a webpage(not a web app)using c# in asp?and if yes,where can I begin from?
Yes
a basic HTML page with .aspx extension is also runnable with IIS
You might also want to look into razor and developing a front end with it.
See webmatrix from Microsoft and don't forget to look into https://developer.mozilla.org/en-US/

Where do I find MVC4 templates for download and how do I install them?

I am somewhat confused. Searched a bunch of ASP.NET related sites but could not find the answer. I must be missing some search word..
I want to find a gallery of MVC4 templates (free/cheap) and apply them to my project. Where do I do that from? I found one codeplex project (http://mvccontribgallery.codeplex.com/), but when I tried applying by copying, there were a bunch of errors (it uses something called SiteMaster, while my project seems to be using something called _layout).
I see a ton of references to people using them, applying them, but I must be missing something very fundamental since I can't even figure out how to find a list of downloadable templates.
What are the simple 1/2/3 steps for finding/getting/installing a template on my MVC4 project?
You should be looking for a suitable HTML template instead of an MVC specific template.
Once you have that, you will need to modify you master template (usually Views/Shared/_layout) to use the HTML and CSS contained within the template you have chosen.
For MVC3 or MVC4 you don't need to download any template. Just install MVC4 in your visual studio 2010 version on higher and then choose option create new project and that is that. See this below screen capture:
Microsoft will provide you the default MVC project architecture or in your term MVC template automatically when you choose any of above option marked in red box.
What do you mean by mvc4 templates? I'm assuming you mean "website template". With MVC you can use any html template, there's no specific template for MVC (that's why you're not finding any of it). You just find any website template and adapt it to mvc context (put css and images under "Content" folder and put html code in _layout and use it like masterpage), not hard to do at all. In fact, so easy to do after you get the idea that no one publish a specific adapted version :)
Follow these steps:
(note: if you have Asp.Net MVC 4, 3 won't install right (for me anyway), so uninstall and install in order).
http://tedgustaf.com/blog/2011/4/installing-asp-net-mvc3-on-visual-studio-2010-sp1/

Categories

Resources