Solved

User Control appearance

Posted on 2009-05-04
6
216 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

929 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now