Vulnerability in EPiServer.Forms
I'm just starting developing using CMS 5 and I want to add a custom property to a Label:
<asp:Label ID="myId" runat="server" Text='<%= CurrentPage["myproperty"] %>' ></asp:Label>
If this is possible, could you please tell me what I'm doing wrong in the code above!?
<asp:Label ID="myId" runat="server" Text='<%# CurrentPage["myproperty"] %>' ></asp:Label>
Thanks for your fast replies!
It works beautifully but I now got a followup question:
I now have a page that looks like this:
<EPiServer:Property PropertyName="myproperty" ID="myId2" runat="server" />
When I browse the page, rightclick and choose Edit (Ändra) I'm only able to edit the value of myId2. Is there a workaround for this?
No. Only EPiServer:property supports on page edit.
Is there a reason as to why couldn't use episerver:property for both properties?
A workaround to this problem is to use
as you wrote in your post.
And you can read more about EPiServer web controls and dope in the document below.
I have created a usercontrol with attributes that I want to set. So it looks like this:
<uc2:MyUserControl ID="MyControl" runat="server" MyAttribute='<%# CurrentPage["myproperty"] %>' />
Is there a way to use the EPiServer:property to set the 'MyAttribute' on the usercontrol?
Not exactly - you cannot nest controls within attributes of another control. I'd have to ask exactly why you want to do this though - it's not a good idea really. An EPiServer property can contain pretty much anything and I don't think you'd really want it writing out information like HTML into an attribute?
If you have to do something like this then can you not just use an EPiServer property control so that you see it in edit mode but just hide it on the View Mode page? That way you can edit it in Edit Mode and use the data as well.
I suspect that a bit of re-architecting might give you a much cleaner and more powerful solution though.
Thanks again for all your input!
I really want to see if I can get this working before looking into re-architecting the site. I have come one step further:
1) I have now placed an <EPiServer:Property> inside the UserControl.2) On the aspx-page containing the UserControl I specify the propertyname for <EPiServer:Property> (inside the UserControl).
Doing this I am now able to edit the text by rightclicking and choose Edit. However, when I click Save the value never gets saved.
I got it all working now, thanks for your help!!!