Showing posts with label object. Show all posts
Showing posts with label object. Show all posts

Monday, March 26, 2012

PageMethods object missing in RTM?

I tried to convert some code from the last RC to the RTM version that called PageMethods.MyMethod(), but the PageMethods object doesn't appear to be working anymore.

I started out with a fresh web.config from the RTM bits, so I know this isn't the problem.

I'm also hear anecdotally from other colleagues that the UpdatePanel control isn't working, or isn't working the way it did in the last RC.

Any feedback would be appreciated.

Hi Look at the following post:

http://forums.asp.net/thread/1545311.aspx

You need to set EnablePageMethods property of ScriptManager to true.


Sure enough. That did the trick.

Thanks for the tip!Wink


Sure enough. That did the trick.

Thanks for the tip!Wink

Pagerequestmanager

Hi All,

the AJAX technology isn't a new one. In IE 5 we where already able to do asynchrone HTTP request with the XMLHTTP object, but you had to communicate directly with the XMLHTTP object. well my question is:

Is the pagerequestmanager THE object that arrange al the communication with the XMLHTTP object so that we don't have to do that anymore? and this pagerequestmanager is the object where the scriptmanager communicates with so indirectly the scriptmanager is responsible for the communcation ?

A collegue of my is using AJAX in CRM. Is it also possible to do calls in CRM (Javascript) to webservices with the use of the scriptmanager? does the version of CRM makes any difference?

Kind regards,

Does nobody have any idea?

Hi Dennis,

I will try to answer to your questions:

1. The PageRequestManager handles the partial rendering mechanism on the client side where the ScriptManager object is the central control that coordinates several things like the scripts rendered to the client, the partial page mechanism , the client proxies used for communicating with the web services, applications services or page methods.

2. I think that the first answer also represents an answer for this question. By using the ScriptManager in your project you can enable calls to your web services.

You can check the docs available for the Beta2 release where you can find for yourself the means for doing all the things mentioned above.

Bogdan



hello.

pagerequestmanager is an important class and it's?only used when you define partial refreshing zones through updatepanels (ie, you generally don't use it directly in your code and it's injected on the page by the scriptmanager server control).

regarding the xmlhttpobject question, atlas introduces a network stack which has several layers. to communicate with the server, you can use the low level calsses or the high level classes.?the?object responsible?for?communicating?with?the?server?is?known?as?an?executor?(currently,?there's?only?one?executor,?XmlHttpExecutor,?which?uses?the?XmlHttpRequest?object?to?communicate?with?the?server?side).

normally, all remote requests are performed through the webrequest class, which let's you set several aspects of the current request (ex.: headers). if you want, you can use the high level classes (_webmethod class) or even generate a client javascript proxy (if your web service is hosted on an ajax enabled web site).

btw, you should note that web service calls don't depend on the scriptmanager control. having said this, it's important to note that?if?you're?developing?an?aspx?page,?then?you?can?also?add?theproxies?to?the?page?through?the?services?property?of?that?control.
hello.

just one more note: currently, there are 2 executors. the 2nd one is on the preview bits and it's called iframeexecutor.

Hi guys,

Sorry for my late response. i gave up the hope for an answer. Thanks for your replies. The reason why i posted this question is that i was reading a book about the old school AJAX technology. And as you will also know, they are working a lot with the XMLHTTPRequests (XHR). So i was curious on what layer did Microsoft build to abstract the direct calls with the XHR object. So i was interested in the whole proces from the scriptmanager to the XHR object.

So is it correct that the webrequestmanager is the layer which is responsible for managing the communication (XMLHTTPExecutor, XHR) for client side to server side. But i dont see the connection between the Pagerequestmanager / Sciptmanager and the webrequestmanager. Thanks in advance.

Regards,

Saturday, March 24, 2012

Paging a GridView in an UpdatePanel

Has anyone been able to implement paging for a GridView inside an UpdatePanel?

I get a JavaScript error everytime I click on the page number: "Object Required".

Enclosing the GridView control inside an UpdatePanel worked fine for me, including the paging.

Have you tried stepping through your code with VisualStudio? This works really good for me when debugging atlas. Also if your gridview is bound to a SqlDataSource you can enable PagingAndSortingCallbacks, and that has the same effect.


hello.

can you show us your code?

<atlas:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"/>

<atlas:UpdatePanelID="EmpOrders"runat="server"Mode="Conditional">

<Triggers><atlas:ControlEventTriggerControlID="Button1"EventName="Click"/></Triggers>

<ContentTemplate>

<asp:ButtonID="Button1"runat="server"Font-Italic="True"OnClick="Button1_Click1"Text="Search"/><br/>

<asp:GridViewID="GridView1"runat="server"CellPadding="4"ForeColor="#333333"GridLines="None"PageSize="15"AllowPaging="True"AutoGenerateColumns="False"OnPageIndexChanging="GridView1_PageIndexChanging"AllowSorting="True">

<Columns>

<asp:BoundFieldDataField="ShipName"HeaderText="Ship Name"SortExpression="ShipName"/>

<asp:BoundFieldDataField="ShipCountry"HeaderText="Country"SortExpression="Country"/>

<asp:BoundFieldDataField="Freight"HeaderText="Freight"SortExpression="Freight"/>

</Columns>

</asp:GridView>

</ContentTemplate>

</atlas:UpdatePanel>

Codebehind:

protectedvoid GridView1_PageIndexChanging(object sender,GridViewPageEventArgs e)

{

GridView1.PageIndex = e.NewPageIndex;

BindGrid();

}


hello.

well, it looks ok to me.

there's one thing i don't understand: you've added a trigger to the panel and configured it against a button which is also placed inside the panel...

i've built a small page that is working ok here (i've built a struct to simulate the info that is passed as source of the grid). see if it works with your current configuration:

public struct Ship
{
private string _shipName;

public string ShipName
{
get { return _shipName; }
set { _shipName = value; }
}
private string _shipCountry;

public string ShipCountry
{
get { return _shipCountry; }
set { _shipCountry = value; }
}
private string _freight;

public string Freight
{
get { return _freight; }
set { _freight = value; }
}

public Ship( string shipName, string shipCountry, string freight )
{
_shipName = shipName;
_shipCountry = shipCountry;
_freight = freight;
}
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!this.IsPostBack )
{
BindGrid();
}
}

void BindGrid()
{
Ship [] shippes = new Ship[]{
new Ship( "1","1","1" ),
new Ship( "2","2","2" ),
new Ship( "3","3","3" )
};

GridView1.DataSource = shippes;
GridView1.DataBind();
}

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{

GridView1.PageIndex = e.NewPageIndex;

BindGrid();

}

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page
</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"/>
<atlas:UpdatePanel ID="EmpOrders" runat="server" Mode="Conditional">
<Triggers>
<atlas:ControlEventTrigger ControlID="Button1" EventName="Click"/>
</Triggers>
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Font-Italic="True" Text="Search"/><br/>
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" PageSize="2" AllowPaging="True"
AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging" AllowSorting="True">
<Columns>
<asp:BoundField DataField="ShipName" HeaderText="Ship Name" SortExpression="ShipName"/>
<asp:BoundField DataField="ShipCountry" HeaderText="Country" SortExpression="Country"/>
<asp:BoundField DataField="Freight" HeaderText="Freight" SortExpression="Freight"/>
</Columns>
</asp:GridView>
</ContentTemplate>
</atlas:UpdatePanel>
<%= DateTime.Now.ToString() %>
</form>
</body>
</html>

Are you doing custom paging? I'm asking because normally, the GridView control takes care of this automatically (as well the binding -- unlike in DataGrid) so that you don't even have to handle the event. This is assuming that your datasource can handle paging (DataSet does I believe).


hello guys, and yes, i think that he is using the asp.net 1.X binding instead of using the new data source controls...

Yes I′m handling the binding as with .NET v1.x


hello again.

Can you run the sample page i've presented in a previous post?

Luis, your example works fine. The only difference between your code and mine is that you use a Struct as your datagrid's datasource and I use a DataSet.

What do you think?


hello.

well, i think that using a dataset shouldn't make any difference. can you build a sample page that uses a dummy dataset to reproduce the problem and post it here?
I have the same problem using an SQLDatasource. Is it possible that it only work with dataset because with dataset you can generate XML. Maybe with SqlDatasource it doesn't generate Xml so Atlas on gridview with SqlDatasource will no work ?
Luis, I′m working on the dummy page. In the meantime, I noticed that having

EnablePartialRendering="true"

won't let me fire the paging, deleting etc. events

Do you have it set to true?


hello.

yes i have. i've introduced < in my previous post and i think that now you should be able to see everything.

Paging in GridView gets Object Expected Error

I have a grid in an update panel that gets databound at runtime (to index server results). I have implemented paging and it works without atlas. As soon as I place that grid in update panel, paging stops working. All I get is a javascript error saying "line 1 :Object Requiered".

I have tried debugging it but on paging, it doesn't event get to the server.

thanks

Hi Biren,

Have you tried this with the April CTP of Atlas that was released earlier this week?

If it's still a problem, can you please provide some more details on your scenario so that we can investigate?

Thanks,

Eilon


I have done it and it works for me. Object required is a pretty generic error just as the "Object reference not set to an..." in .Net. It could be because of wrong syntax in javascript or html that you might have on the page.

If you don't mind pasting the code on the forum please do so we can look at it.


Just tried it and same error.

here is the code:

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="Index.aspx.vb" Inherits="Index" %>

<!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 id="Head1" runat="server">
<title>Search</title>
<link href="http://links.10026.com/?link=Style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<atlas:ScriptManager EnablePartialRendering="true" ID="atlas1" runat="server" EnableViewState="true" />
<form id="frm1" runat="server">

<atlas:UpdateProgress ID="up11" runat="server" >
<ProgressTemplate >
<table>
<tr>
<th style="color:red">Please wait while your serach results are calculated...</th>
</tr>
<tr>
<td>
<img src="http://pics.10026.com/?src=images/spinner.gif" /></td>
</tr>
</table>

</ProgressTemplate>
</atlas:UpdateProgress>
<atlas:UpdatePanel ID="up1" Mode="conditional" runat="server" >
<ContentTemplate >



<table>
<tr>
<th>A word or phrase in the file: </th><td><asp:TextBox ID="txtsearch" runat="server" /></td>
</tr>
<tr>
<th>All or part of filename: </th><td><asp:TextBox ID="txtfilename" runat="server" /></td>
</tr>
<tr>
<th>When was it modified?:</th>
<td>
<asp:DropDownList ID="lstDuration" runat="server">
<asp:ListItem Text="Don't remember" Value="0" />
<asp:ListItem Text="Within the last week" Value="7" />
<asp:ListItem Text="Past Month" Value="30" />
<asp:ListItem Text="Within the past year" Value="365" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2"><asp:Button ID="btnSubmit" runat="server" Text="Search" /></td>
</tr>
</table>

<asp:GridView ID="grdResults" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" AllowSorting="True" AllowPaging="True" PageSize="2" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Document Information">
<ItemTemplate>
<p>
<a href="http://links.10026.com/?link=<%# DataBinder.Eval(Container, "DataItem.path")%>">
<%# DataBinder.Eval(Container, "DataItem.Path")%>
</a>
<br />
<i>Last modified:
<%# DataBinder.Eval(Container, "DataItem.Write")%>
</i>
<br />
</p>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>

</ContentTemplate>

</atlas:UpdatePanel>
</form>
</body>
</html>

Code behind:

Partial Class Index
Inherits System.Web.UI.Page

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click


' Bind DataGrid to the DataSet. DataGrid is the ID for the
' DataGrid control in the HTML section.
Dim source As New DataView(createDS.Tables(0))
grdResults.DataSource = source
grdResults.DataBind()

End Sub
Private Function createDS() As DataSet
Dim cnnOledb As New OleDb.OleDbConnection
Dim strQuery As String

Dim critstr As String = "(contains(filename,'.doc OR .xls OR .ppt OR .asp OR .aspx OR .txt'))"

If txtsearch.Text.Length <> 0 Then
critstr += " AND (contains(contents,'" + condition(txtsearch.Text) + "'))"
End If


strQuery = "Select DocTitle,Filename,VPath,Rank,Characterization,Write,path from SCOPE() where " + critstr + " order by write desc"

Dim connString As String = "Provider=MSIDXS;Data Source='o drive'"

Dim cn As New System.Data.OleDb.OleDbConnection(connString)
Dim cmd As New System.Data.OleDb.OleDbDataAdapter(strQuery, cn)
Dim objDS As New DataSet

cmd.Fill(objDS)

Return objDS
End Function

Function condition(ByVal srchstr As String) As String
Dim arr As String() = srchstr.Split(" ")
For i As Integer = 0 To arr.Length - 1
Dim str1 As String = arr(i)
If str1 <> "AND" And str1 <> "OR" And str1 <> "NOT" Then
arr(i) = "\" + str1 + "\"
End If
Next
Return String.Join(" AND ", arr)
End Function


Sub grdResults_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles grdResults.PageIndexChanging
grdResults.PageIndex = e.NewPageIndex
Dim source As New DataView(createDS.Tables(0))
grdResults.DataSource = source
grdResults.DataBind()

End Sub
End Class


Hi again,

I tried this out and I'm getting the same error. This turns out to be a known bug in the April CTP of Atlas. To work around it, add this code to your Page's Load event handler:

Page.ClientScript.GetPostBackEventReference(this, String.Empty);

Thanks,

Eilon


that works. Thank you. btw ATLAS ROCKS!!

Appears to be an issue in the June CTP too... and if it wasn't for this post, I'd still have the issue.

Thanks guys


Correct, this was not fixed in the June CTP. For now the one line workaround should still be sufficient.

Thanks,

Eilon


In the case of nested UserControls, does this workaround apply? If so, where should the workaround go?

I have a page which contains a UserControl, which in turn contains another UserControl, which contains a GridView wrapped in an UpdatePanel. I tried adding this line to the page's Page_Load and the UserControl's Page_Load, but I get the same generic error:

Line: 10846
Char: 17
Error: Object required
FYI, the offending line appears to be the second one pasted below:

function destroyTree(element, markupContext) {

if (element.nodeType == 1) {


Any ideas?

slp004, can you please give more details as to what you're trying to do? It sounds like other people on this thread have this scenario working so I'm curious what's going on here.

Thanks,
Eilon


I was never able to figure out exactly what the problem was, but by breaking the page up into a number of smaller pages sharing a single master page it started working again. There were just way too many UserControls inside GridView inside FormView inside UserControls inside View areas inside show/hide panels... you get the idea.

I have exactly the same problem - in the same line

 function destroyTree(element, markupContext) {if (element.nodeType == 1) {

My page have three or four levels of nested user controls inside the update panel. The curious thing is the page with the same controls has worked before some change I did - now I am trying to figure it out.


Wow, I figured out the issue.

The error was caused because I have another updatepanel in this page - inside a user control, included in master page. The user control has Visible=false. This scenario causes the error. When I set the user control visibility to true, the error goes off.

The solution is setting the updatepanel (that is inside the user control) mode to Conditional. This solves the problem even if the user control is invisible.

HTH.


I had the same problem and I set all the update panels to conditional and it worked.