Sandip's Programming Zen

An attempt to share tech/coding experiences

Archive for April 2009

Cross-Domain Calls with IFrames

with 2 comments

We know that cross domain ajax calls are not possible from javascript, but come’on we live in virtual world and every law can be bent if we can (remember Morpheus from ultra cool Matrix 😉 )

Ok, I found  here on this nice guy’s blog under Cross-Domain Communication with IFrames.

I have actually used it and it works like a charm. I made a simple javascript function to get the anchor values , actually I used anchors to pass values using URL as if passing URL variable.

For example if I want to pass one variable then I would do :

http://www.yourdomain.com#action=foo#

For two variables :

http://www.yourdomain.com#action=foo#action2=foo2#

Two JS function, one for getting anchor value and second for resetting URL to it’s original form.

function getAnchor(name) {

url = window.location.href;
var varlen = name.length + 2;
var start = url.indexOf(“#” + name) + varlen;
var length = url.indexOf(“#”, start) – start;

var value = url.substr(start, length);
return value;
}

function resetAnchor() {
url = window.location.href;
var hash = url.indexOf(“#”)
if (hash >= 0) {
url = url.substr(0, hash);
window.location.href = url + “#”;
}
}

I would be happy to help if you have any troubles.

Advertisements

Written by Sandip

April 29, 2009 at 4:37 pm

Posted in Internet, Javascript

Tagged with ,

Maximize Firefox space for Gmail

leave a comment »

Gmail in Firefox is my primary work and personal email client, so I try to make as much space available as possible for Gmail.

I use Hide Menubar add-on which hides the main menubar, then I hide all other extra toolbars and keeping only Address bar (which minimum you need anyways).

Then, recently I found Gmail Compactor Add-On which make further space available for Gmail and make it look little better than standard interface. Make sure you have Greasemonkey add-on installed before you try.

Written by Sandip

April 29, 2009 at 4:10 pm

Posted in Internet, productivity

Tagged with , ,

Calling Asp.Net web service from PHP

with 20 comments

I just had a scenario where one of our client needs to consume our Asp.Net web service in their PHP host application.

Calling Asp.Net web service from PHP turned out to be easier then I thought. Here is how you can do.

First you need to download open source nusoap soap library, and put the lib folder under your application root directory. (I have renamed the folder name lib to nusoap in app directory).

The sample PHP code is below:

<?php
require_once(‘nusoap/nusoap.php’);

$client = new nusoap_client(‘http://www.yourdomain.com/service.asmx?WSDL&#8217;, ‘wsdl’,”, ”, ”, ”);

$err = $client->getError();
if ($err) {
echo ‘<h2>Constructor error</h2><pre>’ . $err . ‘</pre>’;
}
$param = ”;
$result = $client->call(‘functionName’, $param, ”, ”, false, true);

if ($client->fault) {
echo ‘<h2>Fault</h2><pre>’;
print_r($result);
echo ‘</pre>’;
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo ‘<h2>Error</h2><pre>’ . $err . ‘</pre>’;
} else {
// Display the result
echo ‘<h2>Result</h2><pre>’;
print_r($result);
echo ‘</pre>’;
}
}
?>

Of course, you can do much more than this, check out samples provided in downloaded nusoap source.

Written by Sandip

April 4, 2009 at 11:06 am

Posted in .Net, PHP, Programming

Tagged with ,

IE8 Developer Tools

leave a comment »

I use all three popular browsers (IE, FF and Chrome) but IE is still my primary browser for development. Till final version of IE8 released I used to use FF for testing my ajax application since Firebug add-on over there is doing nice job. IE8 has built in Developer Tools window now which covers almost all feature which Firebug has, plus there are some more. Very handy to use and does the job well.

 

Written by Sandip

April 3, 2009 at 6:19 am

Posted in Programming, Softwares

Tagged with

Backbase Ajax Framework with Asp.Net

with one comment

Since couple of months we are working on a new project based on Asp.Net 3.5 Framework which is using Backbase as a client rendering framework. Backbase provides a rich user interface which is independent of development platform. It sure has a learning curve but once you are through that phase you will see the real advantage of RAD.

If you are trying to use Backbase with Asp.Net and have any questions then I may try to answer them since we have passed that phase of sorting out initial hiccups.

Written by Sandip

April 3, 2009 at 3:06 am

Posted in .Net, Programming

Tagged with , ,

JQuery Validation Plugin and Asp.Net MVC

with 2 comments

Asp.Net MVC is a great framework. But, developers coming from Webforms background will find it little bit difficult not having a set of Validation controls which automatically validates form input by user. JQuery is a part of Asp.Net MVC application and I just found a nice JQuery plugin which fills the gap of Validator Controls of Webforms. It can be downloaded from here.

There are enough examples which coveres most of the routine validation needs and using it is as easy as Webforms validator controls.

Written by Sandip

April 2, 2009 at 10:33 am

Posted in .Net

Tagged with , ,