在后面的代码中检查div visiblity总是返回false并给出一些内部html表达式 [英] checking div visiblity in code behind always return false and gives some inner html expression

查看:93
本文介绍了在后面的代码中检查div visiblity总是返回false并给出一些内部html表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.aspx页面中有一个多视图,这是我的代码示例...



 <   div     id   =  TransactionTypeDivForCommercial    class   =  postline    runat   =  server       >  
< p class = postText > 所需的交易类型:< / p >
< asp:RadioButtonList ID = RbtnTransactionTypeForCommercial runat = server RepeatDirection = 水平 的AutoPostBack = True OnSelectedIndexChanged = RbtnTransactionTypeForCommercial_SelectedIndexChanged >

< / asp:RadioButtonList >
< / div >

< div id = TransactionTypeDivForResidential = postline runat = server >
< p class = postText > 所需的交易类型:< < span class =code-leadattribute> / p
>
< asp:RadioButtonList ID = RbtnTransactionTypeForResidential runat = server RepeatDirection < span class =code-keyword> = 水平 AutoPostBack = True OnSelectedIndexChanged = RbtnTransactionTypeForResidential_SelectedIndexChanged >

< / asp:RadioButtonList >
< / div >

< div < span class =code-attribute> id = DivBuyType class = postline runat = server >
< p class = postText > 购买类型:< / p < span class =code-keyword>>
< asp:CheckBoxList ID = ChlBListBuyType runat = server RepeatDirection = 水平 >

< / asp:CheckBoxList >
< / div >













在这个我根据我在cs文件中的情况设置div的可见性(真/假)..

这样可以正常工作......



但是当我在服务器上提交数据时...我只提交那些div可见性为真的控件的数据....我的cs代码示例是这样的....







 如果 (TransactionTypeDivForCommercial.Visible ==  true 
{

ObjPostRequirementDetails.TransactionTypeIdReq = RbtnTransactionTypeForCommercial.SelectedValue.ToString();
}
else
{
ObjPostRequirementDetails.TransactionTypeIdReq = RbtnTransactionTypeForResidential.SelectedValue.ToString();
}

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











但是此时检查visiblty它总是返回false(虽然在代码隐藏过程中visibliy设置为true)....





并且在调试时它也会显示某种类型的异常..





 {InnerText = ' ((System.Web.UI.HtmlControls.HtmlContainerControl )(TransactionTypeDivForCommercial))。InnerText'引发类型'  System.Web.HttpException'} 

base = { 无法获取TransactionTypeDivForCommercial的内部内容,因为内容不是文字。}
ErrorCode = -2147467259





i无法找到我的代码错误...呃这个问题非常依赖..



任何建议或帮助都会感激... thnx in advanse

解决方案

i have a multi view in my .aspx page and in this this is my code sample ...

<div id="TransactionTypeDivForCommercial" class="postline" runat="server"   >
                        <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>







in this i am setting visiblity(true/false) of divs according to my situation in cs file ..
this will working fine ...

but when i am submitting data on server ... i am submitting data of only those controls whose div visiblity is true .... my cs code sample is like this ....



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 = "";
            }






but at this point on checking visiblty it always returns false (although visibliy is set to true in code behind process )....


and on debugging it also shows some type of exception ..


{InnerText = '((System.Web.UI.HtmlControls.HtmlContainerControl)(TransactionTypeDivForCommercial)).InnerText' threw an exception of type 'System.Web.HttpException'}

base = {"Cannot get inner content of TransactionTypeDivForCommercial because the contents are not literal."}
ErrorCode = -2147467259



i am unable to find whats the wrong with my code ... i have a lot of dependancy on this problem ..

any suggestion or help will appreciate ... thnx in advanse

解决方案

这篇关于在后面的代码中检查div visiblity总是返回false并给出一些内部html表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆