473,473 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Postback/Validation in a framework

Hi.
We have a framework that we work with for our project. So far we
have had very good success – basically the frame work wraps many day to day
tasks so that they are all included in the project. The framework is built on
a modified Page Controller pattern in which a aspx page controls the loading
of clients (user controls) into a placeholder (Sort of similar to .net 2.0
Master Pages except that the page loads the client not the client loads the
page) – and therefore it can provide many services to the client controls –
such as logging, Home page layout, Request parameter validation , session
introspection (for customer support) , ui messaging (i.e. Messageboxing) etc…

The problem we are having is with validation. Using the standard
asp.net server side validation the developer has to include an explicit
validation check in a posted back event i.e

If (Page.IsValid)
{
Do stuff
}

If page.isvalid is not checked then the code will run even if the values in
the controls are flat out wrong.

One of the aims of our framework is too automatically take care
of as many things as we can offload off the developer – this is something
that is probably ripe for inclusion – basically what I am looking for is a
way to interrupt the page load process so that we can stop postback events
from firing if the page is not valid.

I cannot find anyway of interrupting the validation process.
Ideally I want be able to stop the actual code written in the postback events
(such as onselection changed) from firing. The problem is that I do not see
anywhere that I can hook into this. I want to catch it after it has applied
the values to the controls and before it actually calls the postback events
however everything is marked as private.

I did think about actually unassigning the postback events in
onload (after validation) - however there are so many different types of
events I would have to look for - Including many controls that I do not
currentlly have (third Party). However ifI don't have a choice I might have
to resort to that.

Does any one have any ideas?
Thanks

Nov 19 '05 #1
4 4204
"AIM48" <AI***@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
Hi.
We have a framework that we work with for our project. So far
we
have had very good success - basically the frame work wraps many day to
day
tasks so that they are all included in the project. The framework is built
on
a modified Page Controller pattern in which a aspx page controls the
loading
of clients (user controls) into a placeholder (Sort of similar to .net 2.0
Master Pages except that the page loads the client not the client loads
the
page) - and therefore it can provide many services to the client
controls -
such as logging, Home page layout, Request parameter validation , session
introspection (for customer support) , ui messaging (i.e. Messageboxing)
etc.
....
One of the aims of our framework is too automatically take care
of as many things as we can offload off the developer - this is something
that is probably ripe for inclusion - basically what I am looking for is a
way to interrupt the page load process so that we can stop postback events
from firing if the page is not valid.


Do you currently stop processing your pages in Page_Load if Page.IsValid is
false? I've never written a page like that. I check IsValid when it's time
to maybe change data.

John Saunders
Nov 19 '05 #2
We have many things happening in the page load and I do not stop processing
on the isvalid call. Rather I would like to automaticlly dissconnect the
postback events if !page.isvalid

"John Saunders" wrote:
"AIM48" <AI***@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
Hi.
We have a framework that we work with for our project. So far
we
have had very good success - basically the frame work wraps many day to
day
tasks so that they are all included in the project. The framework is built
on
a modified Page Controller pattern in which a aspx page controls the
loading
of clients (user controls) into a placeholder (Sort of similar to .net 2.0
Master Pages except that the page loads the client not the client loads
the
page) - and therefore it can provide many services to the client
controls -
such as logging, Home page layout, Request parameter validation , session
introspection (for customer support) , ui messaging (i.e. Messageboxing)
etc.


....
One of the aims of our framework is too automatically take care
of as many things as we can offload off the developer - this is something
that is probably ripe for inclusion - basically what I am looking for is a
way to interrupt the page load process so that we can stop postback events
from firing if the page is not valid.


Do you currently stop processing your pages in Page_Load if Page.IsValid is
false? I've never written a page like that. I check IsValid when it's time
to maybe change data.

John Saunders

Nov 19 '05 #3
"AIM48" <AI***@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
We have many things happening in the page load and I do not stop
processing
on the isvalid call. Rather I would like to automaticlly dissconnect the
postback events if !page.isvalid
What I'm getting at is that this seems unnatural to me. I can't say that
I've written many web applications where every postback event began with "if
not page.isValid return".

John Saunders
"John Saunders" wrote:
"AIM48" <AI***@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
> Hi.
> We have a framework that we work with for our project. So
> far
> we
> have had very good success - basically the frame work wraps many day to
> day
> tasks so that they are all included in the project. The framework is
> built
> on
> a modified Page Controller pattern in which a aspx page controls the
> loading
> of clients (user controls) into a placeholder (Sort of similar to .net
> 2.0
> Master Pages except that the page loads the client not the client loads
> the
> page) - and therefore it can provide many services to the client
> controls -
> such as logging, Home page layout, Request parameter validation ,
> session
> introspection (for customer support) , ui messaging (i.e.
> Messageboxing)
> etc.


....
> One of the aims of our framework is too automatically take
> care
> of as many things as we can offload off the developer - this is
> something
> that is probably ripe for inclusion - basically what I am looking for
> is a
> way to interrupt the page load process so that we can stop postback
> events
> from firing if the page is not valid.


Do you currently stop processing your pages in Page_Load if Page.IsValid
is
false? I've never written a page like that. I check IsValid when it's
time
to maybe change data.

John Saunders

Nov 19 '05 #4
ASP.NET is designed so that you check Page.IsValid in you post back event
method prior to saving when there are validators on the page. There are a
few cases:
* If CausesValidation=true, the button will fire Page.Validate() for you
just before calling your click event. It doesn't skip calling your click
event (which is what AIM48 wants). You have to test Page.IsValid
* If CausesValidation=false, then you are responsible for making validation
decisions by calling Page.Validate() or Validator.Validate() and testing the
associated IsValid property.
Its very common for users not to understand this and get into trouble with
it.

AIM48: I have a suggestion. Subclass System.Web.UI.WebControls.Button with
the following changes:
- Add a method that checks Page.IsValid and internally connect it to the
Click event.
- Add a new event to this class which is used as a replacement for Click.
For example: "RealClick".
- You Click event method will fire the RealClick events if Page.IsValid is
true.
- You teach your users to use your new class and assign the event RealClick
instead of Click.

IMO, its no easier than teaching them to use ASP.NET the standard way.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message
news:uB**************@TK2MSFTNGP14.phx.gbl...
"AIM48" <AI***@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
We have many things happening in the page load and I do not stop
processing
on the isvalid call. Rather I would like to automaticlly dissconnect the
postback events if !page.isvalid


What I'm getting at is that this seems unnatural to me. I can't say that
I've written many web applications where every postback event began with
"if not page.isValid return".

John Saunders
"John Saunders" wrote:
"AIM48" <AI***@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
> Hi.
> We have a framework that we work with for our project. So
> far
> we
> have had very good success - basically the frame work wraps many day
> to
> day
> tasks so that they are all included in the project. The framework is
> built
> on
> a modified Page Controller pattern in which a aspx page controls the
> loading
> of clients (user controls) into a placeholder (Sort of similar to .net
> 2.0
> Master Pages except that the page loads the client not the client
> loads
> the
> page) - and therefore it can provide many services to the client
> controls -
> such as logging, Home page layout, Request parameter validation ,
> session
> introspection (for customer support) , ui messaging (i.e.
> Messageboxing)
> etc.

....

> One of the aims of our framework is too automatically take
> care
> of as many things as we can offload off the developer - this is
> something
> that is probably ripe for inclusion - basically what I am looking for
> is a
> way to interrupt the page load process so that we can stop postback
> events
> from firing if the page is not valid.

Do you currently stop processing your pages in Page_Load if Page.IsValid
is
false? I've never written a page like that. I check IsValid when it's
time
to maybe change data.

John Saunders


Nov 19 '05 #5

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

Similar topics

6
by: Brian Miller | last post by:
I've been constructing an ASP.Net application using the 1.1 framework, and have been using Web Matrix for development purposes. Now that my application is near completion, I wanted to see if I can...
1
by: nospamforjoel | last post by:
Hello, I have an ASP.NET site that uses validators on a couple pages. On our staging servers, the site works properly. When I deploy it to the live server, however, the pages that have...
6
by: | last post by:
Hi all, I have a bunch of dropdownlists that are populated in client-side javascript. When i do a postback I get the following error:- Invalid postback or callback argument. Event...
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...
3
by: Martin | last post by:
Hi, I have an aspx page with two dropdownlist controls. I update the options in the second ddl based on selection made in the first. I do this with the ICallbackEventHandler interface, as per...
3
by: teo | last post by:
Mozilla error on postback and validation ----------- A Button causes a Listbox to desappear. If no item has been selected on the Listbox, all is OK. If one or more items are selected,
15
by: mc | last post by:
I'm writing an app for managing Task Lists, I'm trying to add some controls to a form that I can use to link tasks, my original intention was to: - Add two list boxes, one listing "all Tasks"...
2
by: Nathan Sokalski | last post by:
I have a DataList in which the ItemTemplate contains two Button controls that use EventBubbling. When I click either of them I receive the following error: Server Error in '/' Application....
9
by: 200dogz | last post by:
Hi guys, I want to have a button which opens up a new window when pressed. <asp:Button ID="Button1" runat="server" Text="Open new window" /> ... Button1.Attributes.Add("OnClick",
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
Oralloy
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,...
1
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.