[Solved] ASP.Net MVC Error: Index and length must refer to a location within the string. Parameter name: length

sureshMGR
 
on Aug 12, 2021 03:06 AM
439 Views

Hello friends,

i am using below code, but while executing project below issue is coming in if condition

value is:

Model.sodReceptionDate = {6/30/2021 12:00:00 AM}

System.ArgumentOutOfRangeException: 'Index and length must refer to a location within the string. Parameter name: length

@if (Model.SodReceptionDate!=null)
{
    <input class="form-control" disabled="disabled" id="RECEPTION_DATE" name="RECEPTION_DATE" type="text" value=@Model.SodReceptionDate.Value.ToString("dd-MMM-yyyy") />
}

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Aug 12, 2021 07:38 AM
sureshMGR says:
<input class="form-control" disabled="disabled" id="RECEPTION_DATE" name="RECEPTION_DATE" type="text" value=@Model.SodReceptionDate.Value.ToString("dd-MMM-yyyy") />

Check with below.

<input class="form-control" disabled="disabled" id="RECEPTION_DATE" name="RECEPTION_DATE" type="text" value='@Model.SodReceptionDate.Value.ToString("dd-MMM-yyyy")' />