[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 308
  • Last Modified:

Postback in a page with a user control

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?
0
RosanneParnell
Asked:
RosanneParnell
  • 2
  • 2
2 Solutions
 
smolamCommented:
Hi,

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 http://weblogs.asp.net/mnolton/archive/2003/06/04/8260.aspx, 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!

HTH
0
 
msdixonCommented:
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.
      }
0
 
msdixonCommented:
i say split the points
0
 
smolamCommented:
I agree!
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now