Showing posts with label masterpage. Show all posts
Showing posts with label masterpage. Show all posts

Saturday, March 24, 2012

PageRequestManagerTimeOutException

Hey,

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:

<asp:ScriptManagerID="ScriptManager1"AsyncPostBackTimeOut="600"runat="server">

</asp:ScriptManager>

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,

Joesy

Hi Joesy,

P1:

You can add your own exception handler, like this:

<script type="text/javascript" language="javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

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

args.set_errorHandled(true);
alert("My custom exception handler: " + errorMessage);
}
}
</script>

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.

P2:

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 ;

P3:

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,

Joesy


Hi Joesy,

Here is a sample regarding the last 2 questions:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><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="http://www.w3.org/1999/xhtml" ><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:PanelID="Panel1"runat="server"ScrollBars="Vertical"Width="99%"Height="440px"

BorderWidth="1px"BorderColor="#E0E0E0"Wrap="False"HorizontalAlign="Justify"

EnableTheming="False">

<asp:DataGridID="Log_GridView"runat="server"Width="95%"OnItemCommand="Log_GridView_ItemCommand"

AutoGenerateColumns="False"ForeColor="#333333"Font-Names="Verdana"HorizontalAlign="Justify"

EnableTheming="True"AllowPaging="True"PageSize="250"CellPadding="0"DataKeyField="ID"

OnPageIndexChanged="Log_GridView_PageIndexChanged"OnItemDataBound="Log_GridView_ItemDataBound"

GridLines="Vertical">

<EditItemStyleBackColor="#2461BF"></EditItemStyle>

<SelectedItemStyleBackColor="#D1DDF1"ForeColor="#333333"BorderColor="#80FF80"

Font-Bold="True"></SelectedItemStyle>

<PagerStyleBackColor="#2461BF"ForeColor="White"HorizontalAlign="Center"></PagerStyle>

<AlternatingItemStyleBackColor="White"></AlternatingItemStyle>

<ItemStyleBackColor="#EFF3FB"></ItemStyle>

<HeaderStyleBackColor="#507CD1"ForeColor="White"Font-Bold="True"></HeaderStyle>

<Columns>

<asp:BoundColumnDataField="ID"HeaderText="ID"ReadOnly="True"Visible="False"></asp:BoundColumn>

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

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

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

<asp:ButtonColumnHeaderText="View"ButtonType="PushButton"CommandName="View_Button"

Text="View">

<ItemStyleWidth="10%"></ItemStyle>

</asp:ButtonColumn>

</Columns>

</asp:DataGrid></asp:Panel>

Could you please help me as soon as possible?

Thank you very much,

Kind regards,

Joesy


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.

Thanks.


Hey wowief,

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

For problem 1. I added this:

<httpRuntimeexecutionTimeout="5000"/>

into system.web and problem is solved!

Good luck

Joesy

Wednesday, March 21, 2012

Partial refreshing problem with masterpage

Hi, everyone, I add a scriptmanager before updatepanel and updatepanel contatins only contentplaceholder in masterpage, but partial refreshing never takes action in ie6, each time I click, it postback whole page, I don't know why? To solve the problem I have add another updatepanel(contains a button and lablel) in masterpage, in that updatepanel partial refreshing works, but why if for contentplaceholder it doesn't work?

I am sure scriptmanager's partialrendering property is "true" . and I don't have a xhtmlConformance section in my web.config file.

I have searched some posts on this forum, but their problem seems does not fit for mine.

waiting for your answers

Bo.

Hello ,

Plz try the following url,it may not be the exact solution but it can direct u to the solution

http://www.devsource.com/article2/0,1895,1945460,00.asp


Hi,I found that in my project, Hyperlink in UpdatePanel can not support partial refreshing, while I setup another simple website, in its UpdatePanel, HyperLink can support partial refreshing, their environment is almost same. but Have different results, why?

Partial rendering issue

The update panel sometimes doesn't work.

I have a masterpage referencing the scriptmanager:
<atlas:ScriptManagerID="mainAtlasScripts"runat="server"EnableViewState="true"EnableScriptComponents="true"EnablePartialRendering="true"></atlas:ScriptManager>

I have a page that displays a gridview with a table under it to insert rows in the gridview
<atlas:UpdatePanelID="updList"runat="server"Mode="conditional">
<Triggers>
<atlas:ControlEventTriggerControlID="btImport"EventName="Click"/>
</Triggers>
<ContentTemplate>
<asp:GridViewID="gvList"runat="server"AllowPaging="True"AutoGenerateColumns="False"
DataSourceID="odsData"Width="100%"ShowHeader="False"
OnSelectedIndexChanged="gvList_SelectedIndexChanged">
<Columns>
<asp:TemplateFieldHeaderText="Title"SortExpression="Title"ShowHeader="False">
<ItemTemplate>
FieldContent
</ItemTemplate>
</Columns>
</asp:GridView>
</ContentTemplate>
</atlas:UpdatePanel>
<asp:TextBoxID="tbImport"runat="server"asp:TextBox>
<asp:ButtonID="btImport"runat="server"Text="Import"Height="19px"OnClick="btImport_Click"/>

But when I click on the btImport button I get some javascript error saying object required. The update is done tho, but the rendering of the page to the browser doesn't work. So if I click will add the item to the list but the gridview won't be showing me the update.

I would really like to start using this updatepanel because it will save me a lot of time not having to javascript code for updating my page for every single thing.

For basic operations it does work.. just not on the page where I need it at this moment..
So if i put on the same page a different updatepanel with a label in the contenttemplate and a button as trigger then it does work but obviously of no use to me

I have to correct myself because it does work untill I put the updatepanel in a multiview.
I will just go back to updating my html from javascript and calling a webservice as I did before..

casual jim wrote:

The update panel sometimes doesn't work.

I have a masterpage referencing the scriptmanager:
<atlas:ScriptManagerID="mainAtlasScripts"runat="server"EnableViewState="true"EnableScriptComponents="true"EnablePartialRendering="true"></atlas:ScriptManager>

I have a page that displays a gridview with a table under it to insert rows in the gridview
<atlas:UpdatePanelID="updList"runat="server"Mode="conditional">
<Triggers>
<atlas:ControlEventTriggerControlID="btImport"EventName="Click"/>
</Triggers>
<ContentTemplate>
<asp:GridViewID="gvList"runat="server"AllowPaging="True"AutoGenerateColumns="False"
DataSourceID="odsData"Width="100%"ShowHeader="False"
OnSelectedIndexChanged="gvList_SelectedIndexChanged">
<Columns>
<asp:TemplateFieldHeaderText="Title"SortExpression="Title"ShowHeader="False">
<ItemTemplate>
FieldContent
</ItemTemplate>
</Columns>
</asp:GridView>
</ContentTemplate>
</atlas:UpdatePanel>
<asp:TextBoxID="tbImport"runat="server"asp:TextBox>
<asp:ButtonID="btImport"runat="server"Text="Import"Height="19px"OnClick="btImport_Click"/>

But when I click on the btImport button I get some javascript error saying object required. The update is done tho, but the rendering of the page to the browser doesn't work. So if I click will add the item to the list but the gridview won't be showing me the update.

I would really like to start using this updatepanel because it will save me a lot of time not having to javascript code for updating my page for every single thing.

For basic operations it does work.. just not on the page where I need it at this moment..
So if i put on the same page a different updatepanel with a label in the contenttemplate and a button as trigger then it does work but obviously of no use to me


I′m also getting the same error. Did you get around it yet?

I also experienced this...what I did was remove the triger portion of the update panel incases where I only have one update panel on the page. It seemed to work but I did experience some additional page flicker but nothing compared to a full postback. I think that this is a bug with the Click event handler on the trigger. The control builder/wizard/whatever doenst recongize the click event of some buttons.

Good Luck!


Could it be that you need to include the textbox and Button within the update panel?

IE:

<asp:TextBoxID="tbImport"runat="server"asp:TextBox>
<asp:ButtonID="btImport"runat="server"Text="Import"Height="19px"OnClick="btImport_Click"/>
</atlas:UpdatePanel
This way there is no requirement in the backend code to call the update event... it all should be wrapped seemlessly with no changes to normal code there...


it is an issue with the multiview in my case. The work around is to just use panels instead of the multiview

I decided in my case that the partial update indeed is AJAX but defeats the purpose because you are always sending back the full page. I refactored to use the clientscript based implementation.

You get a flicker with the partial rendering for the images and i didn't like it.