0

我在隐藏的 div 中有一组表单元素,如下所示:

<div id="jDivUpdateFolder" style="display:none;">
    <asp:TextBox ID="txtEditFolderName" runat="server"></asp:TextBox><br />
    <asp:TextBox ID="txtEditFolderDesc" runat="server" TextMode="MultiLine"></asp:TextBox><br />
    <asp:FileUpload ID="fuEditPhoto" runat="server" /><br />
    <asp:DropDownList ID="ddlEditContentOrder" runat="server">
        <asp:ListItem Value="0" Text="Ascending"></asp:ListItem>
        <asp:ListItem Value="1" Text="Descending"></asp:ListItem>
    </asp:DropDownList><br />
    <asp:CheckBox ID="chkEditIsActive" runat="server" Text="Active" /><br />
    <asp:CheckBox ID="chkEditShowOnHome" runat="server" Text="Show on HomePage" /><br />
    <asp:LinkButton CssClass="anchorbutton green" ID="btnSaveEditFolder" Text="Save" runat="server"></asp:LinkButton>

我通过 jQuery 中的一个函数来切换这个 div 的可见性(为了简单起见,这里不包括它)

当使用 btnSaveEditFolder 的单击事件提交表单时,我可以正确检索 TextBoxes、FileUpload 控件和 DropDownList 的所有值。但不知何故,复选框总是返回 false。我要疯了。。

Protected Sub btnSaveEditFolder_Click(sender As Object, e As System.EventArgs) Handles btnSaveEditFolder.Click
    Dim fID As Integer = Convert.ToInt32(txtFolderID.Value.Trim) ' value is good
    Dim fname As String = txtEditFolderName.Text.Trim ' value is good
    Dim fdesc As String = txtEditFolderDesc.Text.Trim ' value is good
    Dim order As String = IIf(ddlEditContentOrder.SelectedItem.Value = "0", "Asc", "Desc") ' value is good
    Dim isactive As Boolean = IIf(chkEditIsActive.Checked, True, False) ' ## ALWAYS FALSE
    Dim isvisible As Boolean = IIf(chkEditShowOnHome.Checked, True, False) ' ## ALWAYS FALSE
End Sub

当我删除样式display:block;并且表单在页面上可见时,它们会返回正确的值(如果选中,则返回 true,否则返回 false ..)

有人遇到过这样的问题吗?

4

2 回答 2

0

将复选框的值设置为 true:

value="True"

发布并让我知道这是否有效。听起来很傻,但只要这样做,如果没有成功的话,我会为你进一步调查。

于 2013-05-18T19:27:36.047 回答
0

尝试:

Dim isactive As Boolean = chkEditIsActive.Checked
于 2013-05-18T22:37:30.270 回答