Hope we all had good weekend, I'm looking for some help with the following;
I have a policies page which works great if I just upload an attachment using the document picker, but what I'm looking to do now is give the user the option to either add an attachment or a link in the page and then displaying that option depending which field is filled in.
My issue is if I add a document under documentPicker it shows correct, but what I want to do is if there is no documentPicker, but I want the field "linkPicker" to display. But I get nothing being outputted?
Mind you; this is not a solid solution because a external link without http(s):// wont work and the name of the link needs to be edited in a separate input if you want it to be something else than the url.
I always use Multi url picker for managing internal and external links. Works like a charm!
displaying document field with else command
Morning all,
Hope we all had good weekend, I'm looking for some help with the following;
I have a policies page which works great if I just upload an attachment using the document picker, but what I'm looking to do now is give the user the option to either add an attachment or a link in the page and then displaying that option depending which field is filled in.
Here is my code;
My issue is if I add a document under documentPicker it shows correct, but what I want to do is if there is no documentPicker, but I want the field "linkPicker" to display. But I get nothing being outputted?
Thanks in advance, Matt
Hi Matt,
First of all I would rewrite your code as follows for readability:
What datatype did you use for the linkpicker?
Hello,
I'm used just a text box then validate it as a URL.
Is this correct?
Thanks
Is the link internal or external?
If the link is internal than I would use a content picker. If you use a content picker you can use the code you've shared.
If the link is external you can use the textbox but the else if should look like this:
Mind you; this is not a solid solution because a external link without
http(s)://
wont work and the name of the link needs to be edited in a separate input if you want it to be something else than the url.I always use Multi url picker for managing internal and external links. Works like a charm!
Hello,
I tried your code but I got the following;
The best overloaded method match for 'string.IsNullOrEmpty(string)' has some invalid arguments
Are you able to point me in the right direction.
Thanks in advance, Matt
Sorry, you have to change this line to:
must be:
Works a dream, thank you very much!
No problem.
What you tried to do is cast a string to IPublishedContent. That's not going to work.
Keep in mind my advice to look into multi url picker to prevent errors with bad content.
is working on a reply...