admin管理员组文章数量:1320882
I have a SPList in SharePoint that I want to edit the NewForm.aspx for. I want to add a few JavaScripts as WebParts to the form programmatically.
How do I do that?
Thanks for helping.
I have a SPList in SharePoint that I want to edit the NewForm.aspx for. I want to add a few JavaScripts as WebParts to the form programmatically.
How do I do that?
Thanks for helping.
Share Improve this question asked Apr 27, 2012 at 13:05 carruwcarruw 3595 gold badges10 silver badges22 bronze badges 2- 1 Well, I have my SPContentType and tried to use the "NewFormUrl" but I cannot find the newform.aspx on my server. I simply don't know where to look. – carruw Commented Apr 27, 2012 at 13:13
- @JamesMontagne: Seems like a fair question to me, the guy clearly is inexperienced. – Brian Scott Commented Apr 27, 2012 at 13:14
2 Answers
Reset to default 2Open the list in SharePoint designer in the "lists and libraries" section. In the list designer view you will see a list of forms associated with the list, there will generally be a "NewForm.aspx" form listed. Right click this and then select "Edit File in Advanced Mode" to expose the ASP .Net / HTML markup used for the form.
Now, add your custom block within the page markup. I'd generally remend that you find the asp:content element with id 'PlaceHolderMain'. Add your script as the first element immediately after the content placeholder element opens like:
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script type='text/javascript' language='javascript'>
$(document).ready(function(e) { alert('my custom script has loaded'); });
</script>
..
.. Existing markup
..
</asp:Content>
My example above assumes you have jQuery present in your masterpage to display the message after the form has fully loaded.
If you don't want to (or can't) use SharePoint Designer you can put
?ToolpaneView=2
on the end of the URL to open the View/Edit/new form in design mode in the browser.
http://blog.pentalogic/2010/07/how-to-edit-list-forms-sharepoint-2010/
本文标签: cAdd JavaScript to NewForm for SPList in SharePointStack Overflow
版权声明:本文标题:c# - Add JavaScript to NewForm for SPList in SharePoint - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742086567a2420015.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论