从code-背后设置页面异步模式为真 [英] Setting Page Async mode to true from Code-Behind

查看:117
本文介绍了从code-背后设置页面异步模式为真的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有可能我的code-隐藏文件设置页面指令的异步模式中。

Is it possible within my code-behind file to set the asynchronous mode of the page directive.

我没有直接修改方式<%@页%> 属性,并努力寻找一种方式,我的code-实现这个后面。

I have no way of directly modifying the <%@Page %> attribute and and struggling to find a way to implement this in my code-behind.

我试图在我的Page_Load方法中添加 Page.AsyncMode = TRUE ,但它返回以下错误:

I have tried in my Page_Load method to add Page.AsyncMode = true, but it returns the following error:

无法访问由于其保护级别

is inaccessible due to its protection level

有没有办法做到这一点?而不能直接修改母版页?

Is there any way to do this? Without being able to directly modify the master page?

推荐答案

没有,你不能改变一个页面的异步模式在code-后面。异步页实现了 IHttpAsyncHandler 接口,并没有办法改变.aspx文件后您的网页实现已经被编译ASP.NET接口和你的code正在运行。

No, you cannot change the asynchronous mode of a page in the code-behind. An asynchronous page implements the IHttpAsyncHandler interface, and there is no way to change the interfaces implemented by your page after the .aspx file has been compiled by ASP.NET and your code is running.

设置 Page.AsyncMode 属性不会改变异步模式。其目的是让网页上的控件知道在异步模式下的页面是否正在运行与否,因此与物业篡改可能会导致控制失灵。

Setting the Page.AsyncMode property will not change the asynchronous mode. Its purpose is to let controls on the page know whether the page is running in asynchronous mode or not, so tampering with the property may cause controls to malfunction.

这篇关于从code-背后设置页面异步模式为真的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆