Postback in a page with a user control

Posted on 2004-11-11
Last Modified: 2013-12-23
I have a user control embedded in my C# .NET pages which forms a top navigation. Each page has the same top navigation. The problem is that I'm expected a postback to the page, not the navbar control when the user tries to navigate off a page. It is not doing this. How can I get a postback to the page to clean up and save data when the user selects the user control rather than a page control?
Question by:RosanneParnell
    LVL 7

    Accepted Solution


    Well from my understanding about what you are asking, you need to get the Usercontrol to have its own postback event when a link is clicked in it, so what I would suggest is that you add your own custom postback even when any link is clicked.  I found this article which may be of some use, it tells you how to add your own postback event to a control.  What I would then do is use this or something similar with your controls to first do a postback that you will handle and save the data that you need to depending on which page the user is on.  Then also knowing which link the user has clicked on redirect them to the appropriate page.  If not you can buy custom navigation controls that can do all this for you!

    LVL 9

    Assisted Solution

    in your control you'll want to handle the Unload event of the control:

    in the InitializeComponent method:

             this.Unload += new EventHandler(MyControl_Unload);

    within your class:

          private void MyControl_Unload(object sender, EventArgs e)
             // save data, cleanup, etc.
    LVL 9

    Expert Comment

    i say split the points
    LVL 7

    Expert Comment

    I agree!

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Now that Expression Web 4.0 ( is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
    Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
    The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
    The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

    728 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