c# - How can I make a property declarable as any inheriting type in ASP.NET markup? -
I have seen various controls in ASP.NET with the "archive" of the object, which you define for markup Can be used. For example:
& lt; Asp: UpdatePanel ID = "UpdatePanel1" runat = "server" & gt; & Lt; Trigger & gt; & Lt; Asp: PostBackTrigger ControlID = "MyButton" /> & Lt; / Trigger & gt; ... & lt; / Asp: UpdatePanel & gt;
In the above example, you can add triggers to any number, and they can be any type that increases UpdatePanelTrigger. I want to do something similar, but with only one item instead of the collection:
& Lt; / Application: PortalLink & gt; - or - & lt; App: Portlink ID = "Drink Lounge" & gt; & Lt; Content & gt; I'm thirsty & lt; / Content & gt; & Lt; Request & gt; & Lt; Portal: See ProductsComplete ProductsCategory = "Drink" /> & Lt; / Request & gt; & Lt; / Application: PortalLink & gt;
The idea is that the request can be given a single object of any type that receives a particular interface or class. Is there any way to do this?
Update
To clarify, I want a portal link to be able to accept anything that is a sub-class of the request, which is the parameter which is a specific page For example:
Public class administrator menu request: there is no parameter for request {} / main menu page Public class ViewProductsRequest: request {public string ProductCategory {get; Set;} public bool? ShowOutOfStock {get; Set}}}
and markup:
& Lt; / Application: PortalLink & gt;
So far I have come to know that I can either control the request myself, or accept archive of portal link requests (but no one Is not restricted to single request). If I control the request, then it breaks the one-purpose rule: the request represents both a request on the server side and a link on the client side. Also, since I want to make a request for "Page" because it pollutes the intellisense list in most circumstances. If I accept portal links to the collection of requests, then I can use the first item in the list and I can ignore the rest. It works, but it should be good to be able to implement that each portal should have one (and only one) value. To be able to say this, it will be easier to create or get started in the Codebehind:
((View Products Producer's Resist Food Food Link). ShowoffOffStock = OSCcockbox. Checked;
This is something I can do to duplicate with extra qualities, but I was hoping for something just a tad more elegant.
Take a look here:
Edit: For a "simple" property, you do not need anything other than to make a public property in your control class, but you use it later as a tag attribute (and as an internal asset) Must have:
Public partial class UCSample: UserControl {public string MyCustomProperty { Received; Set; } Secure Zero Page_load (Object Sender, EventErgus E) {Response. White (this microgram property); }} & Lt;% @page language = "c #"%> & Lt;% @ Register src = "UCSample.ascx" Tag name = "UCSample" tagprofix = "uc1"%> & Lt; Uc1: UCSample id = "UCSample1" run = "server" MyCustomProperty = "stack overflow" />
Comments
Post a Comment