473,509 Members | 10,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Web User Controls

Hi All

I created web user control that has a few properties and an Update method.
These controls all get initialised and configured (all properties set) at
the page load event.

Today I included an if(!this.IsPostBack) {} around the initialisation code,
so that if an error occurred when the user was trying to update the
database, I could send them back with all their amended data in tact (not
the data back from database).

Now, when I try to update the page, my user controls still exist, but their
properties are no longer set!! Is there a way around this, I'm new to .Net
and may just be taking the wrong train of thought.

Any advice would be greatly appreciated.

Many Thanks

Luke

Nov 15 '05 #1
2 1367
Luke Ward wrote:
Hi All

I created web user control that has a few properties and an Update
method. These controls all get initialised and configured (all
properties set) at the page load event.

Today I included an if(!this.IsPostBack) {} around the initialisation
code, so that if an error occurred when the user was trying to update
the database, I could send them back with all their amended data in
tact (not the data back from database).

Now, when I try to update the page, my user controls still exist, but
their properties are no longer set!! Is there a way around this, I'm
new to .Net and may just be taking the wrong train of thought.

Any advice would be greatly appreciated.


My question to you is what mechanism are you using to repopulate the data
back into the controls after an update, either successful or failure. I
would guess that on a successful update you would want to initialise the
page as you do on first load so that any data that might have been modified
by triggers or other actions on the database would be retrieved. If that's
the case, you're initialise code needs to be enhanced slightly so that in
the else of your if(!IsPostBack) you still reload the control data from the
database if the update were successful.

Also in the else, you need to decide how you want to reload the controls
with the user input data if the update failed. You can use one of the built
in mechanisms such as viewstate or you can write your own.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.
Nov 15 '05 #2
Thanks Tom

You guess right, on success I can reload the page as first load, on failure
I want to preserve the page and user entered data. So I suppose I just need
to reset all the properties of my user controls on failure or success, I
just thought they would stay set for some reason.

Thanks

Luke

"Tom Porterfield" <tp******@mvps.org> wrote in message
news:ec**************@TK2MSFTNGP12.phx.gbl...
Luke Ward wrote:
Hi All

I created web user control that has a few properties and an Update
method. These controls all get initialised and configured (all
properties set) at the page load event.

Today I included an if(!this.IsPostBack) {} around the initialisation
code, so that if an error occurred when the user was trying to update
the database, I could send them back with all their amended data in
tact (not the data back from database).

Now, when I try to update the page, my user controls still exist, but
their properties are no longer set!! Is there a way around this, I'm
new to .Net and may just be taking the wrong train of thought.

Any advice would be greatly appreciated.
My question to you is what mechanism are you using to repopulate the data
back into the controls after an update, either successful or failure. I
would guess that on a successful update you would want to initialise the
page as you do on first load so that any data that might have been

modified by triggers or other actions on the database would be retrieved. If that's the case, you're initialise code needs to be enhanced slightly so that in
the else of your if(!IsPostBack) you still reload the control data from the database if the update were successful.

Also in the else, you need to decide how you want to reload the controls
with the user input data if the update failed. You can use one of the built in mechanisms such as viewstate or you can write your own.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.

Nov 15 '05 #3

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

Similar topics

1
2116
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new...
6
3350
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...
3
2222
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
8
3157
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
3
2774
by: Terry Olsen | last post by:
I'm trying to add a domain user to a local group using the code below: Dim LCL As New DirectoryEntry("WinNT://" + Environment.MachineName + ",computer") Dim DOM As New...
0
7237
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
7137
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
7347
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
7073
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
7506
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...
1
5062
isladogs
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...
0
4732
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
1571
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
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.