[英]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.