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");
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
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
8 Points
27 Posts
See values at run time
Nov 06, 2019 12:10 PM|AltFire|LINK
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.
How to see the actual value of imageSrc, because getting blank placeholder for picture?
All-Star
53001 Points
23588 Posts
Re: See values at run time
Nov 06, 2019 01:23 PM|mgebhard|LINK
The error message is telling you @imgeSrc is defined as a List<string>. An index is required to get to the value.
You might have to rethink the design if you are expecting a string. Or maybe you need a loop?
Contributor
2096 Points
1040 Posts
Re: See values at run time
Nov 11, 2019 05:40 AM|Khuram.Shahzad|LINK
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();
All-Star
40565 Points
6233 Posts
Microsoft
Re: See values at run time
Nov 12, 2019 10:06 AM|Fei Han - MSFT|LINK
Hi AltFire,
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