Color.Translator.FromHtml inside off @Html.DisplayFor Issue -Razor
-
I have some data from model , in which i getting some hex values .. now i need to translate this hex values to real color. I have try this way... @Html.DisplayFor(modelItem=>System.Drawing.ColorTranslator.FromHtml(item.color)) But this not working. item.Color is a value from database and it's like this #ffffff; Any suggestions ? Thanks for help in advance!
-
I have some data from model , in which i getting some hex values .. now i need to translate this hex values to real color. I have try this way... @Html.DisplayFor(modelItem=>System.Drawing.ColorTranslator.FromHtml(item.color)) But this not working. item.Color is a value from database and it's like this #ffffff; Any suggestions ? Thanks for help in advance!
try this
<span style="display: inline-block; width: 20px; height: 20px; background-color: @item.Color"></span>
it would display like this:
Help people,so poeple can help you.
-
I have some data from model , in which i getting some hex values .. now i need to translate this hex values to real color. I have try this way... @Html.DisplayFor(modelItem=>System.Drawing.ColorTranslator.FromHtml(item.color)) But this not working. item.Color is a value from database and it's like this #ffffff; Any suggestions ? Thanks for help in advance!
In GridView BackColor='<# System.Drawing.Color.FromName(Eval("item_color").ToString())%>'
-
I have some data from model , in which i getting some hex values .. now i need to translate this hex values to real color. I have try this way... @Html.DisplayFor(modelItem=>System.Drawing.ColorTranslator.FromHtml(item.color)) But this not working. item.Color is a value from database and it's like this #ffffff; Any suggestions ? Thanks for help in advance!
Alem.B wrote:
But this not working.
Define "not working". The only obvious problem with your code is the inconsistent naming in your lambda expression:
modelItem => System.Drawing.ColorTranslator.FromHtml(item.color)
This should either be
item => ...
or...FromHtml(modelItem.color)
. Also, is ititem.color
oritem.Color
? In C#, the case matters.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
try this
<span style="display: inline-block; width: 20px; height: 20px; background-color: @item.Color"></span>
it would display like this:
Help people,so poeple can help you.
-
Alem.B wrote:
But this not working.
Define "not working". The only obvious problem with your code is the inconsistent naming in your lambda expression:
modelItem => System.Drawing.ColorTranslator.FromHtml(item.color)
This should either be
item => ...
or...FromHtml(modelItem.color)
. Also, is ititem.color
oritem.Color
? In C#, the case matters.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Alem.B wrote:
But this not working.
Define "not working". The only obvious problem with your code is the inconsistent naming in your lambda expression:
modelItem => System.Drawing.ColorTranslator.FromHtml(item.color)
This should either be
item => ...
or...FromHtml(modelItem.color)
. Also, is ititem.color
oritem.Color
? In C#, the case matters.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
In GridView BackColor='<# System.Drawing.Color.FromName(Eval("item_color").ToString())%>'
-
The king of Persia :-D
Help people,so poeple can help you.