Showing posts with label class. Show all posts
Showing posts with label class. Show all posts

Wednesday, March 28, 2012

Extenders: Using complex types inside my Behavior.js javascript?

I added some complex types to my PanelExtender.vb that represents lists of numerical values:

Public Class ChartPanelExtenderInherits ExtenderControlBase(Of ChartPanelProperties, Panel)Private _dataseriesAs ArrayListPublic Sub AddSerie(ByVal p_serieAs DataSerie) _dataseries.Add(p_serie)End Sub Public Class DataSeriePrivate _valuesAs ArrayListPrivate _nameAs String Public Sub New(ByVal serieNameAs String) _name = serieNameEnd Sub Public Sub AddValue(ByVal p_valueAs Integer) _values.Add(p_value)End Sub Public Property Name()As String Get Return _nameEnd Get Set(ByVal valueAs String) _name = valueEnd Set End Property End Class End Class
Although I can easily create and add data series to my PanelExtender on the server-side (aspx page):

 Public Sub Page_load(ByVal sender As Object, ByVal e As EventArgs) Dim mySerie As New ChartPanelExtender.DataSerie("MyData") mySerie.AddValue(2) mySerie.AddValue(3) mySerie.AddValue(4) ' this is the name of the control in the page ChartPanelExtender1.AddSerie(mySerie) End Sub

I cannot figure how to access this data inside my javascript PanelBehavior.js code?
Do I need to somehow serialize/deserialize it manually?
How can I pass this data to the PanelBehavior.js script?

Any suggestions would be appreciated including telling me I am way off and giving an alternative hehe. All I really need is a way to pass data series to the behavior script.

Thanks in advance

PascalThe typical way of getting information to a JS behavior is via one of its properties. Your server code might transform the list somehow so that it can be safely passed to the behavior in a string (ex: [a, b, c] -> "a,b,c") and then the behavior can transform the string back into the data it represents. We're considering adding JSON support to this scenario so that more complex data types could be communicated more easily, but haven't done so yet, so the ->string-> technique may be a good choice for now. Hope this helps!
Okies, will see if JSON gets added in next CTP.
Thanks for the reply :)

Pascal

Extended class and debug="false"

Does anybody know why the initalizeBase() function fails to extend the current class with the base-class's methods when debug is set to false?

It seems that when in debug mode you are allowed to do this use the parent class' initializeBase function in the constructor. This causes an error with debug=false.

By using the subclass's own initalizeBase, this all works like a charm.

Extend the AutoComplete Class

Is there a way for me to pass an additional parameter to the webservice that returns an array of strings for use in an autocomplete textbox?

Basically, I'd like to add an ID field that queries a database for strings that match the ID and the prefixText.

It should look something like this:

[WebMethod]publicstring[] GetAllNames(string prefixText,int count,int resourceId)

{

ArrayList filteredList =newArrayList();SqlParameter[] p = {newSqlParameter("@dotnet.itags.org.intResourceId", resourceId),newSqlParameter("@dotnet.itags.org.strName", prefixText)

};

SqlDataReader dr =SqlHelper.ExecuteReader(Common.GetDBConnectionString(),

System.Data.

CommandType.StoredProcedure,"prSelectOrganizationPersonnel", p);while (dr.Read())

{

filteredList.Add(dr[1].ToString());

}

return (string[]) filteredList.ToArray(typeof(string));

}

Thanks!

Hi,

sorry, no way to pass additional parameters using the auto-complete stuff at the moment. I can't count the number of times this requirement has been asked, thus I hope the team will provide an improved auto-complete mechanism in the next release.

Monday, March 26, 2012

Exposing Web Services defined in class libraries

I have a class library (or will have) that defines a bunch of web services. I can reference Atlas if necessary. How do I expose all these web services to Atlas via IIS/ASP.Net. In other words, I do *not* want the code for my web services to be in the web project, I want them to be in an external project and optimally just included with a single line for all services, or a line per service if necessary.

Thanks.

All you need to do is to add your assembly as a reference to the web project and then add it to the ScriptManager service reference as following:

 <atlas:ScriptManager ID="ScriptManager1" runat="server" > <Services> <atlas:ServiceReference Type="namepsace.typename" /> </Services></atlas:ScriptManager>

Replace the bold text with the type name of your web service.


Seems that this has changed since way back when... How do I reference a service in a class library now? How do I then hook it up to an extender, e.g. an AutoCompleteExtender?

Thanks.

Saturday, March 24, 2012

Example of using ControlBase class

As I've learened from ASP.NET AJAX IN ACTION AJAX toolkit also allow as to create Script Controls (AJAX Extension) with ControlaBase class (Extenders are inherited from ExtenderBase). Why ajax toolkit provide only extender template? Have anybody used ControlBase class?

Hi,

Which ControlBase class are you referring to? There is only a ExtenderControlBase class that acts as the base class.

The main purpose of the template is to provide a better starting point for creating an Extender, some necessary logics has been added in the base class. Of course, you may choose a different base class, event Control class. But developers will have to do more in this case, and it's more error-prone.


Raymond Wen - MSFT:

Which ControlBase class are you referring to?

On the server side, the Ajax Control Toolkit defines two base classes: ExtenderControlBase and ScriptControlBase. The ExtenderControlBase class derives from the ExtenderControl class and is used to create extenders. The ScriptControlBase class inherits from the ScriptControl class and is used to create script controls.

On the client side, the Microsoft Ajax Library provides the Sys.UI.Behavior and Sys.UI.Control classes for creating visual components. In turn, the Toolkit API provides base classes that encapsulate additional functionality for creating behaviors and controls. These classes are called BehaviorBase and ControlBase.

These are two quotations from Manning ASP.NET AJAX IN ACTION