Showing posts with label hii. Show all posts
Showing posts with label hii. Show all posts

Wednesday, March 28, 2012

PageMethod Timeout

Hi

I call a web method exposed in an aspx page as follows:

PageMethods.MyWS("hello world",
OnCallbackComplete,
OnCallbackTimeout,
OnCallbackError,
null,
10); // timeoutInterval

To simulate the timeout I add some sleep time to the thread in the web method, lets say 10000 (10 seconds). Problem is the timeout callback method on the client doesn't get invoked.

Any ideas?

CraigThere was a bug where we weren't respecting the timeoutInterval set onthe request if the default timeout interval is set. Can you checkif you have set the WebRequestManager's timeout interval? Trysetting the WebRequestManager's timeout interval and see if thattriggers the timeout callback...

Hope that helps,
-Hao

Thanks for the reply.

I tried the following which didn't trigger the timeout as expected:

Sys.Net._WebRequestManager._timeoutInterval = 10;

Sys.Net._WebRequestManager.timeoutInterval = 10;

Sys.Net._WebRequestManager.set_timeoutInterval(10); // threw an exception

PageMethods.MyWS("hello world",
OnCallbackComplete,
OnCallbackTimeout,
OnCallbackError);
So that's not quite right, the instance you want to use is the static Sys.Net.WebRequestManager, rather than the _ one.

So you can do Sys.Net.WebRequestManager.set_timeoutInterval(10), or in the xml markup, you can do something like

<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<webRequestManager timeoutInterval="3000"/>
</components>
</page>
</script
Hope that helps,
-Hao

that did the trickBig Smile [:D]

thanks

Saturday, March 24, 2012

Paging freeze after partial postback

HiI am a newbie to the AJAX stage, I created an application very similar in functionality as the to do list HDI video demo.My problem is when I do a partial page back and the new data is refreshed into my gridview the paging stops to function. You can click on the page numbers and there it will stay till I fire

a full page postback. I have an updatePanel with a Gridview and a dropdownlist included in the panel. The dropdownlist just selects different departments in our organization.

I set the updatePanel to conditionalupdate and specified my trigger as dorpdownlist selected index change, enabled the paging and enablepagingandsorting on my gridview.

What did I miss on my path to AJAX ?

Can you post your code where its freezing. Check with breakpoints?


hello.

if the dropdown is inside the panel, then you simply don't need to set up triggers.

btw, here's a quick example:

i have the following ona code file on app_code:

public class Obj
{
private Int32 _id;
private String _name;

public int Id
{
get { return _id; }
set { _id = value; }
}

public string Name
{
get { return _name; }
set { _name = value; }
}
}


public class ObjDS
{
public List<Obj> Get()
{
List<Obj> objs = new List<Obj>
{
new Obj{Id = 1, Name = "Luis"} ,
new Obj{Id = 2, Name = "Jose"} ,
new Obj{Id = 3, Name = "Jose"} ,
new Obj{Id = 4, Name = "Jose"}

}
;
return objs;
}
}

and then, on an aspx page, i have this:

<asp:ScriptManager runat="server" ID="manager" />
<asp:UpdatePanel runat="server" ID="panel">
<contenttemplate>
<asp:GridView ID="GridView1" runat="server"
PageSize="2"
DataSourceID="source" AllowPaging="true">
</asp:GridView>

<asp:ObjectDataSource
TypeName="ObjDs"
SelectMethod="Get"
ID="source" runat="server">
</asp:ObjectDataSource>
<%= DateTime.Now.ToString() %>
</contenttemplate>
</asp:UpdatePanel>

it's working here. does it work there?


Hi LuisThanks for the reply.I am using a database queried created dataset and not a custom dataset,does this make a difference?What gets me is that after the page has loaded for a first time the paging works and after a partial postback the rest of the controls workexcept the datagrid's paging.

I'll have a crack at your code and let you know.


Hi Dexza,

Here is a working sample which is written based on your description. Please compare it with yours.

<%@. 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)
{
if (!IsPostBack)
{
this.DropDownList1.Items.Add("111");
this.DropDownList1.Items.Add("222");
}
}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{

}
</script
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<%=DateTime.Now.ToString()%>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" PageSize="2" AllowPaging="true">
<Columns>
<asp:CommandField ShowEditButton="True" />
<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" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NORTHWNDConnectionString%>"
SelectCommand="SELECT [EmployeeID], [LastName], [FirstName], [Title] FROM [Employees]"
DeleteCommand="DELETE FROM [Employees] WHERE [EmployeeID] = @.EmployeeID" InsertCommand="INSERT INTO [Employees] ([LastName], [FirstName], [Title]) VALUES (@.LastName, @.FirstName, @.Title)"
UpdateCommand="UPDATE [Employees] SET [LastName] = @.LastName, [FirstName] = @.FirstName, [Title] = @.Title WHERE [EmployeeID] = @.EmployeeID">
<DeleteParameters>
<asp:Parameter Name="EmployeeID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="EmployeeID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="Title" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true">
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</form>
</body>
</html>

Best regards,

Jonathan


Hello.

Jonathan, i haven't run the code, but i'm curious: why did you associate a trigger with a server control that is inside an updatepanel?


Hi Luis Abreu,

Thanks for your attention. I just generated a sample based on the description of the thread owner. Yes , I agree with you that we don't need a trigger in this situation. Thanks

Best regards,

Jonathan


hello again.

well, i just asked because i might be missing something...thanks for the clarification.


Hi guys I have found my problem regarding the paging issue fromContributor post I noticed that on his properties he had only AllowPaging set to true and I had AllowPaging and EnablePagingAndSortingCallback set to true. So I changed it to false and of we go. Paging and sorting is up and running. Now I still have the problem where after selecting something different from my dorpdownlist that the updating does not work, but if I go back to the data the page was loaded with it works fine. So I have two questions. Why does the paging and sorting stop to function with a partial postback if EnablePagingAndSortingCallback is set to true. And what is wrong with the update function. Here is my code.

<%@.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%> <%@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1"%> <!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"> <title>Untitled Page</title> <linkhref="StyleSheet.css"rel="stylesheet"type="text/css"/></head> <body> <formid="form1"runat="server"> <asp:ScriptManagerID="ScriptManager1"runat="server"/> <br/> <br/> <br/> <br/> <asp:PanelID="Panel2"runat="server"BorderColor="Silver"BorderStyle="Solid"BorderWidth="1px" Height="50px"Width="125px"> <asp:UpdatePanelID="UpdatePanel1"runat="server"EnableViewState="False"UpdateMode="Conditional"> <ContentTemplate> <asp:GridViewID="GridView1"runat="server"AllowPaging="True" AutoGenerateColumns="False"BackColor="SteelBlue"DataKeyNames="IdeaNumber"DataSourceID="ObjectDataSource1"ForeColor="White"GridLines="None"Width="504px"AllowSorting="True"> <Columns> <asp:CommandFieldShowEditButton="True"/> <asp:BoundFieldDataField="IdeaNumber"HeaderText="IdeaNumber"InsertVisible="False" ReadOnly="True"SortExpression="IdeaNumber"/> <asp:BoundFieldDataField="IdeaName"HeaderText="IdeaName"SortExpression="IdeaName"/> <asp:CheckBoxFieldDataField="IdealDone"HeaderText="IdealDone"SortExpression="IdealDone"/> </Columns> <AlternatingRowStyleBackColor="LightBlue"ForeColor="SteelBlue"/> </asp:GridView> <asp:ObjectDataSourceID="ObjectDataSource1"runat="server"DeleteMethod="Delete" EnableViewState="False"InsertMethod="Insert"OldValuesParameterFormatString="original_{0}" SelectMethod="GetIdeaData"TypeName="IdeaDataSetTableAdapters.IdeaTableTableAdapter" UpdateMethod="Update"> <DeleteParameters> <asp:ParameterName="Original_IdeaNumber"Type="Int32"/> </DeleteParameters> <UpdateParameters> <asp:ParameterName="IdeaName"Type="String"/> <asp:ParameterName="IdealDone"Type="Boolean"/> <asp:ParameterName="Original_IdeaNumber"Type="Int32"/> </UpdateParameters> <SelectParameters> <asp:ControlParameterControlID="DropDownList1"Name="IsDone"PropertyName="SelectedValue" Type="Boolean"/> </SelectParameters> <InsertParameters> <asp:ParameterName="IdeaName"Type="String"/> <asp:ParameterName="IdealDone"Type="Boolean"/> </InsertParameters> </asp:ObjectDataSource> <asp:DropDownListID="DropDownList1"runat="server"AutoPostBack="True"> <asp:ListItemValue="false">To do</asp:ListItem> <asp:ListItemValue="true">Completed</asp:ListItem> </asp:DropDownList> </ContentTemplate> <Triggers> <asp:AsyncPostBackTriggerControlID="GridView1"EventName="RowEditing"/> </Triggers> </asp:UpdatePanel> </asp:Panel> <br/> <br/> </form></body>

</html>


hello.

well, not sure on what's happening there...anyways, i'll just leave my 2 cents. first, if you have an updatepanel, i'm not sure if you'll be wining much with the grid's paging and sorting through callbakcs (if you have the time, compare the size of each request - yeah, i believe that through callbacks you'll have less to transport but you can't do other interesting things).

second, i can't seem to think of a good reason why the callback mechanism should not working with the updatepanel partial postbacks. try using fiddler to see what's happening between client and server...

Paging Problem in Dynamically added GridView

Hi

I am developing a composite control which includes a GridView. GridView is created and bound in CreateChildControls() method. Normally the control works greate. But if I set AllowPaging=True, it gives an "Object null reference exception". Following is the code. Please give me a solution. [N:B: I have added the PageIndexChages Event also].

protected override void CreateChildControls(){_lsAjaxGridView =new GridView();_lsAjaxGridView.ID ="Leadsoft_AjaxGrid";_lsAjaxGridView.AutoGenerateColumns =this.AutoGenerateColumns;foreach (DataControlField dataControlFieldin Columns) _lsAjaxGridView.Columns.Add(dataControlField);if (this.AllowPaging){if (this.PageSize > 0) _lsAjaxGridView.PageSize =this.PageSize; _lsAjaxGridView.AllowPaging =this.AllowPaging; _lsAjaxGridView.PageIndexChanging +=new GridViewPageEventHandler(Leadsoft_AjaxGrid_PageIndexChanged);}_lsAjaxGridView.DataSource = LSDataSourceView;_lsAjaxGridView.DataBind();}
The exception occurs in "_lsAjaxGridView.DataBind();" only when AllowPaging is True.
Exception Message:"Object reference not set to an instance of an object."

Hi this problem is solved. thing is any DataBinding should be done after the control is added to the form.

lsAjaxGridView.DataSource = LSDataSourceView;

Controls.Add(lsAjaxGridView);
_lsAjaxGridView.DataBind();

Panel is resizing when it is used with RoundCornerExtender.It looks page load twice

hi

I have a master page , in that i have placed three panels and foreach panel i have a RoundedCornersExtender for round corners.problem iswhen i run the page it loads two times. I think that is because of roundcornerextender,when the page loads the panel looks to be resizing and it causes the page loads twice

when i remove the RoundedCornersExtender from the panel,it worksfine and load only once.but i want round corner panel for my masterpage to look good.


if anybody having the solution for this,plz advice me.Thanks in advance

This is my master page code

<%@dotnet.itags.org. Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<%@dotnet.itags.org. Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="http://links.10026.com/?link=Hq_StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#4B5C82"><%--"#4B5C82"--%>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

<table cellspacing="5" cellpadding="4" width="95%" align="center" id="mastertable">
<tr>
<td colspan="2">
<asp:Panel ID="panel1" runat="server" Width="100%" BackColor="#ffffff" >
<!--#include file="header.aspx"-->
</asp:Panel>

</td>
</tr>
<tr >
<td width="20%" height="100%" valign="top" >
<asp:Panel ID="panel2" runat="server" Width="100%" BackColor="#ffffff" Height="100%">
<table cellpadding="3"><tr><td>
<!--#include file="leftnav.aspx"-->
</td></tr>
</table>
</asp:Panel>
</td>
<td width="80%">
<asp:Panel ID="panel3" runat="server" Width="100%" BackColor="#ffffff" Height="100%">
<table cellpadding="3"><tr><td>
<asp:contentplaceholder id="middleContent" runat="Server"></asp:contentplaceholder>
//Content pages
</td></tr>
</table>
</asp:Panel>
</td>

</tr>
<tr>
<td></td>
<td id ="footer">
<!--#include file="footer.aspx"-->
</td>
</tr>
</table>
<ajaxToolkit:RoundedCornersExtender ID="RoundedCornersExtender1"runat="server" TargetControlID="Panel1" Radius="8"BorderColor="#ffffff">
</ajaxToolkit:RoundedCornersExtender>
<ajaxToolkit:RoundedCornersExtender ID="RoundedCornersExtender2"runat="server" TargetControlID="Panel2" Radius="8"BorderColor="#ffffff">
</ajaxToolkit:RoundedCornersExtender>
<ajaxToolkit:RoundedCornersExtender ID="RoundedCornersExtender3"runat="server" TargetControlID="Panel3" Radius="8"BorderColor="#ffffff">
</ajaxToolkit:RoundedCornersExtender>
</form>
</body>
</html>

Regards

Ajith

Hi Ajith,

My suggestion is you can wrap all contents in an div, and set this div's display property to "none" initially.

Then, add a pageLoad function to show it on client side. Like this:

function pageLoad()
{
$get("div's id").style.display = "block";
}

Hope this helps.


Hi Wen

Thank you Very much. it is working superb, but sometime when page loads, twice loading happens again(some times only).what would be the problem?

plz advice.Thank you very much once again

Regards

Ajith


It's hard to tell because I'm not able to reproduce that.

Can you make sure which element incurs a second postback?


Hi Wen

in my header page , i have menu for each page.for eg consider first menu
having a link to 1st page, in that page i having several textboxes and 1 dropdownlist
and cascadingdropdown and 1 auto complete extender.in that menu i clicked several times
only one time the page load twice.i think it may coz of processing time.

2nd having link to another page, in that page also i am having the same controls mentioned above and aditionally i am having ultrawebgrid(thirdpartycontrol,infragistics).i click
this menu also several time , in this case the pages seems like loading
twice so many times. idont know which control is making the problem.


This is the situation i am having.

Plz advice.

Regards

Ajith

Wednesday, March 21, 2012

Partial page refresh on master pages

Hi

I need some help. I'm working on a web site and i'm having problems to avoid a full page refresh when i navigate across the site using a menu control.

I use a master page to define the main aspect of my site. On the master page i placed a menu control and i want to refresh only the content place holder with the content page each time the user click on a menu item. I' ve tried to do this with ajax but until now, no luck.

If someone have a clue on how to do this i would very much appreciate it..Big Smile

Master pages are not frames...each time you click a link, you are on a new page, and the masterpage just gives it the same look. The only way that I have heard of to do that is with iFrames or having one page and load all your pages as user controls, although both methods are rather hacky.


I've alse tried to use iframes inside the master page and set the target property on the menu control to the iframe, but instead of loading the content page inside the iframe it opens a new window.

I placed the iframe within the content place holder on the master page. Maybe its not the right place to put it.


I think that you may need to do it on an aspx page, and all the pages you go to from there would need to not have a master page. Actually if you are doing it that way, you may not even need a master page. You could probably have a page that looks like the master page, but has an iFrame where the content template would be. I am not completely sure if that would work correctly though because we don't worry about that much though because most our pages act as separate applications, so there is not a lot of switching pages. Postbacks can also serve as a way for the user to see that they are going somewhere else, which works the way our site is, but may or may not for you.