简体   繁体   English

Sharepoint .aspx页面

[英]Sharepoint .aspx page

I have been told I will be let go at the end of the week if I can't figure this out by the end of the day. 有人告诉我,如果我不能在一天结束前解决这个问题,我将在一周结束时放手。 I need help in figuring out this issue. 我需要帮助解决这个问题。 I am trying to create a .aspx page for a sharepoint site. 我正在尝试为共享点网站创建一个.aspx页。 This is the code I have... 这是我的代码...

<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>

I keep getting error messages every time I load the page. 每次加载页面时,我都会不断收到错误消息。 I ripped this code off the internet and when I load the page it says: 我把这段代码从互联网上撕下来,当我加载页面时说:

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>

Please help me. 请帮我。 Why am I getting this message? 为什么收到此消息?

SharePoint doesn't allow inline code in .aspx files by default. 默认情况下,SharePoint不允许.aspx文件中的内联代码。 You'll need to change that setting in the web.config if you want to do this, but it's not recommended. 如果要执行此操作,则需要在web.config中更改该设置,但不建议这样做。 See the link @Mark posted in the comments. 请参阅评论中张贴的@Mark链接。

As an alternative, you can create a webpart, and add that to the page. 或者,您可以创建一个Webpart,然后将其添加到页面中。 See this article for more help on how to do this. 请参阅本文以获取有关如何执行此操作的更多帮助。

You can allow adding code inside sharepoint pages by adding below lines in the web.config file 您可以通过在web.config文件中添加以下行来允许在共享点页面内添加代码

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

Where "/pages/test.aspx" is the path of your page , or you can add it as "/_catalogs/masterpage/*" for example to add all masterpages files. 其中“ /pages/test.aspx”是页面的路径,或者您可以将其添加为“ / _catalogs / masterpage / *”例如添加所有母版页文件。

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

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