|
 |
aspx thread: ASPX -> ASCX
Message #1 by "Benjamin Westrich" <matsu_turi_ben@h...> on Wed, 27 Feb 2002 18:48:41
|
|
I want to pass complex properties from an ASPX page into an ASCX control.
Anyone know how to do this?
Message #2 by "Colin Styles" <stylesie1@y...> on Wed, 27 Feb 2002 23:59:14
|
|
Here's one way.
Essentially, you set up a wrapper control with Properties to recieve the
values.
<CODE BEGINS>
<%@ Register TagPrefix="myC1" Namespace="MyNS" Assembly="myDLL" %>
<script language="VB" runat="server">
private sValue as string
Public ReadOnly Property Menu() as ControlInDLL
Get
Return myC1
End Get
End Property
public property Header() as string
Get
Return sValue
End Get
Set (ByVal Value As String)
sValue = Value
End Set
end property
</script>
<C1:ControlInDLL id="C1" runat="server"
ControlParameter=<%=sValue%>
></C1:ControlInDLL>
</CODE ENDS>
I know that using <%=%> tags is a NO-NO but there you are. A bit more
thought will solve that too.
I learned this from Jon Henning at Solution partners. Check out his
Heirarchical Menu Control and examples at http://www.solpart.com/ .
,-._|\ Colin Styles.
/ YGLU \ Yoogalu PTY LTD
\_,--._/ PHONE 612 9201 6408
v FAX 612 9201 6231
Message #3 by <zivf@m...> on Thu, 28 Feb 2002 10:28:05 +0200
|
|
Yes, all you need to do is to put an explicit declaration of a protected
variable - the same way it is automatically done with WebControls (like
textboxes, datagrids etc). the rest is doing stuff the ASP.NET way.
Try it. I was looking for this solution for a few months until I
understood how simple it is. Also, you can use this way custom
properties for these user controls, in a way a component can encapsulate
its functionality and other components can use it like a "black box"
with buttons and switches.
Have fun!
Ziv.
-----Original Message-----
From: Benjamin Westrich [mailto:matsu_turi_ben@h...]
Sent: Wednesday, February 27, 2002 8:49 PM
To: ASP+
Subject: [aspx] ASPX -> ASCX
I want to pass complex properties from an ASPX page into an ASCX
control.
Anyone know how to do this?
|
|
 |