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

How to manage solutions that don't fit within the ASP.NET page lifecycle

I'm new to ASP.NET and have run across a problem several times while
working on web apps. I often need to create content dynamically (based
on an event) which contains dynamically created linkbuttons (or other
webcontrols). These linkbuttons have to be created after events are
processed, and so these linkbuttons cannot have handlers added to them
because they are too late in the page lifecycle for the handlers to
register.

An example:

I have a page that displays the results of a database query. The query
is generated by an interface at the top of the page. The bottom of the
page shows the results of that query. Next to each result is a
linkbutton that allows you to delete that item from the database.

The lower part of the page needs to be generated after the event
handlers for the query interface are fired. This means that the lower
part of the page is created too late in the page lifecycle to attach
eventhandlers to included linkbuttons.

I've kludged around it by using regular HTML instead of linkbuttons
and creating an href javascript calling dopostback - then in my
pageload looking at the POST variables and figuring out what was
clicked.

This works, but because it is accessing parts of ASP.NET that aren't
meant to be accessed directly, I'm afraid it will break in future
versions or on newer browsers.

Ideally, I'd like to be able to refresh the page via a postback - so
that page state and the scroll position is maintained and only the
page lifecycle is rerun.

How are other people handling issues like this?

Regards,
Epson
Nov 18 '05 #1
1 994
I discovered my problem. I wasn't assigning IDs to the dynamically
created controls. Assigning IDs makes the controls able to bind to
events even if they are created later in the page lifecycle.
Nov 18 '05 #2

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

Similar topics

0
by: Epson Barnett | last post by:
I'm new to ASP.NET and have run across a problem several times while working on web apps. I often need to create content dynamically (based on an event) which contains dynamically created...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
2
by: Frankie | last post by:
I have a user control into which I insert a bunch of controls dynamically. I have it all working just fine - Everything is there on Postback, etc. I load this user control into a hosting ASPX...
4
by: Jeremy Holt | last post by:
Hi, In a windows.forms application I would BeginInvoke a delegate on the UI thread to collect data from a database. When the call returns to the AsyncCallback, if the Control.InvokeRequired =...
2
by: Diffident | last post by:
Hello All, I have a question which is pertinent to Page's lifecycle. I declared a protected static object (global variable) whose value is set only once when the page is loaded. Will that...
7
by: | last post by:
I'm using ASP.NET 2.0, C#, SQL Server 2005, and databound controls like the DataList and the GridView. Right now I'm using SqlDataSource as part of very quick and dirty site; I'm not looking to...
19
by: Mark Rae | last post by:
Hi, Is it possible to have programmatic access to the Page object in Application_BeginRequest, or is it too early in the lifecycle...? E.g. to be able to change a page's MasterPage...
2
by: Gary W. Smith | last post by:
I have a page that inherits from a base page that is currently overriding all of the On* events. For the most part I'm accomplishing everything I set out to do with the inheritance, but I wanted...
4
by: Dariusz Tomoń | last post by:
Hello, How can I manage files from ASP.NET C# 2.0? I mean I would like to save/erase files, find files in a folder and programatically check if the file with the specific name exists in a...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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...

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.