SharePoint How to configure NewForm.aspx in a custom function?

I created my own list on a SharePoint site and created a Visual Studio 2008 project using the SharePoint Solution Generator. I can pack this as a function and install it. It works fine on my server.

After checking this, I was able to add a special main page to the function that was deployed in the _catalogs / masterpage folder. Here it is:

<Elements Id="2196306F-3F37-40b5-99CF-42E89B93888A" xmlns="http://schemas.microsoft.com/sharepoint/">
    <Module Name="DefaultMasterPage" Url="_catalogs/masterpage" RootWebOnly="FALSE">
      <File Url="gcbranding.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" />
    </Module>
</Elements>

Now that I have a custom homepage on my site, I would like this to be used to create new elements. But I do not want to install the wizard from SharePoint Designer.

Returning to the generated solution, it has NewForm.aspx, etc. with a list scheme. Like me...

  • Customize the form displayed for new items and redirect it to the thankyou.aspx page instead of displaying all list items?
  • Correctly set the URL of the main page?

I got lost at point 1. Do I need to create a custom website and embed it in NewForm.aspx?

At point 2, I made some progress, but ran into a problem. If I installed a wizard like this in my NewForm.aspx ...

 MasterPageFile="~/masterurl/gcmaster.master"

It will install OK, but when I get to the site, I get an error because ~ is not allowed in the url. If I use _catalogs / masterpage in the directive, it will not find the master, because the URL is relative. Only this code seems to work:

MasterPageFile="../../_catalogs/masterpage/gcmaster.master"

What is the best way to customize the master page file in SharePoint when deploying a custom feature / solution?

+3
5

Re Masterpage: , "~masterurl/gcmaster.master". "/" "~" "master".

Re NewForm: NewForm.aspx, Inherits . , , SharePoint.SharePoint.WebPartPages.WebPartPage .

+2

, , thankyou.aspx, ?

SIMPLEST " ", URL- . , ( http):

www.yoursite.com/Lists/Links/NewForm.aspx

:

www.yoursite.com/Lists/Links/NewForm.aspx?Source=www.yoursite.com/ThankYou.aspx 

"" NewForm, "".aspx.

, , SharePoint Designer .

+1

- NewForm.aspx SharePoint Designer, :

MasterPageFile = "~ masterurl/default.master"

to

MasterPageFile = "~ masterurl/custom.master"

, , , , NewForm.aspx , schema.xml .

, .

0

OnPreInit - :

this.MasterPageFile = SPContext.Current.Web.CustomMasterUrl;

( )

, :

this.MasterPageFile =  SPContext.Current.Web.MasterUrl;

,

0

.aspx, . WSS, , _catalogs/masterpage/gcmaster.master SharePoint Designer " " PowerShell (SharePoint script): http://sharepoint.microsoft.com/blogs/zach/Lists/Posts/Post.aspx?ID=7)

$web = Get-SPWeb("http://mysiteurl")
$web.CustomMasterUrl = "_catalogs/masterpage/gcmaster.master"
$web.Update()

@Page .aspx :

MasterPageFile="~/masterurl/custom.master"

, .aspx , "~/masterurl/custom.master", gcmaster.master.

Alternatively, you can skip all this, and for your .aspx page, just include the @Page directive, which looks like this:

MasterPageFile="~/site/_catalogs/masterpage/gcmaster.master"
0
source

Source: https://habr.com/ru/post/1704010/


All Articles