jordan says:
clsProductPearlMain objpp =
new
clsProductPearlMain(
true
);
objpp.getCatPro();
string
str =
string
.Empty;
int
j = 0;
for
(j = 0; j < objpp.ListclsProductPearlMain.Count; j++)
{
if
(File.Exists(Server.MapPath(
"images/ProductPearl/"
+ objpp.ListclsProductPearlMain[j].ProductID +
".jpg"
)))
{
str +=
@"<div class='row col-md-3 col-xs-6 hovereffect'>
<div class='imageBackGround' style='width:250px;height:280px;'>
<img class='imges' style='height:220px;' src='images/ProductPearl/"
+ objpp.ListclsProductPearlMain[j].ProductID + ".jpg
" + @"
' />
<p
class
=
'sname'
>
" + objpp.ListclsProductPearlMain[j].ProductName + @"
</p>
<p
class
=
'sname2'
>
" + objpp.ListclsProductPearlMain[j].MRP + @"
</p></div><br/>
</div>";
}
}
product.InnerHtml = str;
Place above code in different method and call that method in pageload event like below
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindImagesOnPageStart();
}
}
public void BindImagesOnPageStart()
{
clsProductPearlMain objpp = new clsProductPearlMain(true);
// objProduct.getProduct();
objpp.getCatPro();
string str = string.Empty;
int j = 0;
for (j = 0; j < objpp.ListclsProductPearlMain.Count; j++)
{
// string path = objProduct.ListclsProductMain[i].ProductID+".jpg";
if (File.Exists(Server.MapPath("images/ProductPearl/" + objpp.ListclsProductPearlMain[j].ProductID + ".jpg")))
{
str += @"<div class='row col-md-3 col-xs-6 hovereffect'>
<div class='imageBackGround' style='width:250px;height:280px;'>
<img class='imges' style='height:220px;' src='images/ProductPearl/" + objpp.ListclsProductPearlMain[j].ProductID + ".jpg" + @"' />
<p class='sname'>" + objpp.ListclsProductPearlMain[j].ProductName + @"</p>
<p class='sname2'>" + objpp.ListclsProductPearlMain[j].MRP + @"</p></div><br/>
</div>";
}
}
//}
product.InnerHtml = str;
}
jordan says:
<script type=
"text/javascript"
>
$(
function
() {
$(
'#menu ul li a'
).click(
function
() {
var
selectedLink = $(
this
)[0].innerHTML
localStorage.setItem(
'selectedLink'
, selectedLink);
});
});
window.onload =
function
() {
$(
'#menu ul li a'
).each(
function
() {
if
($(
this
)[0].innerHTML == localStorage.getItem(
'selectedLink'
)) {
$(
this
).attr(
'style'
,
'background-color:deeppink'
);
localStorage.removeItem(
'selectedLink'
);
}
else
{
$(
this
).attr(
'style'
,
'background-color:none'
);
}
});
}
</script>
replace above script with below
<script type="text/javascript">
$(function () {
$('#menu ul li a').click(function () {
var selectedLink = $(this)[0].innerHTML
localStorage.setItem('selectedLink', selectedLink);
});
});
window.onload = function () {
$('#menu ul li a').each(function () {
if ($(this)[0].innerHTML == localStorage.getItem('selectedLink')) {
$(this).attr('style', 'background-color:deeppink');
}
else {
$(this).attr('style', 'background-color:none');
if (localStorage.getItem('selectedLink') == null) {
$('[id*=lnkAllProducts]').attr('style', 'background-color:deeppink');
}
}
});
}
</script>