[英]ASCX.cs code behind page not pulling value from the ascx page
I have a checkbox that resets itself on postback to the code behind page, I'm now trying to set the value of the checkbox in the code behind page. 我有一个复选框,可在回发到页面后方代码时重置自身,我现在正尝试在页面后方代码中设置复选框的值。 But I am unable to do so below is my code the hidden field doesn't get set, any help would be appreciated:
但是我不能这样做,以下是我的代码的隐藏字段未设置,任何帮助将不胜感激:
ASPX ASPX
<asp:Checkbox id="HiddenDossetCheckValue" value="" runat="server" type="hidden"/>
function DossettesSet()
{
var zCheckBox = document.getElementById('<%=HiddenDossetCheckValue.ClientID%>');
var checkBoxBool = zCheckBox.checked;
if(zCheckBox.checked === true)
{
document.getElementById('<%=HiddenDossetCheckValue.ClientID%>').value = "1";
console.log(document.getElementById(HiddenDossetCheckValue).value);
}
if (zCheckBox.checked === false) {
document.getElementById('<%=HiddenDossetCheckValue.ClientID%>').value = "0";
//console.log(document.getElementById(HiddenDossetCheckValue).value);
}
}
ASCX.CS ASCX.CS
public string CheckBoxValue
{
get
{
bool hiddenField;
hiddenField = HiddenDossetCheckValue.Checked;
if (ViewState["HiddenDossetCheckValue"] != null)
return (string)ViewState["HiddenDossetCheckValue"];
else
return null;
}
set
{
bool hiddenField = false;
}
}
You are assigning the checkbox field to a variable and not using it? 您是将复选框字段分配给变量而不使用它吗?
Why not just: 为什么不只是:
zCheckBox.value = '1';
console.log(zCheckBox.value);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.