在沙盒解决方案中拥有自定义 .aspx 页面的代码隐藏
我正在使用沙箱解决方案。我的解决方案中有一个 .aspx 页面,并且我在该页面中放置了一个按钮标签,我需要为该按钮编写服务器端代码。但它显示“此页面不允许事件处理程序‘OnClick’。” 。沙箱解决方案中是否不允许代码隐藏。或者间接地我如何为该按钮编写我的 C# 代码。
我知道我们可以通过创建一个 Web 部件并使用“WebPartPages:SPUserCodeWebPart”标签在页面中显示该 Web 部件来实现。但我想确认我们是否可以以某种方式为 ASP 页面编写代码隐藏。
I am having working with sandbox solution. i have one .aspx page in my solution and i have placed one button tag in that page, i need to write server side code for that button. But it is showing "The event handler 'OnClick' is not allowed in this page." . Does codebehind is not allowed in sandbox solution. Or indirectly how can i write my c# code for that button.
I know we can do it by creating one webpart and show that webpart in page using "WebPartPages:SPUserCodeWebPart" tag . But i want to confirm whether we can write codebehind for an asp page in some way or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果不更改 web.config 文件(在这种情况下不建议这样做),则在布局文件夹(无法使用沙盒解决方案部署到该文件夹)之外不支持内联代码或代码隐藏文件。
但是,您应该能够创建一个类,然后将继承属性设置为指向该类,而不是在代码隐藏文件中引用该类。
Without changing the web.config file (which would not be recommended in this case), inline code or code behind files are not supported outside of the layouts folder (which you cannot deploy to with a sandbox solution).
However, you should be able to create a class and then set the inherits attribute to point to that class, instead of referring to the class in a code behind file.