开发者

Which is the better approach in custom pages?

开发者 https://www.devze.com 2022-12-24 05:18 出处:网络
I want to create a custom new item page for sharepoint but there are two approached that I can use and I want to share your experience in determining which is better.

I want to create a custom new item page for sharepoint but there are two approached that I

can use and I want to share your experience in determining which is better.

The first: is to create a page in a library then create a C# library project to handle

the events of the controls on the page.

The second: is to define a feature of the content type of my list and specify the new

item form to be my custom form, then create a website containing the custom form and put

this site at the layouts folder.

for me the first approach is fine but the problem is that a user may access the default

sharepoint new item form which I don't want to happen.

but I don't like the idea of placing the form in a 开发者_运维问答library on the site.

so which is better in your opinion ?

thanks


i suggest you to go with your second approach ...

Create a completely new feature that allows you add your functionalty of page creation and any customization realted to that and deploy this one to the 12 hive features folder as a new feature and every time you want have such a page created you can you this template and create the page...


Well, frankly, I'm confused by both of your suggestions. I don't see how the first one would ever work.

And the second one; you don't "put sites in the layouts folder".

Here's what I would suggest you to do:

  1. Download and install the WSS Extensions for Visual Studio.
  2. Create a List Definition using these new templates.
  3. Copy the NewForm.aspx from the 12 hive and Customize it.
  4. Download and install the WSP Builder from Codeplex.com
  5. Add your custom list definitions and files to a new Feature project in WSP Builder.
  6. Package the Feature up to a .wsp using WSP Builder and you are good to go.

Your custom page(s) should be placed in your custom folders in my opinion.
Hope this helps.


Your concern in the first approach is that people will still be able to access the default form. If you are not opposed to using a custom control template for a content type definition, I recommend creating a very simple redirect control template and assigning it to the content type's "New Form". Such a control template need only contain one custom control, which has an OnInit or OnLoad method that contains little more than a Page.Response.Redirect call. Make that redirect point to the page you create in your first approach, and now whenever anyone tries to access the default new form for that content type, they will instead be directed to your custom page with all of your custom code. It is perhaps a bit of a hack, but it's definitely functional.

0

精彩评论

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

关注公众号