I'm looking to control the html heading tag output through a custom drop-down datatype.
I'm having trouble though with the syntax outputting the html value in my partial.
I can get my dropdown h tag value returned, but cant get it to output the < & > brackets without an error. I also have a class invloved
Hi Dan, thanks for replying.
I'm looking to set a default value for each of the fields.
More specifically, i'm trying to pass a background image into a the style attribute.
If an image is selected, all is fine and its showing. Without an image I get an error.
Thanks Dan,
I seem to get the following yellow screen.
Exception Details: System.InvalidOperationException: The value of parameter 'id' must be either a string or an integer
Source Error:
Line 10:
Line 11:
Line 12: var image = Umbraco.TypedMedia(fieldset.GetValue("backgroundImage"));
Line 13:
Line 14: if (image != null && !String.IsNullOrEmpty(image.Url))
Sorry to pester you Dan, but changing line 12 gave me this error.
Thanks again for you help with this.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 10:
Line 11:
Line 12: var image = Umbraco.TypedMedia(fieldset.GetValue("backgroundImage").ToString());
Line 13:
Line 14:
Create Heading Level From Dropdown
Hi All, New to Razor.
I'm looking to control the html heading tag output through a custom drop-down datatype. I'm having trouble though with the syntax outputting the html value in my partial.
I can get my dropdown h tag value returned, but cant get it to output the < & > brackets without an error. I also have a class invloved
Any help would be grateful
Hi Martin,
Could you please post a little more of your code, especially you loop?
Jeavon
Hi Jeavon,
I'm using the Archetype package with the following view. I have a dropdown datatype for the value "headingLevel".
Thanks
Hi Martin,
Could you use string.Format() along with Html.Raw() to render your heading?
Thanks, Dan.
Interesting idea, I think Dan's suggestion looks spot on!
Thanks Guys, that worked great.
Hi guys, sorry to come back to this. How would I implement an if statement for each of the values?
Thanks
Hi Martin,
Assuming you want to use the 'headinglevel' property for your if statement, you could write something like the following:
Thanks, Dan.
Hi Dan, thanks for replying. I'm looking to set a default value for each of the fields.
More specifically, i'm trying to pass a background image into a the style attribute. If an image is selected, all is fine and its showing. Without an image I get an error.
Any help would be grateful.
Martin
Hi Martin,
You'll probably want to check if the background image is null and has an image first:
Thanks, Dan.
Thanks Dan, I seem to get the following yellow screen.
Hi Martin,
I'm guessing the return type of GetValue() is an object so try changing line 12 to:
Thanks, Dan.
Sorry to pester you Dan, but changing line 12 gave me this error.
Thanks again for you help with this.
ok, ive got it working. Thanks for your help Dan.
is working on a reply...