I have a link that goes to a controller that renders a page that includes this javascript.
$(document).ready(function () {
var creditCards = '<%:(ViewData["CreditCards"])%>';
alert(creditCards);
if (creditCards != null) {
var CreditCardViewData = '<%:((SelectList)ViewData["CreditCards"]).Count() %>';
....
The situation I am testing is when the viewData creditCards is null. I debug it and it gets to the var creditCards = '<%:(ViewData["CreditCards"])%>';
line and when i click step into it jumps all the way to var CreditCardViewData = '<%:((SelectList)ViewData["CreditCards"]).Count() %>';
. (Note: this page works fine when the ViewData CreditCards is not null)
After it jumps, it instantly gives the error: "argumentnullexception: Value cannot be null. Parameter name: source."
How do i prevent this error from showing up. Thanks