Basic use of devexpress Asp.net (4) aspxcallbackpanel

Source: Internet
Author: User
Aspxcallbackpanel is mainly used to asynchronously refresh the content in callbackpanel. There are many ways to achieve this effect, such as updatepanel in Microsoft Ajax control, which is more convenient and easy to use than this method.
In the following example ListBox , Callback from the client Aspxcallbackpanel To update Aspxcallbackpanel Internal Multiview Control display information.

First, place an aspxcallbackpanel control on the page and set the clientinstancename attribute to "callbackpanel ".
CodeAs follows:

Code
  < Dxcp: aspxcallbackpanel ID = "Aspxcallbackpanel" Runat = "Server" Clientinstancename = "Callbackpanel"
Oncallback
= "Aspxcallbackpanel_callback" Width = "100%" >
</ Dxcp: aspxcallbackpanel >

Set the clientinstancename attribute of aspxcallbackpanel and register an oncallback server event. as mentioned in the previous section, the aspx system controls of devexpress have the same asynchronous update methods, so aspxcallbackpanel also registers the oncallback event on the server and calls the objective mcallback () method of aspxcallbackpanel from the client.
Next, let's take a look at the following code and place a multiview in aspxcallbackpanel. Note that the mulitview is placed under the <panelcollection> sub-element of aspxcallbackpanle.

Code
< Dxrp: panelcontent ID = "Panelcontent1" Runat = "Server" >
< Dxcp: aspxcallbackpanel ID = "Aspxcallbackpanel" Runat = "Server" Clientinstancename = "Callbackpanel"
Oncallback
= "Aspxcallbackpanel_callback" Width = "100%" >
< Panelcollection >
< Dxp: panelcontent ID = "Panelcontent2" Runat = "Server" >
< ASP: multiview ID = "Multiview" Runat = "Server" >
< ASP: View ID = "View1" Runat = "Server" >
< Table >
< Tr >
< TD Valign = "TOP" >
< Dxe: aspxlabel ID = "Aspxlabel1" Runat = "Server" Text = "Who am I? Do not tell me that I am an office worker; Do not tell me that I am a migrant worker; Do not tell me that I am a rich man; Do not tell me that I am a nouveau riche, entrepreneurs all want to be stars. Don't tell me that I am a star. Now stars are like office workers. "
Font-bold
= "True" >
</ Dxe: aspxlabel >
</ TD >
</ Tr >
</ Table >
</ ASP: View >
< ASP: View ID = "View2" Runat = "Server" >
< Table >
< Tr >
< TD Valign = "TOP" >
< Dxe: aspxlabel ID = "Aspxlabel3" Runat = "Server" Text = "Many people don't know what they have lost, and time always gives answers patiently. Looking at what was lost in the past, there will be a heartache! It's a kind of regret! "
Font-bold
= "True" >
</ Dxe: aspxlabel >
</ TD >
</ Tr >
</ Table >
</ ASP: View >
< ASP: View ID = "View3" Runat = "Server" >
< Table >
< Tr >
< TD Valign = "TOP" >
< Dxe: aspxlabel ID = "Aspxlabel5" Runat = "Server" Text = "When a person kisses you, you must be deeply loved. When many people kiss you, you must be a beautiful child. When many people kiss you, you will be drowned"
Font-bold
= "True" >
</ Dxe: aspxlabel >
</ TD >
</ Tr >
</ Table >
</ ASP: View >
</ ASP: multiview >
</ Dxp: panelcontent >
</ Panelcollection >
</ Dxcp: aspxcallbackpanel >
</ Dxrp: panelcontent >

The next step is to call aspxcallbackpanel's performcallback () method. Here we place an aspxlistbox and register the selectedindexchanged event in the clientsideevents event of aspxlistbox, as shown below:

Code
< Dxe: aspxlistbox ID = "Aspxlistbox1" Runat = "Server" Clientinstancename = "ListBox" Height = "83px" >
< Items >
< Dxe: listedititem Text = "Raytheon 1" Value = "0"   />
< Dxe: listedititem Text = "Raytheon 2" Value = "1"   />
< Dxe: listedititem Text = "Raytheon 3" Value = "2"   />
</ Items >
< Clientsideevents Selectedindexchanged = "Function (s, e ){
VaR item = ListBox. getselecteditem ();
Callbackpanel. Callback mcallback (item. Value); <! -- This row is the callback method for calling aspxcallbackpanel -->
}"
Init = "Function (s, e ){
ListBox. setselectedindex (0 );
Callbackpanel. Callback mcallback (0 );
}"
 
/>
</ Dxe: aspxlistbox >

When the customer calls the callbackpanel. Callback mcallback (value) method, it calls the oncallback event on the server.

Protected   Void Aspxcallbackpanel_callback ( Object Source, callbackeventargsbase E)
{
Multiview. activeviewindex
= Convert. toint32 (E. Parameter ); // Viewid displayed for activation
}

 

Summary:
1. Add the aspxcallbackpanel component to the page and set the clientinstancename attribute (Client ID, such as clientinstancename = "callbackpanel ").
2. Register aspxcallbackpanel's server event aspxcallback_callback.
3. Call the callback mcallback method of the client user callback component to call the aspxcallbackpanel_callback event of the server.
Code: callbackpanel. Callback mcallback (ID)

 

 

Conclusion:

Through the use of aspxcallbackpanel and aspxcallback in the previous section, we found that the callback methods of the devexpress aspx control are consistent.
Add clientinstancename
Register the server-side callback event
Call the clientinstancename. javasmcallback method to execute the code in the server-side callback.
Finally, call the callbackcomplete event for necessary processing (optional)

 

Personal Opinion:
Although aspxcallbackpanel and aspxcallback provide many mechanisms to complete Ajax operations, aspxcallbackpanel is not used in updatapanel for ease of use of controls.
However, through the callback learning of aspxcallbackpanel and callback components, we know the callback mechanism and process of the aspx series operations, which is of great help for learning and understanding other aspx controls.

 

 

 

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.