locked
See values at run time RRS feed

  • Question

  • User416875641 posted

    Hi,

    <tr><td>
    <img src=imageSrc alt="images" style="width:128px;height:96px;" />
    @imageSrc
    </td></tr>

    |Yields:

    System.Collections.Generic.List`1[System.String]

    how to get actual vlaue of the variable in razor syntax.

    Debugging not working in f12 much.

    Page.Response.Write("<script>console.log('" + imageSrc + "');</script>");
    Yeilds:
    Page.Response.Write(" ");

    How to see the actual value of imageSrc, because getting blank placeholder for picture?

    Wednesday, November 6, 2019 12:10 PM

Answers

  • User475983607 posted

    The error message is telling you @imgeSrc is defined as a List<string>.  An index is required to get to the value.

    @imgeSrc[0]

    You might have to rethink the design if you are expecting a string.  Or maybe you need a loop?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 6, 2019 1:23 PM

All replies

  • User475983607 posted

    The error message is telling you @imgeSrc is defined as a List<string>.  An index is required to get to the value.

    @imgeSrc[0]

    You might have to rethink the design if you are expecting a string.  Or maybe you need a loop?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 6, 2019 1:23 PM
  • User-1780421697 posted

    why not put value in ViewBag and access it. Well you can define a variable which can hold string and you can access it in Razor view, if you have List<string> then you  have to specify its index. like List<string> r= new List<string>(); r.Add("hello");

    In view : @r[0].ToString();

    Monday, November 11, 2019 5:40 AM
  • User61956409 posted

    Hi AltFire,

    how to get actual vlaue of the variable in razor syntax.

    Do you access a public variable in View page? You can try to pass your data using ViewModel or ViewBag ect.

    With Regards,

    Fei Han

    Tuesday, November 12, 2019 10:06 AM