Saturday, March 24, 2012

Why Soo Slow ?

ASP.NET 2.0.
One line of code (checkbox onclick) in a databound grid really slows down
the page load...
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox ID="chkEmp" onClick=<%# "HighlightRow(this, """ +
Eval("empname") + """)"%> runat="server" autopostback="False"/>
</ItemTemplate>
</asp:TemplateColumn>
If I remove the """ + Eval("employee_name") + """ part from the line
everything works great. Any ideas? Even the HighlightRow javascript
function is simple...
<script language="javascript">
<!--
function HighlightRow(chkB, empname)
{
xState=chkB.checked;
if(xState)
{
chkB.parentElement.parentElement.style.backgroundColor='yellow';
}
else
{
chkB.parentElement.parentElement.style.backgroundColor='whitesmoke';
}
}
-->
</script>
You may notice that the empname var is not eve used (yet) in the javascript.
Anyways, why would this take soo long for the page to load with the onclick
in place?
Thanks.Becuase each row of the grid the code is evaluated - this can be slow.
You may be better to use a different method.
Check with an ASP.NET newsgroup for ASP.NET Gurus
Cheers
Chris Crowe [IIS MVP 1997 -> 2006]
http://blog.crowe.co.nz
---
"Jay" <msnews.microsoft.com> wrote in message
news:%237PsHQh%23FHA.912@.TK2MSFTNGP11.phx.gbl...
> ASP.NET 2.0.
> One line of code (checkbox onclick) in a databound grid really slows down
> the page load...
> <asp:TemplateColumn>
> <ItemTemplate>
> <asp:CheckBox ID="chkEmp" onClick=<%# "HighlightRow(this, """ +
> Eval("empname") + """)"%> runat="server" autopostback="False"/>
> </ItemTemplate>
> </asp:TemplateColumn>
> If I remove the """ + Eval("employee_name") + """ part from the line
> everything works great. Any ideas? Even the HighlightRow javascript
> function is simple...
> <script language="javascript">
> <!--
> function HighlightRow(chkB, empname)
> {
> xState=chkB.checked;
> if(xState)
> {
> chkB.parentElement.parentElement.style.backgroundColor='yellow';
> }
> else
> {
> chkB.parentElement.parentElement.style.backgroundColor='whitesmoke';
> }
> }
> -->
> </script>
> You may notice that the empname var is not eve used (yet) in the
> javascript.
> Anyways, why would this take soo long for the page to load with the
> onclick in place?
> Thanks.
>
Sorry I thought I was in an IIS Newsgroup.
Cheers
Chris Crowe [IIS MVP 1997 -> 2006]
http://blog.crowe.co.nz
---
"Chris Crowe [MVP 1997 -> 2006]" <IISMVP2005@.iisfaq.homeip.net> wrote in
message news:eVS$Akj%23FHA.140@.TK2MSFTNGP12.phx.gbl...
> Becuase each row of the grid the code is evaluated - this can be slow.
> You may be better to use a different method.
> Check with an ASP.NET newsgroup for ASP.NET Gurus
> --
> Cheers
> Chris Crowe [IIS MVP 1997 -> 2006]
> http://blog.crowe.co.nz
> ---
>
> "Jay" <msnews.microsoft.com> wrote in message
> news:%237PsHQh%23FHA.912@.TK2MSFTNGP11.phx.gbl...
>

0 comments:

Post a Comment