Generate code for Web Form with code behind

When I want to add a new item to my project (for instance, a class), I usually use Generate File from Template (Ctrl+Alt+Ins).

I've recently started developing web applications. When I select "Web form without master page" (of with master page, it doesn't matter), R# generates an aspx page without a code behind file. That's not what I'd expect. If I let Visual Studio do it (Ctrl+Shift+A, select "Web Form"), it generates a page with a code behind file.

Can I get ReSharper to create an aspx page with code behind? Of isn't the Generate File from Template option intended for this?

5 comments
Comment actions Permalink

Hello Dick,

Please take a look at this bug-report: http://youtrack.jetbrains.net/issue/RSRP-143893.
Let me know if you feel that it needs to be reopened. Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

When I want to add a new item to my project (for instance, a class), I
usually use Generate File from Template (CtrlAltIns).

I've recently started developing web applications. When I select "Web
form without master page" (of with master page, it doesn't matter), R#
generates an aspx page without a code behind file. That's not what
I'd expect. If I let Visual Studio do it (CtrlShiftA, select "Web
Form"), it generates a page with a code behind file.

Can I get ReSharper to create an aspx page with code behind? Of
isn't the Generate File from Template option intended for this?

---
Original message URL:
http://devnet.jetbrains.net/message/5323021#5323021



0
Comment actions Permalink

Hi Andrey,

I'm not sure. First of all, I don't know for sure if what I expect is how it is intended to work. Second of all, tha bug-report you refer to is closed as being fixed, but I don't see what has been fixed about it. If I read the comment, it is actually closed because it works as designed.

The bug-report also mentions that you can easily create a code behind file "by CA at Page directive". I don't know what CA means.

But I've figured it out. After adding the web form, I place the cursor on the <%@ Page> directive, press Alt-Enter to display the Actions List, and choose Add CodeBehind file.
AddCodeBehindPage.png

0
Comment actions Permalink

Hello Dick,

CA means Context Action and it looks like you've figured it out :) Yes, initially
this feature was designed to insert only a single file at once and at the
moment it works as designed. You can put a vote on that request and if it
gets enough votes we will consider re-designing that feature. Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hi Andrey,

I'm not sure. First of all, I don't know for sure if what I expect is
how it is intended to work. Second of all, tha bug-report you refer to
is closed as being fixed, but I don't see what has been fixed about
it. If I read the comment, it is actually closed because it works as
designed.

The bug-report also mentions that you can easily create a code behind
file "by CA at Page directive". I don't know what CA means.

But I've figured it out. After adding the web form, I place the cursor
on the <%@ Page> directive, press Alt-Enter to display the Actions
List, and choose Add CodeBehind file.
Image:AddCodeBehindPage.png
---
Original message URL:
http://devnet.jetbrains.net/message/5323519#5323519



0
Comment actions Permalink

Hi Andrey,

I'm not sure if this request should be reopened, or if a new request should be created.

I can create  a code behind file from the context action menu. However, this does not lead to the creation of a designer file (i.e. Default.aspx.designer.cs). Therefor, no properties will be created for the controls that are placed in the aspx file. Is there another option that I can use to create this file?

0
Comment actions Permalink

KickBack

The last problem I mentioned still exists (in R# 7.0). Using the CA "Add CodeBehind file" still only creates the codebehind file and no designer file. The code behind file will state it is a partial class, but it isn't, as there is no designer file containing the other part. If you have a control on the page (in the aspx file), no property will be created for it. Therefor, you can't access the control from your code behind.

Should this become a new bug report?

0

Please sign in to leave a comment.