MieJowo.NET

Web Programming, SEO, and Anything On The Web.  

Calling web service with "Atlas" Beta

Wednesday, October 25, 2006

Since there are a lot of people asking how to call a web service in the new Beta version, I am going to post it here:
Testpage.aspx:

<%@ Page Language="C#" EnableViewState="true" AutoEventWireup="true" CodeFile="testpage.aspx.cs"
Inherits="testpage" %>

<!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>Test Page</title>
</head>
<body>
<form id="form1" runat="server" enableviewstate="true">
<atlas:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<atlas:ServiceReference Path="~/WebService.asmx" />
</Services>
</atlas:ScriptManager>
<input type="button" onclick="callWebService();" value="get time" />
<div id="Label">Loading ...</div>

<script type="text/javascript">
function callWebService()
{
WebService.GetServerTime(onComplete);
}

function onComplete(result)
{
$get('Label').innerHTML = result;
}
</script>
</form>
</body>
</html>



WebService.cs:

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;

/// <summary>
/// The client code will call this web service to get the server time
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[Microsoft.Web.Script.Services.ScriptService]
// Dont forget to include this scriptservice attribute
public class WebService : System.Web.Services.WebService {

public WebService () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public String GetServerTime()
{
return DateTime.Now.ToString();
}

However if you are calling PageMethods instead of WebService.asmx, you would have to:


"Replaced the instance page method in the CTP release with static page method support."


AND, you have to put your page method at the aspx-page level, eventhough you have code-behind files for the particular page (I think this is a bug). So for example:


<%@ Page Language="C#" EnableViewState="true" AutoEventWireup="true" CodeFile="testpage.aspx.cs"
Inherits="testpage" %>

<!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>Test Page</title>
<script runat="server">
[System.Web.Services.WebMethod]
public static String GetString()
{
return "This text is generated at: " + DateTime.Now.ToString();
}

</script>
</head>
<body>
<form id="form1" runat="server" enableviewstate="true">
<atlas:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<atlas:ServiceReference Path="~/WebService.asmx" />
</Services>
</atlas:ScriptManager>
<input type="button" onclick="callWebServer();" value="call web service" />

<div id="Label">Web Service Call Label</div>
<div id="Label2">Page Methods Label</div>
<script type="text/javascript">
function callWebServer()
{
WebService.GetServerTime(onComplete);
PageMethods.GetString(onCompletePageMethods);
}

function onComplete(result)
{
$get('Label').innerHTML = result;
}

function onCompletePageMethods(result)
{
$get('Label2').innerHTML = result;
}
</script>
</form>
</body>
</html>




The callWebServer function will call both the same webservice from the previous example and the GetString() page method.


That's all. I hope it helps anyone who needs it.


 

My Experience with the Beta release of "Atlas" part I

Monday, October 23, 2006

Well, well, well ... After playing with the Beta release today, I am very overwhelmed with the changes that they made from CTP to this Beta 1.0 version.

First in order is of course the changes in web.config file. At first I tried to manually rewrite the web.config file by copy-pasting the code from the beta's web.config. It turns out that this approach caused me tons of problem. The most annoying one is that standard <asp:???> tags didn't get recognized (even I rebuild and rebuild the website). Then, I just erased my web.config  and copy the web.config file from the beta and add some lines like <connectionstrings> or <system.net> into my web.config file. After that, I followed the AjaxToolkit guide in modifying web.config and Voila! the page compiled successfully with no errors.

Second in order is modifying my codes. This is where I spend most of the time since there are a lot of codes that I need to rewrite(modify) in order to adapt to the beta release.


          Yes, no more properties, just extender. Simplicity works well here.
          But, yikes, this is a lot of work!



I love the performance gained by the beta release. My pages are more responsive, and they load very fast (eventhough the site is not precompiled). And surely, MS needs to write better documentation and better migration document. I feel that I get very confused reading them. There are value-add, ajax-core (RTM), clientFX, serverFX, and AJAX CTP itself in this release.  Which one control which? Which one support xml-script? Which one don't? Other than that, Intellisense is gone at the content page-level (just for standard asp tags) when using updatepanel in masterpage that wraps the contentplaceholder. One solution to this is to change the "asp" prefix for the Ajax controls back to "atlas". I hope they will fix this soon.


 

"Atlas" Beta v1.0 finally released.

Saturday, October 21, 2006
Yes, yes, I know it is not "Atlas" anymore, but I am just too overly superbly irritated by the term AJAX, and too lazy to write ASP.NET AJAX, instead of just "Atlas", so I just decided to call it Atlas from now on =).
Anyway, the beta version of Atlas is very exciting news for me today. I personally haven't download and try the new beta (I have been out of town for a couple of days), but I have been skimming the new "manual" that makes me excited even more! They said that now Atlas support Safari (yay!), and the future release will support Opera browser as well. But I think the thing that got me most excited is:
"In the RTM release, the load event is also raised on partial page refresh scenarios, and you
can therefore run code in the pageLoad function to manipulate objects that may have been
recreated as a result of the round trip."
How excited!!!???!!! Well, may be not for you but It really is for me since my project got decent bugs in creating Atlas object/recreating Atlas object with partial page rendering(it really frustates me, k?). So, I am really hoping that this release will solve my problems.
More than that, Atlas team decided to change some of the aliases like $(element) shortcut for document.getElementById with $get to avoid collision with other javascript API (I think what they mean by this is the infamous prototype library).
There are really tons of change in this beta release. I don't want to discuss this just yet, but will do right after I downloaded and play with it tomorrow. It's 5:19 AM, so pardon my writing.

 

Testing Windows Live Writer

Saturday, October 14, 2006

Apparently, MS has a nice program to compose blog offline. This post is just to test the program.

Inserting code:

   1:  new Option(_firstItemText, "");

Insert map:


failed, it says that blogger does not support this. Too bad :(


Insert hyperlink:


Plug-in for inserting code


 


Now, Publishhh!!





 

You just have to see this, it's unbelievable!!

Thursday, October 05, 2006
Super Cool SWF
Now , this is still related to web right?!? ;)

 

3D animation of Optimus Prime

This is not related to web technology, but what the heck, this is worth posting.

 

Online word processor

Lately, with the buzz about "Ajax" technology, there are a lot of online word processing web-app (similar to Microsoft Word) that can be accessed from any computer that has internet access (and of course with web browser).
What make them interesting, is the fact that they are FREE! People like me who are too cheap to spend hundreds of dollar to buy expensive word processor apps are very "benefited" with these free web-apps (yay!).
Personally, I love the writely from Google, which in fact sometimes does not work perfectly (it's still in beta version). Other than writely, I also tried Zoho writer, which more "pretty" interface-point-of-view and more responsive (faster) than the writely. Why don't you give them a try and see it for yourself:

Google's Writely
Zoho Writer
Ajax Write

Man, I love free stuff .. =)

ps: actually, I used openoffice.org extensively too, since they are free and reliable =)

 

Web Hosting cost a lot of money?

Wednesday, October 04, 2006
Weleh, gue nggak ngerti kenapa web2 hosting di dunia ini begitu mahal-nya yak? Apa gue yang terlalu miskin buat bayar 10$ per month? Currently, gue lagi nyoba webhost4life.com dengan harga 10$/month. Menurut gue server mereka cukup responsive, customer service-nya oke-lah, meskipun kadang2 agak menyebalkan kalo ngejawab pertanyaan2 gue.
Misalnya: Suatu saat gue bilang kalo salah satu database gue nggak ke-enable service broker-nya. Tau mereka ngebales apa?
"The Service Broker should be enabled by default. Would you please give it a try on it? Please let us know if you have any further enquiries or concerns. Thank you."

Dohhh .. stupid answer man! I wouldn't ask if it is enabled already!
Sometimes, mereka jawab-nya cepet, sometimes it takes HOURS (I mean probably more than 10 hours) even though I set my inquiry with the most important priority.
Overall, I would recommend them for anyone who currently looking for a reliable yet cheap enough web hoster. You also got 2 MS-SQL2005 databases. Cool eh?

Check them here:
webhost4life.com

 

List of Map SDK from Google and Microsoft

For Virtual Earth map:
Virtual Earth Map
For Google Map:
Google Map

Personally, I love the Google Maps API because it's much faster than the VE. But since I use ASP.NET most of the time, I think I will use VE since it's better supported in Microsoft Ajax (I'm a big fan of the MS Ajax).
Both of the API support geotagging now, so you don't have to use third-partie services to convert street addresses to (Lat,Long).
Sadly, both of them do not have map of Indonesia, I hope they will address this soon.

 

Creating Ajax-enabled Website

Tuesday, October 03, 2006

Now, you can make your own "progress indicator" that matches your website theme. I've been using this website for a while, and It gives me impressive indicators. Enjoy!

ajaxload.info

 

My preference websites when choosing HTML color

Monday, October 02, 2006
Berhubung gue gak punya photoshop buat nentuin warna2 keren yang cocok buat website, gue selalu ke website2 ini buat nyari2 warna2 yang kira2 cocok buat website yang di design. Kalau anda2 ada yg punya resource lain yang lebih komplit. Please, let me know ... I would really appreciate it!

xmission.com
cloford.com

Archives

October 2006   November 2006   December 2006   June 2007   February 2008  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]