The hidden DIV containing an ASP.NET CheckBox consistently yields a value of false

I have a group of form elements located within a hidden div which looks like this:

<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>

I control the visibility of this div using a jQuery function (not included here for simplicity)

Upon submitting the form by clicking btnSaveEditFolder, I am able to retrieve the values of the TextBoxes, FileUpload control, and DropDownList accurately. However, the checkboxes always return false. It's driving me crazy..

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 correct
    Dim fname As String = txtEditFolderName.Text.Trim ' value is correct
    Dim fdesc As String = txtEditFolderDesc.Text.Trim ' value is correct
    Dim order As String = IIf(ddlEditContentOrder.SelectedItem.Value = "0", "Asc", "Desc") ' value is correct
    Dim isactive As Boolean = IIf(chkEditIsActive.Checked, True, False) ' ## ALWAYS FALSE
    Dim isvisible As Boolean = IIf(chkEditShowOnHome.Checked, True, False) ' ## ALWAYS FALSE
End Sub

When I remove the style display:block; and make the form visible on the page from the start, then the checkboxes return the correct values (true if checked, false if not..)

Has anyone encountered a similar issue?

Answer №1

Make sure to update the checkbox to true:

value="True"

Try that out and then reach out to me if it resolves the issue. It may seem simple, but sometimes the simplest solutions are the most effective. If it doesn't work, I'll investigate further for you.

Answer №2

Here's a suggestion:

Declare a boolean variable called isActive and set it to the value of the checked property of the chkEditIsActive checkbox.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error encountered in Express middleware: Attempting to write private member #nextId to an object that was not declared in its class

Currently, I am in the process of developing a custom logger for my express JS application and encountering an issue. The error message TypeError: Cannot write private member #nextId to an object whose class did not declare it is appearing within my middle ...

ES6 import of CSS file results in string output instead of object

Too long; Didn't read I'm facing an issue where the css file I import into a typescript module resolves to a string instead of an object. Can someone help me understand why this is happening? For Instance // preview.ts import test from './ ...

Troubleshooting multiple file upload errors in Asp.net Mvc using ajax

I am attempting to implement multiple file upload in MVC using jQuery ajax but I am encountering some issues. https://i.sstatic.net/34kXO.png Here is my HTML design and code: <div id="fileinputdiv"> <input type="file" name="mainfile" id="main ...

How to ensure the footer stays at the bottom of the page even when the Treeview control expands

Greetings Everyone! I'm facing an issue with keeping the footer pinned at the bottom of the page. The treeview control I'm using overlaps the footer when expanded. Can anyone assist in ensuring the footer remains at the bottom of the page? < ...

Incorporating the "+ " icon in Vuejs Dropzone to indicate the presence of existing images

Looking to enhance my Vue-dropzone file uploader component by adding an icon or button labeled "Add more images" when there are already images present in the dropzone. This will help users understand that they can upload multiple photos. Any suggestions on ...

The dynamic form is programmed to display identical values for both the initial and subsequent inputs

Currently, I am developing a personalized dynamic form utilizing the Material UI library as the component for my React Js application. You can find more information about this library at https://mui.com/. In front of you is the initial setup of the dynami ...

The Architecture of a Node.js Application

I'm curious about the efficiency of my nodejs app structure in terms of performance optimization. My main concern lies in how I handle passing around references to my app object across modules. Basically, in my app.js file, I define all my dependenci ...

If the request body exists, it should return a 409 error code

*Can anyone please help me with avoiding duplicate requests for existing names in NodeJS Express?* Here is my code: /* Post new person to persons */ app.post("/api/persons/", (req, res) => { const schema = { name: Joi.string().alphanum ...

The error message states: "It is not possible to destructure the property 'createComponentInstance' of 'Vue.ssrUtils' as it is undefined for nuxt and jest."

I have been working on integrating the jest testing framework into my nuxt project, but I am facing a major obstacle. I am struggling to test a simple component and haven't been able to find a solution yet. If anyone has encountered the same issue, co ...

What is the best way to retrieve the border-color inline style using jQuery?

I have a HTML tag like this. <span id="createOrderFormId:accountNo" style="border-color: red;"><</span> To retrieve the style value for the border-color property, I tried using the following jQuery code: $( document ).ready(function() { ...

What is the correct way to utilize browser actions for sending keys with the "?" symbol in Protractor?

I'm facing an issue in my tests with a particular line of code browser.actions().sendKeys(Key.chord(Key.CONTROL, '?')).perform(); Interestingly, it works fine with another symbol. For example: browser.actions().sendKeys(Key.chord(Key.CONT ...

I am puzzled as to why my ajax script is giving me a 404 error even though the URL appears to be correct

Even though it's not a cross-domain problem, Ajax is returning a 404 error code. In my TIZEN Web application project, I am trying to make an ajax request to a WebService that contains functions necessary for the project. Initially, the xhr.status was ...

React Native vector icons display enigmatic symbols

I recently installed react-native-vector, but I'm seeing strange symbols when using it. Can anyone provide guidance on how to properly utilize this library? Platform: Android import React from 'react'; import {View, Text, StyleSheet} from & ...

clear the input field of any entered text type

Just starting out with Javascript! Below is some code: This code is taken directly from the HTML page <form action="#" id="ToolKeywordSearch"> <input type="text" class="ProductFinderText" id="ToolSearchField"onblur="if(this.value==& ...

Problem with translating a variable into a selector in JQuery

When attempting to make my Jquery code more flexible, I decided to extract the selector and access it through a variable. However, despite creating variables for both selectors, neither of them seem to be functioning properly. I am confident that the issue ...

Difficulty Encountered when Using Colorbox in Internet Explorer (all iterations)

I've been struggling to get Colorbox working properly on this particular page, even after spending more time than anticipated. The link to the page has been removed for privacy reasons. There's a Colorbox test link at the bottom right corner tha ...

What unique functionalities are available in a System.Web.Mvc.Controller that are not present in a System.Web.Http.ApiController?

My current system is based on MVC5 and the WebApi. I am looking to develop a new controller with dual functions. Firstly, it should respond to REST requests by returning API data. Secondly, it needs to act as a backend for a page containing buttons that tr ...

Adjust the height and width controls in the Ui Cropper

I am currently utilizing AngularJS and I have a requirement to crop images, so I decided to use the ui-cropper library. Here is where I found my inspiration: https://codepen.io/Crackeraki/pen/zvWqJM This is the code snippet I am working with: <div&g ...

The information is not being stored in Excel despite the fact that the Excel document has been generated with a header

I have been working on a project that involves fetching book details from the Google Books API and using generative AI to create descriptions for them. I have successfully created an Excel file, but I am facing an issue with saving data inside it. It' ...

Share your message with BotFramework WebChat by simply clicking on the provided link

A chatbot I created using Microsoft Bot Framework has been integrated into my website through DirectLine: <div id="chatbot_body"></div> <script src="https://unpkg.com/botframework-webchat/botchat.js"></script> <script> ...