document.GetElementByID(.......).visible Not working

Discussion in 'HTML / PHP / JavaScript / CSS' started by albanello, Jan 24, 2017.

  1. ********
    WUC creation
    I have created a Web User Control (WUC) with a Check Box as shown below

    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="WUCChkBoxRowDtTm.ascx.vb" Inherits="LotteryApp.WUCChkBoxRowDtTm" %>

    <asp:checkbox id="ckbxCheckBoxID" runat="server"
    style="margin-right:0.75em;"
    Width="17.25em" Height="1.25em"
    Text="Row??Col0" OnClick="DoCheckBoxClick();"/>

    ********
    HTML code
    <ucl:WUCChkBoxRowDtTm id="WUC_ChkBoxRow_1ID" runat="server"/>

    ********
    In the JavaScript code
    I can get "checked" to work:
    document.GetElementByID(WUC_ChkBoxRow_1ID_ckbxCheckBoxID).checked;

    BUT can not get a "visible" to work:
    document.GetElementByID(WUC_ChkBoxRow_1ID_ckbxCheckBoxID).visible;

    ********
    I have been trying for days........can sombody PLEASE tell what I am doing wrong!

    Albanello
     
  2. If anybody is out there, here is the reason I could not get "visible" status on my Web User Control with:

    document.GetElementByID(WUC_ChkBoxRow_1ID_ckbxCheckBoxID).visible;

    JavaScript works with the HTML document. When the WUC is told to NOT be visible the HTML page does NOT render HTML
    for that WUC therefore there is no data for the above Document.Get...........).visible to see/get on the HTML rendered page.

    Simple answer. Hope this helps somebody. It took me a week to figure this out........I'm just happy I found the answer to my problem.

    albanello
     
    RayH likes this.
  3. mjp

    mjp

    Thanks for posting the follow up, I'm sure it will help someone.
     
  4. Here is my solution for JavaScript to see Code Behind WUC visible state. Create a HTML hiddenfield for code behind to pass the visibility state of all WUC, then JavaScript can use the HTML hiddenfield to determine the visibility state of all WUC that have a visibility state of Not visible (visible = false)

    Hope this helps somebody, with a similar problem.

    albanello
     

Share This Page