473,394 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

make user control run before page?

It appears myButton_OnClick is triggering in my user control AFTER its
parent's Page_Load already runs. Is there a way to make the parent Page_Load
to run afterwards?

I'm changing a session variable when a user clicks on a button in a user
control. The parent page reads in the session variable. Obviously, this
isn't going to work if the parent has already done its thing.

I'm looking for an alternative, but adding code to every page negates the
reason for using the user control in the first place: re-use!

-Max
Nov 18 '05 #1
2 1733

Hi there,

Unfortunatelly you can not change the order of event's executing:(
To see the events order when you use user control in an aspx page look at
this page : http://dotnet.dwteam.com/demos/pageevents.aspx ( click on Submit
button)
May be you should think of some other way of doing what you actually - for
example to work with the sessions variables in the Page PreRender event.

Regards
Martin

"msnews.microsoft.com" <ma*****@portvista.com> wrote in message
news:uX**************@TK2MSFTNGP10.phx.gbl...
It appears myButton_OnClick is triggering in my user control AFTER its
parent's Page_Load already runs. Is there a way to make the parent Page_Load to run afterwards?

I'm changing a session variable when a user clicks on a button in a user
control. The parent page reads in the session variable. Obviously, this
isn't going to work if the parent has already done its thing.

I'm looking for an alternative, but adding code to every page negates the
reason for using the user control in the first place: re-use!

-Max

Nov 18 '05 #2
Hmmm, well I found a solution: just added a response.redirect on the user
control which causes the page to refresh (page load is called twice) with
the new session variable. I'm not crazy about the concepts people come up
with on communicating between user controls and pages. When you have a lot
of pages, placing special code in each page so the user control can become
exposed programmatically is simply not the ways of OOP. I'm hoping the next
version of .NET includes templates: that should solve some of these
problems.

-Max

"Martin Marinov" <me********@mecrossroad.bg> wrote in message
news:e5**************@TK2MSFTNGP10.phx.gbl...

Hi there,

Unfortunatelly you can not change the order of event's executing:(
To see the events order when you use user control in an aspx page look at
this page : http://dotnet.dwteam.com/demos/pageevents.aspx ( click on Submit button)
May be you should think of some other way of doing what you actually - for
example to work with the sessions variables in the Page PreRender event.

Regards
Martin

"msnews.microsoft.com" <ma*****@portvista.com> wrote in message
news:uX**************@TK2MSFTNGP10.phx.gbl...
It appears myButton_OnClick is triggering in my user control AFTER its
parent's Page_Load already runs. Is there a way to make the parent

Page_Load
to run afterwards?

I'm changing a session variable when a user clicks on a button in a user
control. The parent page reads in the session variable. Obviously, this
isn't going to work if the parent has already done its thing.

I'm looking for an alternative, but adding code to every page negates the reason for using the user control in the first place: re-use!

-Max


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
6
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I...
5
by: Steve Richter | last post by:
In my user control I want to read the ViewState dictionary of the Parent control. But this sensible idea is not permitted by the compiler: Compiler Error Message: CS1540: Cannot access...
6
by: Selden McCabe | last post by:
I have a form with a bunch of image buttons. When the user moves the mouse over a button, I want to do two things: 1. change the Imagebutton's picture, and 2. make another control visible. I'm...
3
by: VB Programmer | last post by:
I have a SIMPL HTML form that displays a javascript clock. I want to take this component and put it in a web user control so that I can reuse it easily. The problem is I don't know what to do...
3
by: =?Utf-8?B?Qw==?= | last post by:
Hi, I have a user control which I use on all my pages. The control is situated on the top of my page (sits on my master page). For some long pages the user has to scroll back up to the top of...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.