i am using a check box to validate the input given by user. the view is as follows
@if(Model.Is_Prefix_Checked == 1)
{
}
else
{
}
When the check box is unchecked it passes null instead of 0
in my model i as follows
public int? isprefixchecked {get; set;}
Kindly help
Rijwan AnsariPosted Feb 7, 2023, 12:14 PM
Hi
Select your checkbox with Id reference.
Example:
Sachin SinghPosted Feb 7, 2023, 5:33 AM
Test this
Naimish MakwanaPosted Feb 7, 2023, 5:10 AM
Hello Kaushik,
Your model property
isprefixcheckedis of typeint?.which is expecting either an integer value or null. So you need to cast the value to an integer before setting it to the model propertyThanks
Naimish Makwana