繁体   English   中英

Sharepoint .aspx页面

[英]Sharepoint .aspx page

有人告诉我,如果我不能在一天结束前解决这个问题,我将在一周结束时放手。 我需要帮助解决这个问题。 我正在尝试为共享点网站创建一个.aspx页。 这是我的代码...

<script  runat="server">
Sub submit(Source As Object, e As EventArgs)
   button1.Text="You clicked me!"
End Sub
</script>

<!DOCTYPE html>
<html>
<body>

<form runat="server">
<asp:Button id="button1" Text="Click me!" runat="server" OnClick="submit" />
</form>

</body>
</html>

每次加载页面时,我都会不断收到错误消息。 我把这段代码从互联网上撕下来,当我加载页面时说:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Parser Error 
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: Code blocks are not allowed in this file.

Source Error: 

Line 3:     button1.Text="You clicked me!"
Line 4:  End Sub
Line 5:  </script>
Line 6:  
Line 7:  <!DOCTYPE html>

请帮我。 为什么收到此消息?

默认情况下,SharePoint不允许.aspx文件中的内联代码。 如果要执行此操作,则需要在web.config中更改该设置,但不建议这样做。 请参阅评论中张贴的@Mark链接。

或者,您可以创建一个Webpart,然后将其添加到页面中。 请参阅本文以获取有关如何执行此操作的更多帮助。

您可以通过在web.config文件中添加以下行来允许在共享点页面内添加代码

<PageParserPaths>    
  <PageParserPath VirtualPath="/pages/test.aspx" CompilationMode="Always" AllowServerSideScript="true" />    
</PageParserPaths>

其中“ /pages/test.aspx”是页面的路径,或者您可以将其添加为“ / _catalogs / masterpage / *”例如添加所有母版页文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM