I have created a User Control where I need the URL of another page on my site.
I have wrapped the control in a macro and added a parameter of type int called MemberResultPageUrl, which is also the name of the property in my usercontrol.
In my document I have created a property - memberResultPageURL - of type Content Pciker. My template looks like this:
In the code you've pasted in, the Macro appears to have set the property to 123? Which I'm guessing is the node id of the page. You can use the GetNiceUrl() function from the umbraco library to turn that into a URL.
a contentpicker, nodepicker ... etc give back the ID of the node that is selected.
Your macro recieves an ID, this will be passed to your user control. Depending on your needs you can ask the url, document ... of the selected node by different api methods.
Here you will use the GetNiceUrl()function which requires the id of the document as a parameter.
The 123 is the id of the node and I use the GetNiceUrl in my UC to get the URL and it works fine. The problem is that I want a ContentPicker in my document to provide the value 123.
The way it is now it's hardcoded - I want to be able to change it using a ContentPicker-.
- Bert, you're describing exactly what I want but the problem is that the value doesn't get passed from the ContentPicker to the UC - but if I insert a hardcoded value in the template - 123 - it works fine.
Content Picker as parameter to .Net User control
Hi
I have created a User Control where I need the URL of another page on my site.
I have wrapped the control in a macro and added a parameter of type int called MemberResultPageUrl, which is also the name of the property in my usercontrol.
In my document I have created a property - memberResultPageURL - of type Content Pciker. My template looks like this:
<umbraco:Macro MemberResultPageUrl="[#memberResultPageURL]" Alias="msResultList" runat="server">
</umbraco:Macro>
If I call the page with the debug parameter - ?umbDebugShowTrace=true - setting the property is not listed
<umbraco:Macro MemberResultPageUrl="123" Alias="msResultList" runat="server">
</umbraco:Macro>
I get this
loadUserControl Usercontrol added with id 'MsResultList_3'
macro.loadControlProperties Property added 'MemberResultPageUrl' with value '123'
What am I doing wrong here?
/Paul S
In the code you've pasted in, the Macro appears to have set the property to 123? Which I'm guessing is the node id of the page. You can use the GetNiceUrl() function from the umbraco library to turn that into a URL.
a contentpicker, nodepicker ... etc give back the ID of the node that is selected.
Your macro recieves an ID, this will be passed to your user control. Depending on your needs you can ask the url, document ... of the selected node by different api methods.
Here you will use the GetNiceUrl()function which requires the id of the document as a parameter.
Hi Tim
The 123 is the id of the node and I use the GetNiceUrl in my UC to get the URL and it works fine. The problem is that I want a ContentPicker in my document to provide the value 123.
The way it is now it's hardcoded - I want to be able to change it using a ContentPicker-.
- Bert, you're describing exactly what I want but the problem is that the value doesn't get passed from the ContentPicker to the UC - but if I insert a hardcoded value in the template - 123 - it works fine.
Paul S
is working on a reply...