page loads twice due to js code
- by Cristian Boariu
Hi,
I have this div inside a repeater, where i set the class, onmouseover and onmouseout properties from code behind:
<div id="Div1" runat="server" class="<%# getClassProduct(Container.ItemIndex) %>" onmouseover="<%# getClassProductOver(Container.ItemIndex) %>" onmouseout="<%# getClassProductOut(Container.ItemIndex) %>">
codebehind:
public String getClassProduct(Object index)
{
int indexItem = Int32.Parse(index.ToString());
if (indexItem == 3)
return "produs_box produs_box_wrap overitem lastbox";
else
return "produs_box produs_box_wrap overitem";
}
public String getClassProductOver(Object index)
{
int indexItem = Int32.Parse(index.ToString());
if (indexItem == 3)
return "this.className='produs_box produs_box_wrap overitem_ lastbox'";
else
return "this.className='produs_box produs_box_wrap overitem_'";
}
public String getClassProductOut(Object index)
{
int indexItem = Int32.Parse(index.ToString());
if (indexItem == 3)
return "this.className='produs_box produs_box_wrap overitem lastbox'";
else
return "this.className='produs_box produs_box_wrap overitem'";
}
Well, the problem is that, my Page_Load is fired twice, and there i have some code which i want to execute only ONCE:
if (!Page.IsPostBack)
{ ..code to execute once }
This code is fired initially, and after the page is rendered, it is called again, and executed again due to that js...
Anyone can recommend a workaround?
Thanks in advance.