Showing posts with label docs. Show all posts
Showing posts with label docs. Show all posts

Wednesday, March 28, 2012

How do I manually trigger a nextpage for the data navigator?

So I'm already familiar with

http://atlas.asp.net/docs/util/srcview.aspx?path=~/atlas/samples/data/DataNavigator.src

and I can get it to work with buttons

but lets say we replaced those buttons with anchor tags instead?

oh wait I just figured it out. You don't do anything just chaging those elements to anchors and leaving them labeled as buttons in the XML markup causes the same behavior.. That's cool. why is that? My guess is because anchor and button both have the exact same onclick event which is the event that is raised.

OK well than for academic reasons how would I invoke a next page on a DataNavigator without a button like lets say from a hyperlink object or from javascript code?

I tried creating a datanavigator object in javascript code

var

pageNavigator =new Sys.UI.Data.DataNavigator($("pageNavigator"));

pageNavigator.initialize();

alert(pageNavigator.get_dataView());

pageNavigator.onBubbleEvent(

null,"nextpage");

but that didn't work at all.

All the DataNavigator control does is increment the pageIndex property on its associated DataView component. Knowing that, you can easily do the same thing:

var dataView = $object('dataView');
dataView.set_pageIndex(dataView.get_pageIndex() + 1);

Hope that helps.

--
Jason

Monday, March 26, 2012

How do I create static functions in JavaScript?

According to the docs online, the Error class has static functions

I can do the following
var err = Error.create(message, errorInfo);

without having to create a new object first. The documentation online does not explain how to create your own static functions using the MS approach.

Any ideas how I can create my own static functions?

Andre

try this:

var StaticClass =
{
//Static Variables
varInt : 0,
varString : '',
varArray : [],

StaticMethod1 : function()
{
//Accessing the Vars
StaticClass.varInt = 5;
},

StaticMethod2 : function()
{
//Calling another static method
StaticClass.StaticMethod1();
},
}


//Outside the Class:

StaticClass.StaticMethod1()

Hope this help.


When I use this approach, it seems that I can not register the class with ScriptManager anymore.
I have been digging around in MS Ajax code to see how MS creates static classes like the Error class.

Here is a snippet:

Error.__typeName = 'Error';
Error.__class = true;

Error.create = function Error$create(message, errorInfo) {

}

...

I tried to use this approach but it did not work.

Also I would be able to use a namespace instead of only a class name.


Yes you will be able to add it in ScriptManager, but won't be able to use registerClass. Unless you are not creating any component, behavior or control there is no need to use registerClass. To include namespace, add your name as you did for regular class and acess theclass with namespace.