0

I am trying to debug code in a cshtml file. I set a breakpoint and it breaks. But when I try to watch a variable it gives the CS0103 error. This is happening all the time not just in this part of the code.

I have set it to use managed compatibility and made sure I am in debug instead of release. I have looked at it on google and it is set up the way it should be as far as I know. I am a newbie to C# and debugging cshtml files.

if (@Model.GranteeDeed1 > 0) {
    var fe = fundEntities.filter(function(obj) { return obj.FundEntityID == @Model.GranteeDeed1; });
    $("#lblGranteeDeed1").text(fe[0].EntityName);
    $("#txtGranteeDeed1 option[value='" + fe[0].FundEntityID  + "']").attr("selected", "selected");
}

I want to see the value of either obj.FundEntityID or (fe[0].EntityName). I can see the value of @Model.GranteeDeed1.

YosiPel
  • 25
  • 7
  • Hi, which VS do you use, VS for MAC or VS for windows? If it's vs for windows, right-click project=>properties=>build tab=>advanced, make sure the `debug information` is set to Full instead of Portable... – LoLance Oct 15 '19 at 17:06
  • Windows. And it is already set to Full. That was one of the hints I got from googling. – YosiPel Oct 15 '19 at 20:47

1 Answers1

0

Both of those two variables appear to be Javascript. You will want to use the developer tool in your browser (F12 in Chrome/Firefox/Edge on Windows, not sure what the equivalent is on Mac). In Chrome it's the "Sources" tab and in Firefox it's the "Debugger" tab.

Here are some links:

howcheng
  • 2,211
  • 2
  • 17
  • 24
  • IE says that the EntityName was unable to get the value. Chrome did not give any indication of a problem. But I will look again at the Sources tab, tomorrow. Thanks. – YosiPel Oct 15 '19 at 20:50
  • I knew the @Model was a javascript variable I just thought the others were c# server-side variables. – YosiPel Oct 15 '19 at 20:53
  • `@Model` *is* a server-side variable. The `@` symbol is a shortcut to put the value of a server-side variable onto the page. If you look at the actual HTML, you'll see that it renders as something like `if (5 > 0) {` (whatever the value of `@Model.GranteeDeed1` is). – howcheng Oct 15 '19 at 21:13
  • @howcheng- Thanks for the explanation. I did see that it replaced it with the value from the db. – YosiPel Oct 16 '19 at 17:24
  • I found that a Json query is coming back blank. But when I step through the code it appears to be populating the list and the value that is in GranteeDeed1 is in the list. See below var fundEntities = JSON.parse('@Html.Raw(Json.Encode(((List)ViewBag.FundEntities).Select(f => new { FundEntityID = f.ID, EntityName = f.EntityName, InvestorId = f.InvestorId, InvestorName = f.InvestorName }).Where(f => f.InvestorName == Model.InvestorName).OrderBy(f => f.EntityName).ToList()))'); var fundEntities = JSON.parse('[]'); – YosiPel Oct 16 '19 at 17:27