Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 582637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:42:29+00:00 2026-05-13T14:42:29+00:00

I’ve seen various controls in ASP.NET with "collections" of objects, which you can use

  • 0

I’ve seen various controls in ASP.NET with "collections" of objects, which you can use markup to define. For example:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <Triggers>
        <asp:PostBackTrigger ControlID="MyButton" />
    </Triggers>
...
</asp:UpdatePanel>

In the above example, you can add any number of triggers, and they can be of any type that extends UpdatePanelTrigger. I’d like to do something similar, but with only a single item instead of a collection:

<app:PortalLink ID="DrinkLink" Text="I am thirsty">
    <portal:ViewProductsRequest ProductCategory="Drinks" />
</app:PortalLink>
--or--
<app:PortalLink ID="DrinkLink">
    <Content>I am thirsty</Content>
    <Request>
        <portal:ViewProductsRequest ProductCategory="Drinks" />
    </Request>
</app:PortalLink>

The idea is that the Request could be given a single object of any type that inherits a particular interface or class. Is there any way to do this?

Update

To clarify, I want a PortalLink to be able to do accept anything that is a sub-class of a Request, which represents the parameters that a particular page accepts. For example:

public class AdminMenuRequest : Request
{} // No parameters for the main menu page.
public class ViewProductsRequest : Request
{
    public string ProductCategory {get;set;}
    public bool? ShowOutOfStock {get;set;}
}

And in markup:

<app:PortalLink runat="server" Text="I am an administrator">
    <portal:AdminMenuRequest />
</app:PortalLink>
<app:PortalLink runat="server" Text="I am thirsty">
    <portal:ViewProductsRequest ProductCategory="Drinks" />
</app:PortalLink>

So far I’ve figured out that I can either make the Requests controls unto themselves, or make PortalLinks accept a collection of requests (but not restricted to a single request). If I make the Requests controls, it sort of breaks the single-purpose rule: requests represent both a request on the server side and a link on the client side. Plus, since I want to have one request per "page", as it were, it would also end up polluting the intellisense list in most circumstances. If I make PortalLinks accept a collection of requests, then I can simply use the first item in the list and ignore the rest. That works, but it would be nice to be able to enforce that each PortalLink should have one (and only one) value in it. It would also be easier when creating or initializing links in the codebehind to be able to say:

((ViewProductsRequest)FoodOrDrinkLink.Request).ShowOutOfStock = OOSCheckBox.Checked;

This is something I can sort of fake with additional properties, but I was hoping for something just a tad more elegant.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:42:29+00:00Added an answer on May 13, 2026 at 2:42 pm

    Take a look here: Web Control Collection Property Example

    EDIT: For a “simple” property, you don’t need anything else than to create a public property into your control class, but you must to use it later as an tag attribute (and not as an inner property):

    public partial class UCSample : UserControl
    {
        public string MyCustomProperty { get; set; }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(this.MyCustomProperty);
        }
    }
    
    <%@ Page Language="C#"  %>
    <%@ Register src="UCSample.ascx" tagname="UCSample" tagprefix="uc1"%>
    
    <uc1:UCSample ID="UCSample1" runat="server" MyCustomProperty="StackOverflow" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
i got an object with contents of html markup in it, for example: string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.