Sticky Checkbox with Razor Pages

I am rewriting an application that I made years ago that uses Asp.Net WebForms. One of the features is, upon visiting a page that has several checkboxes, the checkboxes are checked by way of a cookie using JavaScript.

In my Razor Pages Application, I'm trying to do everything I can without using JS. I have a List<T> property on the page that binds to the checkboxes. My plan was to create a cookie as a .csv when the form is posted (that works) and then reading that cookie and assigning those values back to the Bound Property (StatusCheckBox).

I can debug, and see that the values get assigned, but as soon as the Page() is returned, the checkboxes are returned unchecked. The values get bound on the Post(), but once the Get() is complete, the page that is returned has a checkbox with no values.

Is there a way to do this, or am I stuck with Ajax/JavaScript?

Thanks in advance!


3 Replies

AS Aravinthan Seetharaman Syncfusion Team October 4, 2021 05:30 PM UTC

Hi karbotilne, 
 
Thanks for contacting Syncfusion Support. 
 
We have checked your query. Before proceeding further we would like to know the below details. 
 
·         Please confirm us whether you are using Asp.net web forms or ASP.NET Core. 
·         Please share us your Syncfusion Package version. 
·         Please share CheckBox related code snippet 
·         Please share us your Exact requirement. 
 
Please share us the above requested information and that would be a grate help for us to provide better solution quickly. 
 
Regards, 
Aravinthan S 



KA karbotilne October 5, 2021 09:00 PM UTC

I am rewriting an application that I made years ago that uses Asp.Net WebForms. One of the features is, upon visiting a page that has several checkboxes, the checkboxes are checked by way of a cookie using JavaScript.

In my Razor Pages Application, I'm trying to do everything I can without using JS. I have a List property on the page that binds to the checkboxes. My plan was to create a cookie as a .csv when the form is posted (that works) and then reading that cookie and assigning those values back to the Bound Property (StatusCheckBox).

I can debug, and see that the values get assigned, but as soon as the Page() is returned, the checkboxes are returned unchecked. The values get bound on the Post(), but once the Get() is complete, the page that is returned has a checkbox with no values. https://vshare.onl/

 Is there a way to do this, or am I stuck with Ajax/JavaScript?

Thanks in advance!

issue got solved!!



AS Aravinthan Seetharaman Syncfusion Team October 6, 2021 07:38 AM UTC

Hi karbotilne, 
 
Thanks for the update. 
 
We are happy to hear that your issue has been resolved. Please feel free to contact us if you need any further assistance on this. 
 
Regards, 
Aravinthan S

Loader.
Up arrow icon