Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have some div whose visiblty is set true or false according to conditions ...

on a point in code behind .. i have to check div visibility true or false ...
but it always return false ... whats wrong in this i am unable to understand .. my code sample is ... ....


XML
<div id="TransactionTypeDivForCommercial" class="postline" runat="server" visible="false"  >
                        <p class="postText">Transaction Type Required :</p>
                        <asp:RadioButtonList ID="RbtnTransactionTypeForCommercial" runat="server" RepeatDirection="Horizontal" AutoPostBack="True" OnSelectedIndexChanged="RbtnTransactionTypeForCommercial_SelectedIndexChanged">

                        </asp:RadioButtonList>
                    </div>

                    <div id="TransactionTypeDivForResidential" class="postline" runat="server">
                        <p class="postText">Transaction Type Required :</p>
                        <asp:RadioButtonList ID="RbtnTransactionTypeForResidential" runat="server" RepeatDirection="Horizontal" AutoPostBack="True" OnSelectedIndexChanged="RbtnTransactionTypeForResidential_SelectedIndexChanged">

                        </asp:RadioButtonList>
                    </div>

                    <div id="DivBuyType" class="postline" runat="server">
                        <p class="postText">Buy Type :</p>
                        <asp:CheckBoxList ID="ChlBListBuyType" runat="server" RepeatDirection="Horizontal">

                        </asp:CheckBoxList>
                    </div>




and my code behind logic is ...

C#
if (TransactionTypeDivForCommercial.Visible == true)
            { 
           
            ObjPostRequirementDetails.TransactionTypeIdReq= RbtnTransactionTypeForCommercial.SelectedValue.ToString();
            }
            else
            { 
            ObjPostRequirementDetails.TransactionTypeIdReq=RbtnTransactionTypeForResidential.SelectedValue.ToString();
            }

            if(DivBuyType.Visible==true)
            { 
            string s1 = ZrickGlobalClass.ControlLoading.NewMultiListSelection(ChlBListBuyType);
            ObjPostRequirementDetails.BuyTypeIdReq = ZrickGlobalClass.BasicDbOperations.NewSaveMultiListItems(s1).ToString();
            }
            else
            {
                ObjPostRequirementDetails.BuyTypeIdReq = "";
            }



pls give some help .. thanks in advanse ..
Posted
Updated 31-May-16 1:24am
v2
Comments
Schatak 7-May-14 7:39am    
because you have specified "TransactionTypeDivForCommercial" visibility=false so it will always give you false.
are you setting its visibility = true somewhere in your code or not?
GDdixit 7-May-14 8:20am    
Yes i have seted it to true in my code ...

and this visiblity set false only in this div ...

and i now when i am checking the visiblity using if condition , it returns false .. although i have already set visible =true ... any idea why this happening

on debugging step by step it shows a message that "{InnerText = '((System.Web.UI.HtmlControls.HtmlContainerControl)(TransactionTypeDivForCommercial)).InnerText' threw an exception of type 'System.Web.HttpException'}"


????????????

in case of this div



replace ----> class ="<%=clsdisplay%>"

add this class in page

ie,

.clsdisplay
{
display:none;
}

then declare clsdisplay as public string

public string clsdisplay = "dispnone";

if you want to hide div in some condition set
C#
clsdisplay ="";
 
Share this answer
 
Comments
GDdixit 7-May-14 7:43am    
can you describe little more any example or link .... and whats wrong in my code .. i have already implemented this .. in a big area .. i i continue that code .. than it will be more batter ?
GDdixit 7-May-14 8:17am    
dude problem is not in displaying or hiding the div .. problem occours when ..

i am checking the visibality of div in code behind .. it always shows visible= false ?
For some reason it is not possible to access values set through Javascript in the code behind directly. The work around is to put a hidden field eg. <asp:HiddenField ID="idName" runat="server"/> on your form and update the value property anytime you modify the div visibility. You can go ahead to check the value stored in the hidden field instead of the div i.e.
if(idName.value=="hidden")
{
do something.
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900