Search code examples
c#.netashx

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>
    </asp:Panel>

Any ideas?


Solution

  • 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.