2
I didn’t use the visual studio for a few years. Now I tried again and came across a problem.
I created a new web project in visual studio 2012, using the ASP.NET MVC 3 Web Application option. I asked for a new web form and put a Button and a Label on it. Hence the intention is, when clicking the button, to put any phrase on the Label.
To start, I clicked twice on the Button. Hence the visual studio has already created for me the function of the event Click on the button. Inside the event, I put the action:
Label1.Text = "Hello World";
It shows no errors, but when I run the project and click on the button, nothing happens. I never had this problem in previous versions of visual studio. In this version, and due to the MVC, there is something different I should do pro button perform the action when clicking on it???
You may not be running the latest build of your project. Try Click Build -> Clean Solution and try again.
– Tony
Thanks Tony, but still it wasn’t. Really weird. Then I’ll try another PC to see if the problem can be here. Finding out what it is, I put it on. Thank you.
– Paulo Luvisoto
I was also surprised that he put the C# code inside the same ASPX (In page) document, and in previous versions, he placed the C# code in a separate class (Code Behind). It would be "force" to store the C# code in a separate file?
– Paulo Luvisoto
OK. You could leave by downloading Visual Studio 2013 (stable) http://www.visualstudio.com/pt-br/downloads/download-visual-studio-vs.aspx. Or if you prefer Visual Studio Vnext (in development).
– Tony
I noticed that when I start a normal web application project (not MVC), then it works with Behind code, but when the project is MVC3.
– Paulo Luvisoto
Take advantage that you are resuming with Visual Studio and use a newer version like 2013.
– Tony
Put in question the ASPX code and Code Behind
– Tony
Guys, I installed VS 2013. But now when I try to run the project, the message appears: The display in '~/Views/Home/Index.aspx' should derive from Viewpage, Viewpage<Tmodel>, Viewusercontrol or Viewusercontrol<Tmodel>. Any hint???
– Paulo Luvisoto
Starts a new project, already with the new template that comes with Visual Studio 2013.
– Tony
Now something occurred to me. I had VS 2012 before. But before installing 2013, I uninstalled 2012.
– Paulo Luvisoto
What happens is that MVC, as well as the internet itself, has evolved a lot and changed a lot throughout its versions. This is why it is recommended to use the latest version of Visual Studio and MVC.
– Tony
Create a new project in VS 2013 and compare with yours and see what has changed in each of the files.
– Tony