Can not set inline style based on model's value? - asp.net-mvc

I am working with MVC 4. I want to use model's value to set inline-style. But It didn't work?
style= "background-color:#item.CompanyColor"//It not work
style= "background-color:Black"//It work: background color is black now
And I can use this value to set color like that:
font color="#item.CompanyColor"//it work: font color changed
So, what is the problem here?

Use parenthesis to separate code with style attribute.
It should be like this :
style= "background-color: #(item.CompanyColor) "

You can also use Html.Raw html helper
style="background-color: #{Html.Raw(item.CompanyColor);}"

Related

Break line defaultvalue of textarea

I have textarea with defaultvalue like this:
<textarea>
One Two Three
</textarea>
How can i display field like this:
One
Two
Three
Assuming you're referring to the placeholder, this has been answered on here: Insert line break inside placeholder attribute of a textarea?
Note there's no simple way, just some hacks that may work in some browsers and not others like using &#10 where you want the line break.
<textarea placeholder="one
two">
</textarea>
Depending on what you're going for you could set the width or use something like col="5" to force each word to the next line, but that also affects the user input.
My solution here
I replace space character by <br/> tag
Solution:
Break with \r\n with default text area. It will work.
"One\r\nTwo\r\nThree\r\nFour"

Vaadin Create <div>simple text</div> with no styles or classes?

Is this possible? Do I need to create custom componant? I simple want to create a div that just hold text and be able to change the text programatically.
Thanks :)
To remove the v-label style name from your Label, you could say
label.setPrimaryStyleName("foobar");
It replaces the v-label style name with foobar.

How to set a CSS background-image with URL in Dart?

I'm trying to find a equivalent to jQuery.css() method
In my specific case, I want to set a background image for a canvas.
in jQuery, it would be:
$("#canvas").css("background-image", "url(./assets/gridPattern.png)");
It is possible to acess CSS properties via the style attribute in Element
query("#canvas").style.backgroundImage = "url(./assets/gridPattern.png)";

How do we remove the inline style of SmartGwt components?

say: When we create a TextAreaItem inline style such as margin, width height etc are set are created along with a style name... How can we get rid of it?
<textarea handlenativeevents="false" oninput="isc_TextAreaItem_1.$43g()" tabindex="1052" wrap="SOFT" spellcheck="true" autocomplete="OFF" style="margin:0px;WIDTH:140px;HEIGHT:94px;-moz-user-focus:normal;" cols="10" rows="10" class="textItem" $9a="$9b" $89="isc_TextAreaItem_1" id="isc_5" name="isc_TextAreaItem_0"></textarea>
U can achieve this by setting setShowTitle to false
EG : textAreaItem.setShowTitle(false);
FormItem.setTextBoxStyle(String)
FormItem.setCellStyle(String)

How to change the color of some text in textbox - Silverlight 3?

I have a usual TextBox. I know in order to change the color of some text I can use Run tag. But when I try to use it imperatively instead declaratively (because I need to do that dynamically) I have the text in TextBox like
AAA<Run...>Text to be changed in color</Run>
and sure nothing in color changes.
How can I change the color of some text in some program way?
Thanks
I'm fairly sure you have to use a RichTextBox for that, TextBox only works with plaintext.

Resources