. Net componentart client calls server-side functions

Source: Internet
Author: User
What I encountered today is dizzy. My server-side method name is the same as the client-side method name, and then click the link to see "stack overflow ", I found it online. It seems that no one has encountered this problem. Later I checked it carefully and found that the name may be the same, so I immediately changed the name, the error "Object missing" is returned.
Later, I checked the information on the Internet and added a sentence to the Web. config file.
<Httphandlers>
<AddType ="Componentart. Web. UI. callbackhandler, componentart. Web. UI" Path ="*. Aspx" Verb ="*" />
</ Httphandlers >

Background:
[Componentartcallbackmethod]
Public String Getserverdatestring ()
{
Return Datetime. Now. Date. tostring ("Mmmm DD, YYYY ");
}

Front-end:
Alert (getserverdatestring ());

Specific can refer to the page: http://www.componentart.com/forums/ShowPost.aspx? Postid = 16637

Componentart callback 2006.1
Posted: 2/23/2006 12:37:47 pm
By: Miljan

Here is a brief overview of the new features and improvements of the componentart callback control for the web. ui 2006.1 release. our goal was to address common customer feature requests and make our callback framework more comprehensive.

Viewstate Maintenance

Starting with the 2006.1 release, you will be able to access the latest state of ASP. net controls contained on the page from your callback event handler. to enable this feature, simply set the poststate callback property to true.

Passing multiple parameters from the callback. Callback () client-side Method

We now support passing any number of simple-type parameters from the callback. Callback () call:

 
Callback1.callback ('Stephen ', 'hatcher', 30, true );

These parameters will be available in the new string collection event ARGs member "Parameters ":

StringFirstname = E. Parameters [0];StringLastname = E. Parameters [1];IntAge = convert. toint32 (E. Parameters [2]);BoolIsmanager = convert. toboolean (E. Parameters [3]);

Bypassing page Life Cycle

We have noticed that pointer of our MERs have been using 3rd party Ajax libraries side-by-side with our callback control in order to be able to send quick commands to the server without going through page life cycle. this was a way to efficiently execute server-side logic when complex rendering through callbacks was not needed. we now provide this functionality out of the box through a custom HTTP handler. to take advantage of it, do the following:

1. Specify the HTTP handler within the <system. Web> section of your web. config file:

 
<Httphandlers><AddType ="Componentart. Web. UI. callbackhandler, componentart. Web. UI" Path ="*. Aspx" Verb ="*" /></Httphandlers>

2. Mark all server-side methods you wish to expose on the client with the [componentartcallbackmethod] attribute. For example:

 
[Componentartcallbackmethod]Public StringGetserverdatestring (){ReturnDatetime. Now. Date. tostring ("Mmmm DD, YYYY ");}

Or

 
[Componentartcallbackmethod]Public IntServersideadd (IntNumber1,IntNumber2 ){ReturnNumber1 + number2 ;}

Note: You can have any number of simple-type arguments within the function signature.

3. You can then access those methods directly from your client-side JS Code:

 
Alert (getserverdatestring ());

Or

 
Alert ('server side: 2 + 2 = '+ serversideadd (2, 2 ));

Automatic refresh

Automatic callback Refresh can be enabled by setting the refreshinterval property to the desired time interval (in milliseconds ). you can use the client-side API to change the parameter (s) that are being sent to the server at any given time.

We hope that you will enjoy the new features of componentart callback 2006.1.

The componentart team
Helping you build something amazing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.