Showing posts with label error. Show all posts
Showing posts with label error. Show all posts

Monday, March 26, 2012

Call web service in Javascript

I used to use Atlas for calling web service in Javascirpt and everything works fine. After I upgrade to Ajax beta1 it stopped working. The error message is the web service class is undefined. I have updated web.config file manually. I also tested this by creating a new ajax toolkit web site. The following is the code. It give me the same error? Anyone can help? I also get a error message for one page I had never met before with Atlas. The error message is error:Sys.ArgumentException: Value must not be null for controls and Behaviors. parameter name:element.

Thanks.

<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="microsoft.web" type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="Microsoft.Web.Configuration.ScriptingSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="webServices" type="Microsoft.Web.Configuration.ScriptingWebServicesSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="Microsoft.Web.Configuration.ScriptingJsonSerializationSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="profileService" type="Microsoft.Web.Configuration.ScriptingProfileServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="authenticationService" type="Microsoft.Web.Configuration.ScriptingAuthenticationServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="Microsoft.Web.UI" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="asp" namespace="Microsoft.Web.UI.Controls" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>
</controls>
<tagMapping>
<add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CompareValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CustomValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RangeValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RegularExpressionValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RequiredFieldValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="Microsoft.Web.UI.Compatibility.ValidationSummary, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</tagMapping>
</pages>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpHandlers>
<httpModules>
<add name="WebResourceCompression" type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>
<microsoft.web>
<scripting>
<webServices>
<!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
<!--
<jsonSerialization maxJsonLength="500">
<converters>
<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
</converters>
</jsonSerialization>
-->
<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
<!--
<authenticationService enabled="true" requireSSL = "true|false"/>
-->
<!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
and modified in Atlas applications, you need to add each property name to the setProperties and
getProperties attributes. -->
<!--
<profileService enabled="true"
setProperties="propertyname1,propertyname2"
getProperties="propertyname1,propertyname2" />
-->
</webServices>
</scripting>
</microsoft.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-ISAPI-2.0"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
</system.webServer>
</configuration>
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;

/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService {

public WebService () {

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

[WebMethod]
public string HelloWorld() {
return "Hello World";
}

}

<%@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>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" >
<Services >
<asp:ServiceReference Path="~/WebService.asmx" />
</Services>
</asp:ScriptManager>
<div>
<script type="text/javascript">
function GetString()
{
strResult = WebService.HelloWord(alert(),alert());
alert(strResult);
}
</script>
<input type="button" id="Button1" onclick="GetString();" value="Click" />
</div>
</form>
</body>
</html>

Hi there, I think you forgot to append [Microsoft.Web.Script.Services.ScriptService] attribute in your webservice class. For example of simple webservice call, see myblog post orajax.asp.net docs.


Got it. Thanks for your advice. It is not mentioned in the migration manual. I also find you can not use AJAX controls on hidden field, at least it is true for AutoComplete. This caused the problem I mentioned in the first post. Hope this will help someone.

Call Web Service : can not return dataset

Hi,

I got an error : "A circular reference was detected while serializing an object of type 'System.Globalization.Cultureinfo' when returning a dataset variable. It didn't happen when returning string.

It also run smoothly when using PageMethods of Atlas.

What's wrong with the code :

<Microsoft.Web.Script.Services.ScriptService()> _Public Class EmpServiceInherits System.Web.Services.WebServiceDim cnHimalayaAs New SqlConnection( _ ConfigurationManager.ConnectionStrings("HimalayaConnectionString").ConnectionString) <WebMethod()> _Public Function GetData(ByVal SearchCategoryAs String,ByVal NIKAs String)As Data.DataSetDim strSQLAs String Select Case SearchCategoryCase"Experience" strSQL = _"SELECT JobTitle,Company,Period,JobDesc DeptName FROM Ht_HRD_Experience " & _"WHERE NIK ='" & NIK & "'" Case "Training" strSQL = _ "SELECT Training,Category,Year,Host,Location FROM Ht_HRD_Training" & _ "WHERE NIK ='" & NIK & "'"Case"Education" strSQL = _"SELECT Education,School,Subject,YearGraduate FROM Ht_HRD_EmpEducation " & _ "WHERE NIK ='" & NIK & "'"End Select Dim sqlDaAs New SqlDataAdapter(strSQL, cnHimalaya)Dim dsDataAs New Data.DataSetIf cnHimalaya.State = Data.ConnectionState.ClosedThen cnHimalaya.Open()End If Try sqlDa.Fill(dsData)Return dsDataCatch exAs SqlExceptionThrow (New ApplicationException(ex.Message))Finally cnHimalaya.Close() dsData.Dispose()End Try End Function

thanks.

The problem is the DataSet is not natively supported by the JavaScriptSerializer.
In order to return a DataSet, you need to implement and register a custom converter for the DataSet in the config file.
There is a DataTable converter that comes with the ASP.NET 2.0 AJAX Futures November CTP that you can try to use.

HTH,

Maíra


Thanks.

Do you have article that expalin more detail with example how to do that?

Rgds


Instead of the dataset-- why don't you just return Xml?

That's good idea. I'll use it for the next project because there is a lot of code i have to change for the current project.

thanks anyway.


Instead of the dataset-- why don't you just return Xml?

Eh because using XML is pretty much a pain to use in JavaScript? <s> Wno wants to parse XML on the client side when you could instead get an object back instead?

As to the DataTable converter it's broken in Beta 2 - it's still in Beta 2 but it's returning a bogus object which appears to be an internal object. It is possible to use the converter and grab the JSON it generates but this will likely change in the future so it's probably not a good idea to use.

Here's an example (Client Code):

 function GetCustomerTable_Callback(Result) { var List = ListControl.get_element();// retrieve raw DOM element // *** This is a HACK workaround AJAX Beta 1 until Microsoft brings back a real // *** DataTable Converter currently it contains a string property that has be eval'd // *** String has trailing ( that must be trimmed off var Text= Result.dataArray.substring(0,Result.dataArray.length -1); var Table = eval( Text);// *** Clear the list firstfor (x=List.options.length-1; x > -1; x--) { List.remove(0); }for (x=0; x < Table.length; x++ ) { var Row = Table[x];// Mozilla needs to assign var option = document.createElement("option"); option.text = Row.CompanyName; option.value = Row.CustomerId;if ( window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) List.add(option);else List.add(option,null); } }
 

On the server (WebService or PageMethod):

 [WebMethod]public DataTable GetCustomerTable() { busCustomer Customer =new busCustomer();if (Customer.GetCustomerList() < 0)return null; DataTable dt = Customer.DataSet.Tables["TCustomerList"];return dt; }

You also need to register the DataTableConverter:

<microsoft.web><scripting><webServices><!-- Uncomment this line to customize maxJsonLength and add a custom converter --><jsonSerialization maxJsonLength="50000"><converters><add name="DataTableConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter"/></converters></jsonSerialization></webServices></scripting></microsoft.web>
 
+++ Rick -- 


I just downloaded AJAX v1.0 and now I get the circular reference error. I had the following code but I don't know what I have to change it to for my code to work properly.

<jsonSerialization maxJsonLength="50000"><converters><add name="DataTableConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter"/></converters></jsonSerialization>

Anyone have any ideas? Thanks.


Sorry, this does work. I forgot to download the January Futures CTP.

You usually get this error when you try to serialize a DataTable that has no custom converter registered for it.

The Ajax v1.0 does not contain the converters for the DataTable, they are part of the ASP.NET AJAX Futures January CTP. You need to install this and add a reference to in in your project.

Have you done this?

Maíra


Hi folks,

I'm getting the same problem and am "stuck", so I appreciate some help !

I installed the ASP.NET AJAX Futures January CTP msi file.

I added a reference to my \BIN

C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Futures January CTP\v1.0.61025\Microsoft.Web.Preview.dll

I put this in the web.config:

<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000">
<converters>
<add name="DataTableConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter"/>
</converters>
</jsonSerialization>
</webServices>

But still no go...

Do I have to MERGE the web_CTP.config with my standard AJAX 1.0 web.config or replace it entirely ?

It seems fairly complex to do so. Is their a pre-existing AJAX 1.0 / Jan CTP combined web.config available ?

Thanks, LA Guy


Hi again,

I missed these settings but still no go.

<jsonSerialization maxJsonLength="50000">
<converters>
<add name="DataSetConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter, Microsoft.Web.Preview"/>
<add name="DataRowConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataRowConverter, Microsoft.Web.Preview"/>
<add name="DataTableConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter, Microsoft.Web.Preview"/>
</converters>
</jsonSerialization>

Thanks, LA Guy


I'm getting the same problem and am "stuck", thk


Guys I'm getting it working fine with the January CTP with the

<system.web.extensions>
<scripting>
<webServices>
<!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
<jsonSerialization>
<!--<jsonSerialization maxJsonLength="500">-->
<converters>
<add name="DataSetConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter, Microsoft.Web.Preview, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="DataRowConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataRowConverter, Microsoft.Web.Preview, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="DataTableConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter, Microsoft.Web.Preview, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</converters>
</jsonSerialization>

Config setting and the reference added to the Preview dll.

Can we assume these implementations would be included in the future MS Ajax releases bcoz I'm going to use these JSON converters for a real product.


I am running the latest AJAX 1.0 product set. When I apply the changes as mentiond above, I no longer am able to access my webmethod. I get a javascript error that states that method is undefined? when I comment the section above, I get circular reference encountred (since I am trying to return a datatable)

What am I doing wrong?

Call to WebService not working...

I am getting this error 'Microsoft JScript runtime error: 'wsWeatherFeed' is undefined. It's just a basic call to a webservice via the asp:ScriptManager tag. Can someone help me point out what I might be doing wrong?

.Aspx file:

<scriptlanguage="javascript"type="text/javascript">

function fnImgMouseOver(e){

wsWeatherFeed.set_timeout(40000);

wsWeatherFeed.fnGetWeatherData(e,callback_fnImgMouseOver,fnGetWeatherDataError);

}

function callback_fnImgMouseOver(result){

alert(result);

}

function fnGetWeatherDataError(err){

alert("Here is the error: " + err.error);

}

</script>

<further down>

<asp:ScriptManagerID="ScriptManager1"runat="server">

<Services>

<asp:ServiceReferencePath="wsWeatherFeed.asmx"/>

</Services>

</asp:ScriptManager>

.Asmx file

<%@dotnet.itags.org.WebServiceLanguage="C#"CodeBehind="~/App_Code/wsWeatherFeed.cs"Class="wsWeatherFeed" %>

.cs WebService file:

using System;

using System.Web;

using System.Web.Services;

using System.Web.Services.Protocols;

using System.Collections;

using System.Xml;

using System.Xml.XPath;

using System.Xml.Xsl;

[WebService(Namespace ="http://tempuri.org/")]

[WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]

[System.Web.Script.Services.ScriptService()]

publicclasswsWeatherFeed :WebService {

public wsWeatherFeed () {

//Uncomment the following line if using designed components

//InitializeComponent();

}

[WebMethod]

protectedstring fnGetWeatherData(String strData)

{

return strData

}

}

I got this to work with VB.Net but I guess I just lost something along the way, can anyone provide a clue?

J

Ok I got it. The reason why my js couldnt get to my webservice class was that my web service method fnGetWeatherData was intially set to 'protected' instead of 'public'.

Anyway, I didnt want anyone to spend any time troubleshooting this if I can answer it quick enough myself.

J

Call Remote WebService. "Parameter count mismatch" Error

Hello All, I.m using AJAX for call remote WS. For example WS placed on localhost.

1) Here some web methods from WS (AJAXBridgeService WebSite)

  
 [WebMethod]
public string HelloWorld()
{
return"Hello World";
}

[WebMethod]
public Account GetAccountByID(int ID)
{
return new Account();
}

[WebMethod]
public string GetStringByID(int ID)
{
return ID.ToString();
}

[WebMethod]
public int GetIntByID(int ID)
{
return ID;
}

  2) i generated proxy class with wsdl utility and place it in App_Code (AJAXBridge WebSite) 
 3) i created asbx file

<bridge namespace="AJAXTest" className="Class">
<!-- change url to required --> <proxy type="AJAXTest.Service, App_Code"
serviceUrl="http://localhost/AjaxBridgeService/Service.asmx" /
<method name="HelloWorld"/
<method name="GetAccountByID">
<input>
<parameter name="ID"/>
</input>
</method
<method name="GetStringByID">
<input>
<parameter name="ID"/>
</input>
</method
<method name="GetIntByID">
<input>
<parameter name="ID"/>
</input>
</method>
</bridge>

 
4) then i used the following HTML+JS code 
<asp:ScriptManager ID="PageScriptManager"
runat="server"
LoadScriptsBeforeUI="False"
EnablePartialRendering="True">
<Services>
<asp:ServiceReference Path="bridges/bridge.asbx" />
</Services
<Scripts>
<asp:ScriptReference Path="bridge.js" />
</Scripts>
</asp:ScriptManager
<a href="javascript:void(0);" onclick="javascript:Click1();">Click Me 1</a> <span id="span1"></span>
<br/>
<a href="javascript:void(0);" onclick="javascript:Click2();">Click Me 2</a> <span id="span2"></span>
<br/>
<a href="javascript:void(0);" onclick="javascript:Click3();">Click Me 3</a> <span id="span3"></span
JS:
function Click1()
{
AJAXTest.Class.HelloWorld({}, OnComplete1, onError1);
}

function OnComplete1(obj)
{
var span = $get('span1');
span.innerHTML = obj;
}

function onError1(obj)
{
var span = $get('span1');
span.innerHTML = "Error:" + obj.get_message;
}

function Click2()
{
AJAXTest.Class.GetAccountByID({"ID" : 1}, OnComplete2, onError2);
}

function OnComplete2(obj)
{
var span = $get('span2');
span.innerHTML = obj;
}

function onError2(obj)
{
var span = $get('span2');
span.innerHTML = "Error:" + obj.get_message();
}

function Click3()
{
AJAXTest.Class.GetStringByID({"ID" : 100}, OnComplete3, onError3);
}

function OnComplete3(obj)
{
var span = $get('span3');
span.innerHTML = obj;
}

function onError3(obj)
{
var span = $get('span3');
span.innerHTML = "Error:" + obj.get_message();
}

 
5) After press "Click Me 1" link, i invoke HelloWorld and it returned string value to span,
then if i press "Click Me 2" or "Click Me 3"links, i got OnError and error message with "Parameter count mismacth".
There is a topic like thishttp://forums.asp.net/t/1136077.aspx
Does have anybody any information about call bridge with parameters? 
 
 
 
 
 



  
 
  


You may remove the jason-styled parameters.

In your javascript service invocation you may send the number only before the callbacks at this syntax:

AJAXTest.Class.GetAccountByID(1, OnComplete2, onError2);
(instead of AJAXTest.Class.GetAccountByID({"ID" : 1}, OnComplete2, onError2); )

Note: Don't send date this form, (you may send string instead and parse it on server side)


Vinija:

You may remove the jason-styled parameters.

In your javascript service invocation you may send the number only before the callbacks at this syntax:

? AJAXTest.Class.GetAccountByID(1, OnComplete2, onError2);
(instead of? AJAXTest.Class.GetAccountByID({"ID" : 1}, OnComplete2, onError2); )

Note: Don't send date this form, (you may send string instead and parse it on server side)

?

There we call remote web service via bridges technology, which demand of JSON input parameter.

I'm mot realy familiar with JSON syntax but according to the article you've referenced to, it seems that
you shouldn't write ID in quotation marks but simply write the word ID.

I'm not sure if it'll help you (you may have tried it already) but this is what I can see that by be wrong.

About the JSON input parameter, shouldn't the AJAX engine imlement the JSON serialization without
you actually write the parameters JSON styled?


<method name="HelloWorld"/
<method name="GetAccountByID">
<input>
<parameter name="ID"/> see here ...the parameter name is the same for all !!!has it got to be different?try and see it does not knw which parameter to invoke when clicked ,probably this might be an error
</input>
</method
<method name="GetStringByID">
<input>
<parameter name="ID"/>
</input>
</method
<method name="GetIntByID">
<input>
<parameter name="ID"/>
</input>
</method>
</bridge>

cheers

shankar

Saturday, March 24, 2012

call global javascript function - help

hi forum,

i want to call a global javascript function from

<invokeMethodmethod="gobalFunction"/>

it's throw an error of no instance

i have readed the good page at

http://www.wilcob.com/Wilco/Atlas/DeclarativelyInvokingJavaScript.aspx

but this

<atlas:ButtonID="btnServer"runat="server"Text="call">

<behaviors>

<atlas:ClickBehavior>

<ClickHandler="globalFunction"/>

</atlas:ClickBehavior>

</behaviors>

</atlas:Button>

just doesn't compile, i guess because is december ctp. I'm using January ctp

i tried the client way i have seen at the same page

<click handler="globalFunction"/>

or

<ClickBehavior click="globalFunction"/>

there is no error but the function is not called.

So i want to try the last way

<ClickBehavior>
<Click>
<Actions>
<InvokeMethodAction Target="myWindow" Method="test" />
</Actions>
</Click>
</ClickBehavior>


but don't know how to set the id 'myWindow' to link the method call.

Finally, i'm here asking if someone can show me a way to call a global function from an atlas client component.

thanks

oops

just have to say thanks to the atlas team for their work. I can't understand yet all the power in this framework, but it looks great

hector

It's me again,

no replies, may be the question was not in the right way or it's so stupid that nobody want to reply it.

I just started with atlas and my programming level is low (being kind to me), but it's hard, there is not docs and when you find some pieces often is not working against the current release.

As a suggestion for the forum i would like at the top section a page with useful links about atlas ex.

http://www.nikhilk.net/

http://www.wilcob.com/Wilco/Atlas.aspx

http://weblogs.asp.net/bleroy

so people can add good links to a central location easy to find.

OK. this post it's to show a solution for the problem i posted before.

----

Type.registerNamespace("HostChan");

HostChan.HostSite =function() {

HostChan.HostSite.initializeBase(this, [true]);

var _hostApp = window.external;

this.getDescriptor =function() {

var td = HostChan.HostSite.callBaseMethod(this,'getDescriptor');

td.addProperty('hostApp', Object,true);

td.addMethod('sayHello');

return td;

}

this.initialize =function() {

HostChan.HostSite.callBaseMethod(this,'initialize');

eval('window.' +this.get_id() +' = this;');

}

this.get_hostApp =function() {

return _hostApp;

}

this.sayHello =function() {

alert("hello");

}

}

Type.registerClass('HostChan.HostSite', Web.Component);

Web.TypeDescriptor.addType('gdc','hostSite', HostChan.HostSite);

--

<scripttype="text/xml-script">

<page xmlns:script="http://schemas.microsoft.com/xml-script/2005" xmlns:gdc="gdc">

<components>

<gdc:hostSite id="theHost" />

<button targetElement="btnJs">

<click>

<invokeMethod target="theHost" method="sayHello" />

</click>

</button>

</components>

</page>

</script>

-------

I created a custom component derived from

Web.Component

added properties and methods and override the

initialize

function where i it create a global object named instance with the id supplied in the xml script

I liked before to create javascript objects better than global functions but i still would like some one show me the way to call a global javascript function from the

invokeMethod

tag in the xml script

sorry for the long post

have a happy day

Wednesday, March 21, 2012

CalendarExtender, ValidatorCallout, or FilteredTextboxExtender Causing Error in Partial Po

Hello everyone,

I really enjoy working with the Controls Tookit. The ValidatorCallout is especially nice to use. I'm trying to use a drop-down list to cause a partial postback in an updatepanel. When the ddl selectionchanges, it is supposed to pull database information and then populate some textfields. These textfields have been wrapped in sometimes all three of the extenders listed above. When I change the selection on the ddl, I get a Javascript error:

Line: 5909 Char: 12 Sys.ArgumentUndefinedException: value cannot be undefined. Parameter name: id.

I know this is in one of the javascript files that get attached to my code when it gets built. I'm trying to figure out what's the root cause. Do you think the page is trying to validate the empty textfields? The validatorcallouts are not firing, if that is the case. I've attached my aspx code. Let me know if the code-behind would be useful as well.

Thanks for any help you can provide.

<asp:ScriptManager runat="server" ID="smModify" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <table> <tr> <td colspan="3" style="font-size: x-large"><b>Common Fields</b></td> </tr> <tr> <td class="spacer"> </td> <td align="right">Branch Number:</td> <td> <asp:DropDownList ID="ddlSharedBranches" runat="server" AutoPostBack="True"> </asp:DropDownList><%--<asp:TextBox ID="txtBranchNumber" runat="server" MaxLength="5"></asp:TextBox> <ajax:FilteredTextBoxExtender ID="ftxteBranchNumber" runat="server" TargetControlID="txtBranchNumber" FilterType="Numbers"> </ajax:FilteredTextBoxExtender> <asp:RequiredFieldValidator ID="rfvBranchNumber" runat="server" display="none" ErrorMessage="Please enter data in the form #####." ControlToValidate="txtBranchNumber"></asp:RequiredFieldValidator> <ajax:ValidatorCalloutExtender ID="vceBranchNumber" runat="server" TargetControlID="rfvBranchNumber" HighlightCssClass="validateCallout"> </ajax:ValidatorCalloutExtender>--%> </td> </tr> <tr> <td class="spacer"> </td> <td align="right">Branch Name:</td> <td> <asp:TextBox ID="txtBranchName" runat="server" MaxLength="30"></asp:TextBox> <asp:RequiredFieldValidator ID="rfvBranchName" runat="server" display="none" ErrorMessage="Please enter the Branch's Name here." ControlToValidate="txtBranchName"></asp:RequiredFieldValidator> <ajax:ValidatorCalloutExtender ID="vceBranchName" runat="server" TargetControlID="rfvBranchName" HighlightCssClass="validateCallout"> </ajax:ValidatorCalloutExtender> </td> </tr> <tr> <td class="spacer"> </td> <td align="right">Bank:</td> <td> <asp:DropDownList ID="ddlBank" runat="server"> <asp:ListItem Text="Carolina First" Value="1"></asp:ListItem> <asp:ListItem Text="Mercantile Bank" Value="6"></asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td colspan="3"> <asp:CheckBox ID="cbTOSS" runat="server" AutoPostBack="true" />Modify TOSS Fields </td> </tr> <tr> <td colspan="3"> <asp:Panel ID="pnlTOSS" runat="server"> <table> <tr> <td colspan="3"><b>TOSS Specific Fields</b></td> </tr> <tr> <td class="spacer"> </td> <td align="right">Region:</td> <td> <asp:DropDownList ID="ddlAddBranchTOSSRegion" runat="server"> </asp:DropDownList> </td> </tr> <tr> <td class="spacer"> </td> <td align="right">Number of Tellers:</td> <td> <asp:TextBox ID="txtAddBranchTOSSNumTellers" runat="server" MaxLength="2"></asp:TextBox> <ajax:FilteredTextBoxExtender ID="ftxteAddBranchTOSSNumTellers" runat="server" TargetControlID="txtAddBranchTOSSNumTellers" FilterType="Numbers"> </ajax:FilteredTextBoxExtender> <asp:RequiredFieldValidator ID="rfvAddBranchTOSSNumTellers" runat="server" display="none" ErrorMessage="This field is required." ControlToValidate="txtAddBranchTOSSNumTellers"> </asp:RequiredFieldValidator> <ajax:ValidatorCalloutExtender ID="vceAddBranchTOSSNumTellers" runat="server" TargetControlID="rfvAddBranchTOSSNumTellers" HighlightCssClass="validateCallout"> </ajax:ValidatorCalloutExtender> </td> </tr> <tr> <td class="spacer"> </td> <td align="right">Sales FTE:</td> <td> <asp:TextBox ID="txtAddBranchTOSSSalesFTE" runat="server" MaxLength="7"></asp:TextBox> <ajax:FilteredTextBoxExtender ID="ftxteAddBranchTOSSSalesFTE" runat="server" TargetControlID="txtAddBranchTOSSSalesFTE" FilterType="Custom" ValidChars=".0123456789"> </ajax:FilteredTextBoxExtender> <asp:RequiredFieldValidator ID="rfvAddBranchTOSSSalesFTE" runat="server" display="none" ErrorMessage="This field is required." ControlToValidate="txtAddBranchTOSSSalesFTE"> </asp:RequiredFieldValidator> <ajax:ValidatorCalloutExtender ID="vceAddBranchTOSSSalesFTE" runat="server" TargetControlID="rfvAddBranchTOSSSalesFTE" HighlightCssClass="validateCallout"> </ajax:ValidatorCalloutExtender> </td> </tr> <tr> <td class="spacer"> </td> <td align="right">Effective Date:</td> <td> <asp:TextBox ID="txtAddBranchTOSSEffectiveDate" runat="server" MaxLength="10"> </asp:TextBox><asp:Image ID="imgCalendar" runat="server" ImageUrl="images/cldrimg.png" /> <ajax:FilteredTextBoxExtender ID="ftxteAddBranchTOSSEffectiveDate" runat="server" TargetControlID="txtAddBranchTOSSEffectiveDate" FilterType="custom" ValidChars="0123456789//"> </ajax:FilteredTextBoxExtender> <ajax:CalendarExtender ID="cldreAddBranchTOSSEffectiveDate" runat="server" TargetControlID="txtAddBranchTOSSEffectiveDate" Animated="true" PopupButtonID="imgCalendar"> </ajax:CalendarExtender> <asp:RequiredFieldValidator ID="rfvAddBranchTOSSEffectiveDate" runat="server" display="none" ErrorMessage="This field is required." ControlToValidate="txtAddBranchTOSSEffectiveDate"> </asp:RequiredFieldValidator> <ajax:ValidatorCalloutExtender ID="vceAddBranchTOSSEffectiveDate" runat="server" TargetControlID="rfvAddBranchTOSSEffectiveDate" HighlightCssClass="validateCallout"> </ajax:ValidatorCalloutExtender> </td> </tr> </table> </asp:Panel> </td> </tr> <tr> <td colspan="3"> <asp:CheckBox ID="cbTSFGu" runat="server" AutoPostBack="true" />Modify TSFGu Fields </td> </tr> <tr> <td colspan="3"> <asp:Panel ID="pnlTSFGu" runat="server"> <table> <tr> <td colspan="3"><b>TSFGu Specific Fields</b></td> </tr> <tr> <td class="spacer"> </td> <td align="right">Region:</td> <td> <asp:DropDownList ID="ddlAddBranchTSFGuRegion" runat="server"> </asp:DropDownList> </td> </tr> </table> </asp:Panel> </td> </tr> </table>


I was able to narrow it down to the ValidatorCallout causing the error.

I'm able to run the ddl one time to fill in the fields. It results in the error described above, but the fields fill in. If I try to select another branch from the dropdown list above, the error keeps the postback from going. So it's a one-shot deal, otherwise you have to reload.

Removing the updatepanel removes all of the errors and it works perfectly, but the tell-tale page flicker is back.

CalendarExtender throws error after manual textbox input

Hya,

I'm encountering a few issues with the calendarextender on the new RTM, i just have a textbox, a image, and the extender on a blank page:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:Label ID="lblPublishDate" runat="server" AssociatedControlID="publish_date" Text="Publish Date:"></asp:Label><br /><asp:TextBox ID="publish_date" runat="server" CssClass="frm_textbox" Width="150px" ValidationGroup="SearchLatestNews"></asp:TextBox><asp:Image runat="Server" ID="imCalendar" CssClass="vm" ImageUrl="/images/calendar.png" /><br /><em>e.g. 01 Jan 2007</em><ajaxToolkit:CalendarExtender ID="extCalendar" runat="server" TargetControlID="publish_date" PopupButtonID="imCalendar" />


The data format is dd MMM yyyy and i want to allow the user to manually input the data aswell as picking it. and i get the following error in both IE and FF:

Error: [Exception... "'Sys.ArgumentUndefinedException: Sys.ArgumentUndefinedException: Value cannot be undefined.
Parameter name: array' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "<unknown>" data: no]

Is anyone experienced the same issue? Is there a known workaround?


Kind Regards,

P.

Sorry i was doing some tests, and i accidentally removed the format="dd MMM yyyy" from the code..

CalendarExtender Not Working

I haven't read about this anywhere, but the CalendarExtender hasn't been working for me for some time.

I keep getting the following javascript error when i attempt to Pop it up:

Sys.ArgumentNullException:Value cannot be null. Parameter name: classNameI just picked up 14100 off of CodePlex and can confirm the same thing with the development branch.
As far as i can tell this began happening after the 11645 changes
There is a calendarextender?

CalendarExtender memory Leaks

I'm having issues with the CalendarExtender not disposing when it is done.

Here is what the error looks like

-- d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs 00000000 push edi 00000001 push esi 00000002 push ebx 00000003 mov esi,ecx 00000005 mov ebx,edx 00000007 cmp dword ptr ds:[03847ED4h],0 0000000e je 00000015 00000010 call 7278C609 00000015 mov edx,5C358ED8h <-- error here 0000001a mov ecx,51EEB38h 0000001f call 7278F006 00000024 mov edx,ebx 00000026 mov ecx,esi 00000028 call 54A68100 0000002d mov ecx,esi 0000002f call dword ptr ds:[051EEE2Ch] 00000035 mov edi,eax 00000037 test edi,edi 00000039 je 0000005D 0000003b mov ecx,esi 0000003d call dword ptr ds:[051EEE48h] 00000043 mov edi,eax 00000045 mov ecx,edi 00000047 mov eax,dword ptr [ecx] 00000049 call dword ptr [eax+00000090h] 0000004f mov edi,eax 00000051 test edi,edi 00000053 je 0000005D 00000055 mov ecx,esi 00000057 call dword ptr ds:[051EEE70h] 0000005d nop 0000005e pop ebx 0000005f pop esi 00000060 pop edi 00000061 ret

Here is the CalendarExtender in question:

<cc1:CalendarExtender ID="CalendarExtender6" runat="server" TargetControlID="ASDTextBox" Format="dd-MMMM-yyyy"> </cc1:CalendarExtender>

I originally had a format of dd-MMM-yyyy and was having the problem. I saw this post : http://forums.asp.net/t/1067282.aspx

So I changed my formating. no luck

Hi Jebrik,

Would you please post ithere? Our developers will evaluate them seriously and take them into consideration when designing future release of the product. Thanks.

Best regards,

Jonathan