在 .ashx 页面中设置属性
我有一个由几个页面使用的 .ashx 组件,并且由于要求,它需要具有 bool 属性,以便对使用该组件的其中一个页面采取不同的操作。
我通常会做类似 this 的事情适用于 .aspx 页面,对于 .ashx 页面执行完全相同的操作似乎不起作用。
我想要的是能够通过 .ascx 页面设置一个 bool 属性,该属性将反映在 .ashx 页面中。
这是当前不起作用的代码:
.ashx.cs 页面具有此属性:
public bool ShowUnpublishedConcepts
{
get; set;
}
我试图这样设置:
<asp:Panel ID="pnlConceptTree" runat="server">
<ExtExt:TreePane ID="treeConcepts"
Loader="ConceptTreeLoader.ashx"
ShowUnpublishedConcepts="True">
</ExtExt:TreePane>
</asp:Panel>
有什么想法吗?
I have an .ashx component that is used by a couple of pages, and because of a requirement it needs to have a bool-property in order to act differently for one of the pages that is using the component.
What I would normally do is something like this but that is for .aspx pages, and it doesn't seem to work to do exactly the same for an .ashx page.
What I want is to be able to set a bool property via the .ascx page that'll be reflected in the .ashx page.
This is the current code that is not working:
The .ashx.cs page has this property:
public bool ShowUnpublishedConcepts
{
get; set;
}
That I'm trying to set like this:
<asp:Panel ID="pnlConceptTree" runat="server">
<ExtExt:TreePane ID="treeConcepts"
Loader="ConceptTreeLoader.ashx"
ShowUnpublishedConcepts="True">
</ExtExt:TreePane>
</asp:Panel>
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ASHX 文件并不是真正的页面,而是服务器端代码,因此它们没有视图状态。您需要将这些值放入会话中以使它们持续存在。
ASHX files are not really pages but server side code so they have no view state. You'll need to put the values in session to have them persist.
这为我解决了这个问题:
在 ashx.cs 页面中,我请求参数:
这将等于 false。
This solved it for me:
And in the ashx.cs page I request the parameter:
Which will equal to false.