Solved

User Control appearance

Posted on 2009-05-04
6
226 Views
Last Modified: 2013-11-26
I have a menu system set up in a user control.
The system is in a left side div.

What I need to do is the FIRST time the web site is loaded, I need the menu panel to appear as an accordian down after 1 second.

Any ideas?
0
Comment
Question by:lrbrister
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:ppittle
ID: 24296261
In the code behind for your user control, you can use the IsPostBack property to determine if the Control is being loaded for a new request or to a user that is already on your site.  If IsPostBack is false, then the Control is loaded for a new request:

 protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
//Code to 'accordian down' the menu
            }
}
0
 

Author Comment

by:lrbrister
ID: 24315556
ppitle
What code will allow the PANEL to accordian down?
0
 
LVL 8

Expert Comment

by:ppittle
ID: 24315607
What do you mean by accordian down?  Are you trying to do animation?  Is there an example of this behavior out on the web already that you are trying to emulate?
0
 

Author Comment

by:lrbrister
ID: 24315683
ppittle:

I can do an on clink for Panel1.Visible= true/false with the buttin click below
But that is just an "on-off" feature.

I need it to "slide" down/up?



 Protected Sub btnFavorites_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFavorites.Click
        panelfavorites.Visible = Not panelfavorites.Visible
    End Sub
0
 
LVL 8

Accepted Solution

by:
ppittle earned 500 total points
ID: 24355146
lrbrister,

C# does not have any inherient animation controls. Animations on websites are powered by a number of technologies, such as Adobe Flash, Microsoft Silverlight and JavaScript.  Consequently, you will need to use a hybrid approach.

This tutorial provides examples of how to implement sliding animation using JavaScript:
http://www.switchonthecode.com/tutorials/javascript-tutorial-inline-sliding-panels

To incorporate this within your C# application, you'll need to call the JavaScript functions from .NET controls.

For example, to initiate a JavaFunction from a C# button you need to set the OnClientClick property.  If a function requires you to pass in a control ID, you'll need to pass in Control.ClientID:

<script type="text/javascript">
function JavaScriptAnimationFunction (controlToAnimate)
{
//JavaScript code
}
</script>
<asp:Panel ID="MyPanel" runat="server />
<asp:Button ID="RunJavaScriptFunction" runat="server" OnClientClick="JavaScriptAnimationFunction('<%= MyPanel.ClientID %>'

If you need to launch the menu animation only on a page load, you can use Page.ScriptManager to register a javascript method as so:

//Sorry about the C#, I'm a C# developer and don't know the VB syntax off hand.
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "MenuStartScript",
                    "//Code for JavaScript menu animation");
}


Finally, you could always purchase prebuilt controls that do all of this for you, but they can be rather expensive.:  http://www.telerik.com/products/aspnet-ajax/menu.aspx

HTH

PJ
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question