Thursday, August 22, 2019

On Hover of div Show another div

aspx page changes

//css

.MyAccountdiv {
    width:35%;
    padding:5px 8px;
    /*margin-left:20%;*/
    display:inline-block;
    background:#ededed;
    float:right;
    cursor:pointer;
}
#MyAccountdiv {
}
.MyAccount {
    color:#2f71a9;
    background: url("/Web/App_Themes/default/images/darrow.png") #ededed no-repeat center right 5px;
    }
.MyAccountbtn {
    color: #424242;
    text-align:left;
    width:100%;
    font-weight: normal;
    border:0px;
    background:#ededed;
}

<script type="text/javascript">

    function myFunction() {
        var x = document.getElementById("<%=Account_list.ClientID %>");
                    x.style.display = "block";
           }
    function myFunctionout() {
        var x = document.getElementById("<%=Account_list.ClientID %>");
                  x.style.display = "none";
       
    }
</script>

 <div runat="server" id="DivMyAccount" class="MyAccountdiv" onmouseover="javascript:myFunction();" onmouseout="javascript:myFunctionout();" >
                        <div id="MyAccountdiv" runat="server"  class="MyAccountbtn">
                            <div>My</div>
                            <div class="MyAccount">Account</div>
                        </div>
                    </div>
                    <div runat="server" id="Account_list" class="Account_list" onmouseover="javascript:myFunction();" onmouseout="javascript:myFunctionout();"></div>



aspx.cs page changes

//Load data to the div which will be visisble to customer on hover

 StringBuilder sQuery = new StringBuilder();
            sQuery.AppendFormat("SELECT RTRIM(CDCValue) AS CDCValue, RTRIM(CDCValueDesc) AS CDCValueDesc FROM {0}  where CDCCode = 'MyAccountList' and Lang = '{1}' order by CDCValue desc ", E2WConstants.SSTables.CDC_DETAIL, Profile.culture);
            //if (string.IsNullOrEmpty(Address.GetERPAdrressIDForCustomerItemNumber(signOn)))
            //{
            //    sQuery.Append(" and ColumnName <> 'CustomerMaterialNumber'");
            //}
            // sQuery.AppendFormat(" Union Select '{0}' AS CDCValue, '{0}' CDCValueDesc ", E2WConstants.SearchAutoComplete.ALLCOLUMN);
            DataTable dt = DBtools.GetDataTable(sQuery.ToString(), "CDCValues");

         
            if (dt != null && dt.Rows.Count > 0)
            {
              
                    StringBuilder sbInnerHtml = new StringBuilder();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                     

                        //sbInnerHtml.AppendFormat("<li><a href={0}></a></li>", dt.Rows[i][1].ToString());

                        sbInnerHtml.AppendFormat("<li><a href=\"{0}\" {2}>{1}</a></li>", dt.Rows[i][1].ToString(), dt.Rows[i][0].ToString(), "");
                    }

                    // MyAccount.InnerHtml  = sbInnerHtml.ToString();
                    Account_list.InnerHtml = sbInnerHtml.ToString();
            }


No comments:

Post a Comment