开发者

Setting a propery in an .ashx page

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>
    &开发者_高级运维lt;/asp:Panel>

Any ideas?


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.


This solved it for me:

        Loader="ConceptTreeLoader.ashx?ShowUnpublished=false" 

And in the ashx.cs page I request the parameter:

string ShowUnpublished = context.Request["ShowUnpublished"];

Which will equal to false.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜