Hi,
I have a .aspx page which has a .ascx file included through the lines
<%@ Register TagPrefix="aspcustom" TagName="menu" Src="Menu.ascx" %>
and
<aspcustom:menu id="Menu1" runat="server"></aspcustom:menu>
both of these files have vb.net code behind.
I am processing some information from a post back in the code behind for the
ascx file, as it is common to various pages. I would, during this postback
period, like to access this processed data, and use it in the main page. How
do I access the data? Do I have to do anything special to ensure the .ascx
code is executed before the .aspx code, so that the information is ready?
Thanks,
Martin 6 2592
Martin
How about moving your code to a class and populating public or session
variables with the data you require? You can then call your variables
from both the .ascx and .aspx.
I am not sure if you can force a .ascx to run first.
Cheers
Jared
You could try moving your code to a Class module and storing it as
Session or Public variables. You can then call these variables in both
the .ascx and .aspx.
I am not sure if you can ensure that the .ascx code runs first.
Jared
Martin Wrote: I have a .aspx page which has a .ascx file included through the lines
<%@ Register TagPrefix="aspcustom" TagName="menu" Src="Menu.ascx" %> and <aspcustom:menu id="Menu1" runat="server"></aspcustom:menu>
both of these files have vb.net code behind.
I am processing some information from a post back in the code behind for the ascx file, as it is common to various pages. I would, during this postback period, like to access this processed data, and use it in the main page. How do I access the data? Do I have to do anything special to ensure the .ascx code is executed before the .aspx code, so that the information is ready?
"Jared" <ja***********@gmail.com> wrote in message news:11**********************@g47g2000cwa.googlegr oups.com... Martin
How about moving your code to a class and populating public or session variables with the data you require? You can then call your variables from both the .ascx and .aspx.
The problem with moving the information to a class is that the variable hang
over from another instance. I need the variable to be instance variables
rather than class variables, and I need to be able to access the same
instance from the .ascx file and .aspx file. My thought was that the code
behind the .aspx could reference the instance of Menu.ascx called Menu1, but
I get a blue underline in the code behind saying that Menu1 is not declared.
I am not sure if you can force a .ascx to run first.
I thought there was a page lifecycle with init, load etc. I found a video
about it on MSDN TV, but It doesn't say what happens when there are .ascx
files involved as well as .aspx files. Does anyone have any ideas on this?
Thanks,
Martin
Events for ASCX controls and their parent ASPX page do run in a
predefined manner with respect to the ASP.NET lifecycle. I never
remember the order in which events run for each -- so I usually just do
a Response.Write() inside each event handler for both the ASCX control
and the parent ASPX page, so I can quickly see which events run first.
Hopefully this will help.
Luke
"Jared" <ja***********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com... You could try moving your code to a Class module and storing it as Session or Public variables. You can then call these variables in both the .ascx and .aspx.
I am not sure if you can ensure that the .ascx code runs first.
Thanks, I tried that - code appears to run in this order
..ascx init
..aspx load
..ascx load
so if I move some of my code in the .ascx file from the Page_Load to the
Page_Init, I can access the .ascx variables from the .aspx file's Page_Load
method.
Martin
"Martin Eyles" <ma**********@NOSPAMbytronic.com> wrote in message
news:11*************@corp.supernews.com... "Jared" <ja***********@gmail.com> wrote in message news:11**********************@g44g2000cwa.googlegr oups.com... You could try moving your code to a Class module and storing it as Session or Public variables. You can then call these variables in both the .ascx and .aspx.
I am not sure if you can ensure that the .ascx code runs first.
Thanks, I tried that - code appears to run in this order
.ascx init .aspx load .ascx load
so if I move some of my code in the .ascx file from the Page_Load to the Page_Init, I can access the .ascx variables from the .aspx file's Page_Load method.
Martin
Sorry, replied to the wrong thread - this is in fact a reply to slagomite
suggestion - Ignore the text I quoted from Jared, and read the slagomite
text This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jeff Smith |
last post by:
Can I load custom web user controls dynamically and access the properties
and methods without having to explicitly define custom control types
(example 2 below). I have custom web control named...
|
by: Dan Nash |
last post by:
Hi all,
I've got a page with a user control on, added via VS. I'm trying to get to a
property of the user control (or more precisely, a public var).
Here's the code at the top of my aspx...
|
by: Vivek Sharma |
last post by:
Hi There,
I have a situation where I wish to load the controls dynamically on the
basis of user role. Hence, I am using this code.
if (UserRole == "IS Administrator")
{
Control UC1 =...
|
by: Brenden Bixler |
last post by:
I have a user control, dropdown.ascx
Inside dropdown.ascx, I have a dropdownlist control.
From my page.aspx, I need to be able to access the dropdown's value.
By setting it to auto-post...
|
by: hummh |
last post by:
Hello out there,
I´m making my first steps with ASP.NET 2.0 and have he following
problem:
I´ve implemented a Web User Control that sits in the root of my
ASP.NET Website. I want to use the...
|
by: evandelagrammaticas |
last post by:
Hi all. I have spent the better part of a day scouring the newsgroups
and I am sure that I must have come across the solution a number of
times - but I am still a real newbie at asp.net so please...
|
by: tshad |
last post by:
Is there a way for a User Control to access an object (such as label or
textbox) on the .aspx page that calls it?
For example:
x.aspx
**************************************
....
Sub...
|
by: schneider |
last post by:
Hi all,
I created a User Control "SlideShow.ascx" in my application's root.
Then I created a subfolder and an aspx page "MySlideShow1.aspx" in
there. I added an instance of the ascx control to...
|
by: michael234 |
last post by:
Hi All,
Before i get into things I'm writing in C# using VS2003 with framework 1.1.
I am having a problem accessing a user control in the code behind.
I'm using the user control for some...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
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...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |