|
-
Nov 13th, 2002, 05:54 PM
#1
Thread Starter
New Member
Using a property to define layout in User Control
I've been searching across the web but can't find the result to something that I imagine is easy to do.
What I've got is a User Control with a property called Layout which can either Brief or Full. If Layout=Brief then I want it to display an ItemTemplate with a different table layout compared to the layout used if Layout=Full. Each template is signficantly different. However they need to access the same data so I thought it would surely make sense to use the one User Control.
So basically, can I create 2 different templates and call the appropriate one depending on the property value.
Thanks!
-
Nov 15th, 2002, 03:22 PM
#2
Hyperactive Member
Yes you can do this in the code behind of the user control. First declare a public string called Layout outside of any prodecure (right after class declaration is best):-
Public String Layout
Then when placing your user control set this property:-
<udd:MyUserControl id="blah" runat="server" Layout="Brief" />
Now in the Load event of the control you can check it:-
If Layout="brief" then
'brief implementation
else
'Full Implementation
End If
-
Nov 17th, 2002, 03:32 PM
#3
Thread Starter
New Member
Thanks for your reply. That's what I did too. I've used the LoadTemplate method to load up the appropriate template depending on what Layout value was passed in through the property.
Cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|