开发者

Unable to open code behind file in Visual Studio

In an ASP.NET web application using C#, when we double click on design it will go to code behind page (cs file), but problem here is, when we double click on design its going to script of sou开发者_C百科rce file. Why it is happening?


Is there actually a matching .aspx.cs file for the page? Sounds to me like the project you're working on is a Web Site rather than an WebApplication, and the page was created without checking the "Place code in separate file".

Is there anything else in the Script section of the .aspx page? It's possible that once there is code in there, double clicking on the designer will open that instead of the code behind.

Personally, I always avoid double clicking to open the source in-case I accidentally click on a control and create a click event, rather than just opening the code - I prefer to either:

  1. Right-click on the designer and "View source"
  2. From Solution Explorer open the .cs file directly.


I had the same problem, and when I survey my code, I found the problem in the @page tag where codefile was not correct.


I had this problem after importing an .ascx file into an existing project. I had to import the .ascx.cs and .ascx.designer.cs files on my own too, since otherwise I could not use the "Show Code (F7)" feature of Visual Studio. It would show that the files are all there, but the icon in Visual Studio was a bit grayish.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜