Saturday, March 24, 2012



I have several problems and I need your help.

Problem 1: In a MasterPage, I have a timer which always runs to check whether there is any new update in the database, If I let the website running over night, in the next morning I will see that the memory will increase to >1GB in Task Manager and raise an error "Sys.WebForms.PageRequestManagerTimeOutException: The server request timed out", I have searched to find the solution for this, there is a tip to add AsyncPostBackTimeOut into the scriptManager like this:



But the problem is still occured! like the firgure below:

Does anybody know how to catch this exception! Thanks in advance

Problem 2: I add a datagrid inside a Panel1. First take a look at the figure below:

If I scroll down the scrollbar and click on a button View, the scrollbar will be automatically moved on the top. I tried to add this:

this.Page.MaintainScrollPositionOnPostBack =true;

In the end of code lines of event for button "View" but problem is till occured! Again, please help me!

Problem 3: (last problemSmile )

First take a look at the figure below:

This is a datagrid, it is nice that when the mouse hovers at every row, the background color of that row will be changed to gray. But is it possible that I click on every place at that row and I get the event which is the same with click on button View. is it possible? Thanks,

Your help will be appreciated!

Thank you so much in advance,


Hi Joesy,


You can add your own exception handler, like this:

<script type="text/javascript" language="javascript">

function EndRequestHandler(sender, args)
if (args.get_error() != undefined)
var errorMessage = args.get_error().message;

alert("My custom exception handler: " + errorMessage);

Please also note this:

AsyncPostBackTimeout : Gets or sets a value that indicates the period of time,in seconds, before asynchronous postbacks time out if no response is received.


The position can't be maintained because the scroll position of a control inside the page will be lost between postbacks.

You need implement this with your own code. For instance:

1. Add a hiddenfield to the page, which will be used to save current scroll position.

2. Save current scroll position to the hiddenField before the page postbacks. document.getElementById("hiddenField").value =document.getElementById("grdWithScroll").scrollTop;

3. Set the scroll position to the value of the HiddenField after the page postback. document.getElementById("grdWithScroll").scrollTop=document.getElementById("hiddenField").value ;


Yes, it's possible. Basically, you can add a onclick event handler to the generated <tr> tag in which trigger the corresponding button's click event.

Hope this helps.

Hey Raymond,

Firstly, Thank you very much for your reply, It has been a time and you are the only one who replied to my post. I am very appreciated about your help.

P1: I solvedYes

P2: Could you please give me a full code that I need to implement?

P3: Could you please help me to give me more details? it is the best to give me an example.

Thanks in advances,


Hi Joesy,

Here is a sample regarding the last 2 questions:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""><script runat="server"> protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Button btn = e.Row.FindControl("Button2") as Button; btn.OnClientClick = "$get('HiddenField1').value = $get('Panel3').scrollTop;"; e.Row.Attributes.Add("onclick", "$get('" + btn.ClientID + "').click();"); } } protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { }</script><html xmlns="" ><head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> </script></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Panel ID="Panel3" runat="server" Height="130px" Width="564px" ScrollBars="Auto"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="EmployeeID" DataSourceID="SqlDataSource1" OnRowDataBound="GridView1_RowDataBound" OnRowCreated="GridView1_RowCreated"> <Columns> <asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" InsertVisible="False" ReadOnly="True" SortExpression="EmployeeID" /> <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" /> <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" /> <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /> <asp:TemplateField> <ItemTemplate> <asp:Button ID="Button2" runat="server" Text="Button" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString%>" SelectCommand="SELECT [EmployeeID], [LastName], [FirstName], [Title] FROM [Employees]"></asp:SqlDataSource> </asp:Panel>   <asp:Button ID="Button1" runat="server" OnClientClick="$get('HiddenField1').value = $get('Panel3').scrollTop;" OnClick="Button1_Click" Text="Button" /> <asp:HiddenField ID="HiddenField1" runat="server" /> </form><script type="text/javascript">function pageLoad(){ $get('Panel3').scrollTop = $get('HiddenField1').value;}</script></body></html>

Hey Raymond,

Thank you very much for your help, We are nearly to solve the problem. but i am using DataGrid view instead of GridView, so is it any chance, you could help me to provide me a sample solution? This is the data grid inside the panel:


















<asp:BoundColumnDataField="LastName"HeaderText="Last Name"></asp:BoundColumn>

<asp:BoundColumnDataField="FirstName"HeaderText="First Name"></asp:BoundColumn>

<asp:BoundColumnDataField="Badgenumber"HeaderText="Badge Nr"></asp:BoundColumn>







Could you please help me as soon as possible?

Thank you very much,

Kind regards,


It's pretty much the same code as the above one, in ItemDataBound event of the DataGrid.

Hi JoeySY, how were you able to fixed the error for your Problem 1. I have the same problem.


Hey wowief,

It has been a long time since I came back to my post.

For problem 1. I added this:


into system.web and problem is solved!

Good luck


No comments:

Post a Comment