views:

95

answers:

2

Hi everyone,

I am creating a dynamic CSS file in ASP.NET MVC2, and I'm now encountering an exception. Everything was working fine, but all of a sudden I'm getting this error message for 2 variables:

The call is ambiguous between the following methods or properties: 'System.IO.TextWriter.Write(string, params object[])' and 'System.IO.TextWriter.Write(char[])'

An example of the code is:

#pageMaster .CCResultsText2 { 
    font-size: <%= ViewData.Model.FontSize %>; 
    color: <%= ViewData.Model.FontColor %>; 
}

This error gets resolved, however, when I replace <%= ViewData.Model.FontColor %> with <% Response.Write(ViewData.Model.FontColor); %>

It seems that there seems to be some kind of issue differentiating the two different forms of the System.IO.TextWriter.Write method, but I'm not exactly sure what I can do besides write out the Response.Write method.

+1  A: 

Try to cast your model member to a specific type like:

#pageMaster .CCResultsText2 { 
    font-size: <%= (int)ViewData.Model.FontSize %>; 
    color: <%= (string)ViewData.Model.FontColor %>; 
}

The types are just my guess.. cast it to proper types of course ;)

ŁukaszW.pl
Thanks, this works. Is there a reason that this would occur with only 2 fields within the table (when all the rest have the same varchar datatype) ?
Swamp56
A: 

I, too, would like to know why this happens. If we change a field's datatype, this just adds more places we have to remember to change it.

James in Indy