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

Postback on a derived page

I'm playing with page inheritence but I am currently stumped by postback, on
a page derived from a base class.

In my base page/class I have defined an HTMLForm object. It is instantiated
and added to the base page's control collection during the Init event of the
base page. I expose this form object to any given derived page through a
public property. And this works, more or less; from the derived page, I can
instantiate textboxes, buttons, etc, add them to the form's controll
collection, and then render the whole thing down to the client. On
postback, I can find the value pairs of the form data in the request.form
collection.

Two things that I'm missing out on (and these are my questions)... First is
there an good way to repopulate the controls on a postback- to maintain
viewstate (i.e. textbox text & dropdown selected values, etc) - currently I
perform a somewhat tedious/crude task of scanning the request.forms
collection and manually repopulate everything.

My second question is what I am more interested in, it is about postback
firing events on the server. If, on the derived page, I add a button to my
form object's control collection and reder it, then on postback, it doesn't
appear to raise a click event on the server side. I could simply check
__EVENTTARGET's value if page.ispostback to see what caused postback (and
that's what I'm doing so far), but this isn't the solution I want to use. I
know that it's possible for asp.net to have a button raise a click event
server-side on postback, the eventtarget method is sort of 'primitive' and
I'd like to handle the click event properly. I would like to convert an
existing asp.net website over to the inherited page model, and this website
already relies on server-side click events which I do not want to rewrite to
check eventtarget, etc.

Is this an uncommon approach to site design? I don't find much
documentation regarding these issues.
Nov 19 '05 #1
1 1159
23s
"seven" <z@zd7.com> wrote in message
news:iY********************@speakeasy.net...

In my base page/class I have defined an HTMLForm object. It is
instantiated and added to the base page's control collection during the
Init event of the base page.


Likewise, on the derived page, you'll want to instantiate and add all of the
form-related objects (textboxes, buttons, literal controls, etc) to the
form's control collection during the Init event. This should plug them into
the lifecycle at the correct point and you should end up with events firing
and viewstate repopulation behaving as you might expect.
Nov 19 '05 #2

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

Similar topics

5
by: Matt | last post by:
I always see the term "postback" from ASP book, but I am not sure if I fully understand the meaning. Here's my understanding so far, please correct me if any mistakes. Here's a typical html...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
2
by: Helen | last post by:
I've written a web control that allows you to hide certain bits of your page when the specified selectbox has a certain value. It's a simple enough bit of logic, but I got sick of coding it again...
1
by: Steve Loper | last post by:
I am developing a control in ASP.NET 2.0 that is derived from GridView. This control handles paging on its own and thus renders custom paging buttons. It also add some other functionality to the...
4
by: John | last post by:
Hi, I derived a class from the Hashtable class, with ISerializable implemented and the tag added. Everything works fine with one exception. I store the hashtable in ViewState, but on a...
1
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater...
11
by: antonyliu2002 | last post by:
I know that this has been asked and answered thousands of times. As a matter of fact, I know that I need to say If Not Page.IsPostBack Then 'Do something End If for things that needs to be...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
6
by: anthonykallay | last post by:
Hi there, I dont this this a bug but i cant get my head around it.. I have a master page that has a login control on it, to log in i press the button and the page posts back, however on the page...
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:
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: 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
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.