473,396 Members | 1,923 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,396 software developers and data experts.

asp.net user control

I am trying to migrate from asp to asp.net and having problem replacing
include with user control.
On every page we have include asp that have some common asp code that I
need to run before the page code kicks in, but user control code is
always running after the page code.
I am even registering and placing user control before my page
initialization, but still it's running after.

<%@Register TagPrefix="FindSessionUC" TagName="FindSession"
Src="EDWFindSessionValues.ascx"%>
<FindSessionUC:FindSession id="MyFindSessionUC" runat="server" />
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="EDW_TEST.aspx.vb" Inherits="CSATodayWEBNet.EDW_TEST"%>

What am I doing wrong?
Any help would be appritiated.
Thanks.

Jun 7 '06 #1
2 1183
Hi,

I suggest you put breakpoints in your user contol and in your aspx page
to get an idea of the order in which events are occurring.

Also, it is unclear whether your code is supposed to execute javascript
or c#/vb code.

The location of your <FindSessionUC> tage doesn't determine when code is
executed instead it determines where the rendered code is placed within
the html markup that is output.

To simulate ASP like behaviour (a habit I am also used to) I use the
following at the top of my aspx page:

<!--#Include virtual="~/tools/PageHeader.inc" -->

But even then I know the code will be executed/included after the
PageLoad event.

I think that if you need code routinely executed before the Page_Load
event you are best off writing a new class that inherits
System.Web.UI.Page and then using it for all of your pages. That is
something I also do.

In ASP.NET 2.0 I think something similar can be done with Master pages.

Hope this helps a bit.

mnichols

ed******@yahoo.com wrote:
I am trying to migrate from asp to asp.net and having problem replacing
include with user control.
On every page we have include asp that have some common asp code that I
need to run before the page code kicks in, but user control code is
always running after the page code.
I am even registering and placing user control before my page
initialization, but still it's running after.

<%@Register TagPrefix="FindSessionUC" TagName="FindSession"
Src="EDWFindSessionValues.ascx"%>
<FindSessionUC:FindSession id="MyFindSessionUC" runat="server" />
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="EDW_TEST.aspx.vb" Inherits="CSATodayWEBNet.EDW_TEST"%>

What am I doing wrong?
Any help would be appritiated.
Thanks.

Jun 7 '06 #2
Another option would be to put the code into a class that inherits from
Page and have your code behind class inherit from your new "base page".
Now you can use all of the events from the page, like OnLoad, Init,
etc...

I would use a user control only for content you want to use in multiple
pages in your site.

ed******@yahoo.com wrote:
I am trying to migrate from asp to asp.net and having problem replacing
include with user control.
On every page we have include asp that have some common asp code that I
need to run before the page code kicks in, but user control code is
always running after the page code.
I am even registering and placing user control before my page
initialization, but still it's running after.

<%@Register TagPrefix="FindSessionUC" TagName="FindSession"
Src="EDWFindSessionValues.ascx"%>
<FindSessionUC:FindSession id="MyFindSessionUC" runat="server" />
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="EDW_TEST.aspx.vb" Inherits="CSATodayWEBNet.EDW_TEST"%>

What am I doing wrong?
Any help would be appritiated.
Thanks.


Jun 7 '06 #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: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
4
by: louise raisbeck | last post by:
Resending this as own topic as didnt get answer from original. Would be grateful for a response from anyone that knows. Thanks. Hi there, I found your post really helpful..but i wondered if, once...
0
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
0
by: davidr | last post by:
Hi, I have a panel that I load user Control in no problem. The problem arrises when I do a post back on one of these user controls. I have button it does a click event. In this click event I...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
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...
3
by: Fred Chateau | last post by:
I am trying to access a user control class, for a user control that is loaded dynamically, from the containing page. I have been able to access Web controls in the user control, but so far I have...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.