How to tell if a form checkbox is checked through a pageload asp.net
Sorry if this is a duplicate, most of the questions that I looked at were similar but not the same question.
I have a form with a checkbox:
<input id = "ppCheckBox" type = "checkbox" name = "policy"/>
I do an ajax call in my JS to send all form data to a page load. I want to be able to know if that checkbox is checked during page load.
Any ideas on how to do开发者_JAVA百科 this? is there something like Request.Params.["policy"].isChecked()
? Or any method that I can use just to determine if it is checked?
I added your input and an asp button to a page, clicked the button, and viewed the Request["policy"]
in the debugger.
When the checkbox is unchecked, Request["policy"]
returns null
. When it's checked, it returns "on"
.
Make it server side:
<input runat="server" id = "ppCheckBox" type = "checkbox" name = "policy"/>
Then you can reference ppCheckBox
by name in your C# code.
精彩评论