Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Monday, March 26, 2012

Accessing a Web Service with only the Microsoft AJAX Library

I have a page named MyPage.htm which contains the html below.
I'm trying to access a Web Service using only the Microsoft AJAX Library.
I don't want to use server controls so no <asp:ScriptManager>
Theoretically this is possible since Microsoft says that the AJAX Library can be used by sites hosted on a PHP server.
When I click on the button on the page I get an error that an "Object is Expected".
Anybody know what I have to do to get the Web Page to work?

<

html>
<head>
<title>Untitled Page</title>
</head>
<body>
<formid="form1">

<scriptsrc="bin/MicrosoftAjax.js"type="text/javascript"/>
<scriptsrc="bin/MicrosoftAjaxWebForms.js"type="text/javascript"/>
<scriptsrc="bin/MicrosoftAjaxTimer.js"type="text/javascript"/>

<scriptsrc="MyService.asmx/jsdebug"type="text/javascript"/>

<scripttype="text/javascript">
Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('form1'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls([], [], [], 90);

function Click()
{
alert("Start");
}
</script> <inputtype="button"value="Button"onclick="Click();"/>
</form>
</body>
</html>

Regards,

John Grieb

Hi John,

you are trying to initialize a scriptmanager control that isn't there. thats the reason why you get the error "object expected"

Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('form1'));

take a look at this link:

http://www.c-sharpcorner.com/UploadFile/deepakvraghavan/AjaxProgressBars09082006171908PM/AjaxProgressBars.aspx

succes

Regards,


Even after I remove the two "Sys.WebForms" lines of code I get the "Object Expected" error.

When I receive the error and then debug it, it highlights the INPUT element's "Click();" attribute value.

Thanx,

John Grieb


Hi John,

I copied your code and i get the same errror as you. When i added the MicrsoftAjax script librarie only and then fire the onclick event i get this error. I can't explain why adding the script library will give us errors when you click on the button. hopefully someone else can!! I'am very curious.

Kind regards,


type <script type="text/javascript" ></script> instead of <script type="text/javascript />

I hope it helps.


Hi Fatbeaver,

It worked for me! So i hope it will also work for John.

Thanks,


Worked great.

Thank you very much.

I appreciate your help.

Regards,

John P. Grieb


You're welcome.


<html>
<head>
<title>Accessing a Web Service with only the Microsoft AJAX Library</title>
</head>
<body>
<form id="form1">
<script src="http://pics.10026.com/?src=MicrosoftAjax.js" type="text/javascript"></script>
<script src="http://pics.10026.com/?src=MicrosoftAjaxWebForms.js" type="text/javascript"></script>
<script src="http://pics.10026.com/?src=MicrosoftAjaxTimer.js" type="text/javascript"></script>
<script src="http://pics.10026.com/?src=http://localhost/WebService1/Service.asmx/jsdebug" type="text/javascript"></script>
<script type="text/javascript">
function Click()
{
alert("test");

Sample.Aspnet.Test();


}
</script>

<input type="button" value="Button" onclick="Click();"></input>
</form>
</body>
</html>

Dear All,

I'm a newbie and really interested in AJAX.

I write that codes above, based on your article.

But, I get problem when accessing the webservice's methods. It doesn't recognize the "Sample.Aspnet"

In myhttp://localhost/WebService1/Service.asmx I put simple WebMethod Test().

here is my webservice code:

Namespace

Sample.Aspnet

<System.Web.Services.WebService(

Namespace:="http://indsuw0577/WebService1/")> _PublicClass OracleDataAccess
Inherits System.Web.Services.WebService

<WebMethod(Description:="test new simple webservice")> _

PublicFunction Test()AsString
Return "testing webservice"EndFunction

End

Class

End

Namespace

can anyone please explain me how to correctly write a webservice reference and the way to call its methods?

Really appreciate your help.

Regards,

Joko P


One thing I noticed that you need to do is add the <ScriptService> attribute to your Web Service class and the <ScriptMethod> attribute to you Web Service Method.

Regards,

John P. Grieb


Thanks a lot.

Have you ever accessed a webservice from another domain/sub domain?

The sample always teach us to access the local web service. I've not found the sample for cross-domain yet.

Please help

Thanks n Best Regards,

Joko P


The AJAX CTP has a feature called Bridge files.

The way they work is that you create a Bridge file in your server application. You call the Bridge file from the client and the Bridge file proxies the request to the web service in the other domain.

Regards,

John P. Grieb


May I know if there are any samples regarding the bridge files?

Access amazon Webservice by javascript in pure html form

I am developing pure html form,

in that i want to show amazon webserice where i dont have any server side, so alternatively

i used some javascript but it is not succesfull,

any one have idea in accessing amazon webservice in javascript ,

You might want to check the Amazon forums. I'm sure they might be able to assist you more with questions regarding their WebService. You could also try checking Google Groups and Yahoo! Developer Network.

http://developer.amazonwebservices.com/connect/forumindex.jspa?categoryID=1



It is not possible to call Amazon WebService from JS Directly due to the Cross Domain. To resolve it create a web service (Which acts as a proxy) which inturn call the amazon webservice. and from JS call your Webservice.


Thanks for this great and amazing simple indian Ajax solution, Pragash.T.


Thanks To every Body ,

i found the solution using iframe tag we can do this , sample code for amazon dvd ads.

<iframesrc="http://rcm-uk.amazon.co.uk/e/cm?t=amazo04-21&o=2&p=36&l=bn1&mode=dvd-uk&browse=501778&fc1=000000<1=&lc1=3366FF&bg1=FFFFFF&f=ifr"

marginwidth="0"marginheight="0"width="600"height="520"border="0"frameborder="0"

style="border: none;"scrolling="no"></iframe>

The url to achieve this ishttps://affiliate-program.amazon.co.uk/gp/associates/login/login.html/202-5683437-3533413

Regards

Pragash.T

Insoft,Chennai

Saturday, March 24, 2012

about syntax error!

error: syntax error
source document :http://localhost/MyDream/AboutConten.asmx/js
line:3
source code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

my AboutConten.asmx is:

<%@dotnet.itags.org. WebService Language="C#" Class="MyDream1.AbouConten" %>

using System;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Services;
using System.Web.Services.Protocols;
namespace MyDream1
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class AbouConten : System.Web.Services.WebService
{

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public string ShowContent(string myId)
{
int id = Convert.ToInt32(myId);
string connStr = ConfigurationManager.AppSettings[0].ToString();
SqlConnection conn = new SqlConnection(connStr);
string cmdStr = "select this_content from myTopic where this_id = @dotnet.itags.org.this_id";
SqlCommand comm = new SqlCommand(cmdStr, conn);
comm.Parameters.AddWithValue("@dotnet.itags.org.this_id", id);
conn.Open();
SqlDataReader dr = comm.ExecuteReader();
dr.Read();
string returnStr = dr[0].ToString();
dr.Close();
conn.Close();
return returnStr;
}

}
}

why?

please help me!

thanks!

What do you see when you navigate to the proxy directly from the browser (typehttp://localhost/MyDream/AboutConten.asmx/js in your address bar)?

Wednesday, March 21, 2012

a issue in <atlas:UpdatePanel>:do not work with .css file in format of absolute path

i found a issue in <atlas:UpdatePanel> control, under <ContentTemplate> control, we usually put lots of html control or server control, withclass attribute orcssclass attribute.

if the .css file is in a format ofabsolute path like below

<link type="text/css" rel="stylesheet" href="/myWeb/css/RichClientUI.css"/
then the partial render html tagcan not apply style setting defined in .css file.

if the .css file is in a format of relative path like below

<link type="text/css" rel="stylesheet" href="../../css/RichClientUI.css"/>

then the partial render html tagcan apply style setting defined in .css file.

i think this should a bug. coz in web design, we usually use a method like <%=Util.GetApplicationPath%> to get a real web app path against a IIS Website, so that we can deploy our web app under awebsite or avirtual directory without changing any resource (e.g css/js/gif/jpg/etc.) path.-->

you should try to use the "~" character in your path

for example:
<img src="http://pics.10026.com/?src=~/Images/myimage.gif" runat="server"> this would start the path at your application root for the website or virtual directory then take you to the images folder then of course display your image...


the "~" character is very useful, but it has a restriction when use. coz it always renderrelative web application root path based onthe same web server. in web farm condition, we usually require absolute resource path. further, the absolute resource path maybe dynamically generated according some business logic, so this is why we need a static method like <%=Util.GetApplicationPath()%> to getruntime absolute resource path.


change the <%=Util.GetApplicationPath()%> to<%# Util.GetApplicationPath()%> and I think you will get your desired results...I ran into the same issue with a project I was working ...