Panel control of ASP. NET

Source: Internet
Author: User

ASP. NET Panel control. We can see through the name that this is a menu control. When you move the mouse to a specified position, a menu appears without affecting other elements, and allow the user to perform some operations.

Important attributes
TargetControlID: ID of the target control to display the menu
PopupControlID: ID of the control for the pop-up menu
HoverCssClass: Specifies the style of the target control when you move the cursor to the target control.
PopupPosition: Position of the pop-up menu. There are five values (bottom, top, left, right, center)
OffsetX: the position of the menu from the target control-abscissa
OffsetY: the position of the menu from the target control-y coordinate


1. Open vs2005 and create an AjaxControlToolKit website named oec2003_HoverMenu.
2. Open the Default. aspx page and switch to the design view.
3. Add a TextBox and a Panel control to the page, and add three LinkButton controls to the Panel control, as shown below:

PopDelay: the delay time of the pop-up menu

 
 
  1. <Asp: Panel ID="Panel1" Runat="Server" Height="50px" Width="125px"> 
  2. <Asp: LinkButton ID="LinkButton1" Runat="Server" OnClick=
    "Linkbutton#click">Date</Asp: LinkButton> 
  3. <Br /> 
  4. <Asp: LinkButton ID="LinkButton3" Runat="Server" OnClick=
    "LinkButton3_Click">Time</Asp: LinkButton><Br /> 
  5. <Asp: LinkButton ID="LinkButton2" Runat="Server" OnClick=
    "LinkButton2_Click">Name</Asp: LinkButton> 
  6. </Asp: Panel> 
  7. 4. Add the HoverMenu control on the page and set its properties. The Code is as follows:
  8. <AjaxToolkit: HoverMenuExtender ID="HoverMenuExtender1" Runat=
    "Server" TargetControlID="TextBox1" 
  9. OffsetX="-1" OffsetY="-1" HoverCssClass="Hover" PopupControlID=
    "Panel1" PopupPosition="Bottom"> 
  10. </AjaxToolkit: HoverMenuExtender> 
  11. 5. Switch to the Code view and add a css style between the head elements to implement the style when the mouse moves to the target control, as shown below:
  12. <Style Type="Text/css"> 
  13. . Hover
  14. {}{
  15. Background-color: blue;
  16. Background-repeat: repeat-x;
  17. Background-position: left top;
  18. }
  19. </Style> 

Three LinkButton controls are placed in the Panel. After you click the LinkButton control, the corresponding content is displayed in the text box. The event code for clicking a LinkButton is as follows:

 
 
  1. protected void LinkButton1_Click(object sender, EventArgs e)  
  2. {  
  3. TextBox1.Text = DateTime.Now.ToShortDateString();  
  4. }  
  5. protected void LinkButton3_Click(object sender, EventArgs e)  
  6. {  
  7. TextBox1.Text = DateTime.Now.TimeOfDay.ToString();  
  8. }  
  9. protected void LinkButton2_Click(object sender, EventArgs e)  
  10. {  
  11. TextBox1.Text = "oec2003";  

Save the design, run the program, move the mouse over the text box, you will find that the text box style is changed to our custom style, and a menu is displayed, that is, the Panel control.
Click the button in the menu and the corresponding content will appear in the text box. The Panel control of ASP. NET is described above.

  1. ASP. NET TypeConverter
  2. Analysis on TypeResolver of ASP. NET
  3. Define JavaScriptConverter in ASP. NET
  4. How to replace Sys. Services in ASP. NET
  5. Use Profile Service of ASP. NET AJAX

Related Article

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.