cshtml binding js function with boolean parameter using model
Hi,
I recently faced this issue while binding Model.boolvariable as a parameter to js function.
it was not getting passed as expected but always received 'onclick' the event name which was getting bind.
here is the sample I was struggling with:
<a href="" class="OpenDataTablePopup" style="font-weight:bold" onclick="javascript: ShowTBL(@Model.intfield,@Model.IsDefaultData); return false;">Edit record</a>
After several tries with trial and error I got this solution, which I wasn't aware of:
<a href="" class="OpenDataTablePopup" style="font-weight:bold" onclick="javascript: ShowTBL(@Model.intfield,@Model.IsDefaultData.ToString().ToLower()); return false;">Edit record</a>
Just adding this info, as someone might save some time.
Happy coding!!!
I recently faced this issue while binding Model.boolvariable as a parameter to js function.
it was not getting passed as expected but always received 'onclick' the event name which was getting bind.
here is the sample I was struggling with:
<a href="" class="OpenDataTablePopup" style="font-weight:bold" onclick="javascript: ShowTBL(@Model.intfield,@Model.IsDefaultData); return false;">Edit record</a>
After several tries with trial and error I got this solution, which I wasn't aware of:
<a href="" class="OpenDataTablePopup" style="font-weight:bold" onclick="javascript: ShowTBL(@Model.intfield,@Model.IsDefaultData.ToString().ToLower()); return false;">Edit record</a>
Just adding this info, as someone might save some time.
Happy coding!!!
Comments
Post a Comment