Showing posts with label function. Show all posts
Showing posts with label function. Show all posts

Wednesday, March 28, 2012

Atlas web service proxy undefined - bug or mistake?

Ok, here's the deal: I have javascript method that is called on the window's load event:

window.onload = function () { getDataForTable();};

Pretty striaghtforward, right? Well, when the getDataForTable method executes it calls an Atlas proxy method:

WebServices.Callbacks.CalendarFunctions.CheckDate(dateField.value, getDataForTable_Callback);
But when the script execute on load, I get an error stating that 'WebServices' is not defined. When I check the HTML output the Atlas javascript reference is there: "text/xml-script">"http://schemas.microsoft.com/xml-script/2005"> <references> <add src="http://pics.10026.com/?src=/Anthem/Callback/CalendarFunctions.asmx/js"/> "text/xml-script">"http://schemas.microsoft.com/xml-script/2005"> <references> <add src="http://pics.10026.com/?src=/Anthem/Callback/CalendarFunctions.asmx/js"/>
<script type="text/xml-script"><page xmlns:script="http://schemas.microsoft.com/xml-script/2005"> <references> <add src="/Anthem/Callback/CalendarFunctions.asmx/js" /> </references> <components /></page></script>
And when I hit the URL above the javascript there looks correct:
Type.registerNamespace('WebServices.Callbacks'); WebServices.Callbacks.CalendarFunctions=new function() {this.path = "http://localhost:64408/Project/Callback/CalendarFunctions.asmx"; this.appPath = "http://localhost:64408/Anthem/"; var cm=Sys.Net.ServiceMethod.createProxyMethod; cm(this,"CheckDate","date"); }

So... here is the question: why is this undefined? I think this is a bug because when I debug the script the ".asmx/js" script is not loaded in the script explorer window like other referenced scripts. So, any work arounds? How else do I get this call to execute during the window.onload event?

Thanks in advance for the help.

The best thing to do I think is to install something like fiddler, and verify that the request going out is in the form you expect, and that you are indeed getting the javascript that you get when you use the script include. Hopefully you'll see something obvious...

Actually I think this might be a timing issue, you are probably calling your onLoad before atlas has a chance to load its scripts, so you can verify that is the case in fiddler. Anyways you probably want to register your getDataForTable on pageLoad or using atlas's ApplicationOnLoad.

Hope that helps,
-Hao


You are right, I added the getDataForTable method after I posted this and it worked - it was just a timing issue. Thanks for the help though!

Monday, March 26, 2012

Atlas update panel problem

Hi,

I have page which main content is generated with function which returns HTML string:

<table>
<

tbody><tr><tdvalign="top"align="left">
<%=_contentOfPage%>
</td></tr></tbody>
</table>

Ant the function in code behind looks like:

public

string _contentOfPage;
publicvoid getContent(Int32 nDays)

{

String content;

content=.....//here is logic, which define content of the page

.......

_contentOfPage=content;

}

Everything works fine.

Because page has a lot of menues which I don't wont to refresh on every page submit, I included atlas update panel, which refresh only the main content of the page. It works with atlas too, page doesn't blink and only the main content is refreshed on page submit, like I wanted. But the interesting here is that refreshing only the part of the page(main content) takes about 3 seconds, while on the other hand, refreshing whole page takes only 1 second.
On all other pages, refreshing only content of the page works much faster, but here not. Any idea why?
Maybe because the length of _contentOfPage string is about 10000 signs or more?

Regards,S

HI,
as per my guess you are using lots of string concatenations to create the _contentOfPage,
that will take much of the server time,
try using stringBuilder which will be quite faster than the normal string concatenation

hope this will help
satish

Hi,

all I'm using for string concate is + sign between many if statements.
Maybe string builder is faster but the problem is not on the server.

The function on the server generates string in miliseconds.

The problem is obviously on client side.

Atlas call this method from client to server with ajay technology(XML HTTP) and than replace part of page on client with new string which gets from the server.(I think with INNERHTML method or similar).

If string is very long, like in my case, that procedure is slower than refresh a whole page.

I don't know if that is a rule or I missed something? Any idea?

regards,S

Saturday, March 24, 2012

Atlas stopped working when I added a javascript function.

Everything was working perfectly until I added a <script type="text/javascript"> section in the header and added a function. Now Atlas doesn't work any more. The page I created is simply a listbox, button and a label. When the button is pushed items are added to the list box and the label text is changed. With the javascript function in the code, nothing happens when I click the button. It works if the "hasOptions" function is removed. Is this a bug, or am I just doing something wrong?

Here is the aspx code:

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function hasOptions(obj) { if (obj != null && obj.options != null) { return true; } return false; } </script></head><body><form id="form1" runat="server"> <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /> <br /> <atlas:UpdatePanel ID="TableUpdatePanel" runat="server" Mode="Conditional"> <ContentTemplate> <asp:ListBox ID="listbox" runat="server"> <asp:ListItem Text="Hello"></asp:ListItem> </asp:ListBox> <asp:Button ID="button" runat="server" OnClick="button_Click" Text="Push Me!" /><br /> <asp:Label ID="label" runat="server"></asp:Label> </ContentTemplate> </atlas:UpdatePanel> </form></body></html>

And here is the Code Behind:

using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partialclass _Default : System.Web.UI.Page {protected void Page_Load(object sender, EventArgs e) { }protected void button_Click(object sender, EventArgs e) { listbox.Items.Add("Test"); listbox.Items.Add("Test"); listbox.Items.Add("Test"); listbox.Items.Add("Test"); listbox.Items.Add("Test"); label.Text ="This worked!"; }}

Hi,
I recently posted a message regarding your problem.
Try commenting out the IF statement with the && logical and operator,
that should fix your problem, seriously :)

I assume this is caused by a bug in the Atlas framework.
Every response returned from a partial update is treated as an XML document (you can use WebDevHelper to monitor the HTTP traffic and see this) and because '&' is a special xml charachter it confuses the Xml Parser and causes the Partial Rendering to fail.

I'm still waiting for a reply from for my post regarding this issue.

My Post:
http://forums.asp.net/thread/1267658.aspx

Have fun,
Lidor Pergament.