473,503 Members | 8,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

a growing dislike of custom user controls

Long story as short as possible:

I have a page (aspx) that contains a user control
(ascx). In the form the user can enter a username and
password. If they do, the password box auto-posts-back
and checks to see if the user already exists in the
database.

If yes, the rest of the form fields on the page are
populated with that existing user's data.

If no, nothing happens, of course.

Everything works fine until I fire the submit button at
the bottom of the form. In the OnClick event handler for
the button, data is inserted and the user is redirected.

However, the event handler isn't fired first, for SOME
reason, the ontextchanged event handler for the password
box gets fired first, screws up my page, and creates a
bunch of errors.

First of all, why does that event fire when nothing
changes about this particular field that would fire the
event?

By all means, the OnClick event handler should be getting
fired, and it does, but only *after* the OnTextChanged
for the password box is fired (when logically, it
shouldn't have!)

Any ideas?

Thanks ahead of time!

-v
Nov 18 '05 #1
5 2049
Probably not much help to you, but I find explicitly configuing custom event/postback requirements for ascx controls is a pain in the arse. I've given up on it. ASP.NET server controls that only do a postback you're fine with, but anything else and you might aswell just copy the html and paste it.
Nov 18 '05 #2
Hopefully, the following link should be of some help with your sequence
issue:

http://msdn.microsoft.com/library/de...nLifecycle.asp

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"V. Jenks" <sp**@scientifik.com> wrote in message
news:55****************************@phx.gbl...
Long story as short as possible:

I have a page (aspx) that contains a user control
(ascx). In the form the user can enter a username and
password. If they do, the password box auto-posts-back
and checks to see if the user already exists in the
database.

If yes, the rest of the form fields on the page are
populated with that existing user's data.

If no, nothing happens, of course.

Everything works fine until I fire the submit button at
the bottom of the form. In the OnClick event handler for
the button, data is inserted and the user is redirected.

However, the event handler isn't fired first, for SOME
reason, the ontextchanged event handler for the password
box gets fired first, screws up my page, and creates a
bunch of errors.

First of all, why does that event fire when nothing
changes about this particular field that would fire the
event?

By all means, the OnClick event handler should be getting
fired, and it does, but only *after* the OnTextChanged
for the password box is fired (when logically, it
shouldn't have!)

Any ideas?

Thanks ahead of time!

-v

Nov 18 '05 #3
I'm not sure but if this is relevant by might the root of this problem
in the way password fields are handled? You said the ontextchanged gets
fired even when the password hasn't changed. The password field will
always be blank on the form (as you can't populate a password field with
a value in html), until something is entered in the field. If you set a
value to a password field then it would always be changed unless someone
physically types the same value in to the password box on your form,
otherwise it would be considered to have changed as it will be posted
back as blank.

Not sure if that will be any help or not, but from your message it
sounds like a possible cause.

Matt
http://www.3internet.co.uk
"V. Jenks" <sp**@scientifik.com> wrote in message
news:55****************************@phx.gbl...
Long story as short as possible:

I have a page (aspx) that contains a user control
(ascx). In the form the user can enter a username and
password. If they do, the password box auto-posts-back
and checks to see if the user already exists in the
database.

If yes, the rest of the form fields on the page are
populated with that existing user's data.

If no, nothing happens, of course.

Everything works fine until I fire the submit button at
the bottom of the form. In the OnClick event handler for
the button, data is inserted and the user is redirected.

However, the event handler isn't fired first, for SOME
reason, the ontextchanged event handler for the password
box gets fired first, screws up my page, and creates a
bunch of errors.

First of all, why does that event fire when nothing
changes about this particular field that would fire the
event?

By all means, the OnClick event handler should be getting
fired, and it does, but only *after* the OnTextChanged
for the password box is fired (when logically, it
shouldn't have!)

Any ideas?

Thanks ahead of time!

-v

Nov 18 '05 #4
Yes you can, by adding an attribute to the password
TextBox control (TextBox.Attributes.Add("value", item);)

This is what I'm doing, however, I'm encrypting it so it
can't be viewed by viewing the source.

Anyhow, that's irrelevant. Why isn't the button's click
event firing *first*!?

-----Original Message-----
I'm not sure but if this is relevant by might the root of this problemin the way password fields are handled? You said the ontextchanged getsfired even when the password hasn't changed. The password field willalways be blank on the form (as you can't populate a password field witha value in html), until something is entered in the field. If you set avalue to a password field then it would always be changed unless someonephysically types the same value in to the password box on your form,otherwise it would be considered to have changed as it will be postedback as blank.

Not sure if that will be any help or not, but from your message itsounds like a possible cause.

Matt
http://www.3internet.co.uk
"V. Jenks" <sp**@scientifik.com> wrote in message
news:55****************************@phx.gbl...
Long story as short as possible:

I have a page (aspx) that contains a user control
(ascx). In the form the user can enter a username and
password. If they do, the password box auto-posts-back
and checks to see if the user already exists in the
database.

If yes, the rest of the form fields on the page are
populated with that existing user's data.

If no, nothing happens, of course.

Everything works fine until I fire the submit button at
the bottom of the form. In the OnClick event handler for the button, data is inserted and the user is redirected.
However, the event handler isn't fired first, for SOME
reason, the ontextchanged event handler for the password box gets fired first, screws up my page, and creates a
bunch of errors.

First of all, why does that event fire when nothing
changes about this particular field that would fire the
event?

By all means, the OnClick event handler should be getting fired, and it does, but only *after* the OnTextChanged
for the password box is fired (when logically, it
shouldn't have!)

Any ideas?

Thanks ahead of time!

-v

.

Nov 18 '05 #5
Yes good point! Not sure why I had thought the password couldn't have a
value assigned to it, although it's logical that you shouldn't be able
to as you say otherwise it's left to you to ensure any encryption, and
this is why you when you set the Text property that no value attribute
is output.

Having said that I think it's still the root of you problem. Setting
the value attribute using the syntax you mention is different to setting
the text value. It is the Text property of the textbox that is checked
against to determine the ontextchange event.

I suspect that if you change your code to set the Text property of the
password field as well as adding the value attribute to the password
field then you would find the ontextchanged event will not fire for the
password field, if it does then a workaround is to check whether the
button has been clicked.

One other thing I am not sure why you expect the onclick event to always
fire first.

Matt
"V. Jenks" <sp**@scientifik.com> wrote in message
news:5a****************************@phx.gbl...
Yes you can, by adding an attribute to the password
TextBox control (TextBox.Attributes.Add("value", item);)

This is what I'm doing, however, I'm encrypting it so it
can't be viewed by viewing the source.

Anyhow, that's irrelevant. Why isn't the button's click
event firing *first*!?

-----Original Message-----
I'm not sure but if this is relevant by might the root

of this problem
in the way password fields are handled? You said the

ontextchanged gets
fired even when the password hasn't changed. The

password field will
always be blank on the form (as you can't populate a

password field with
a value in html), until something is entered in the

field. If you set a
value to a password field then it would always be

changed unless someone
physically types the same value in to the password box

on your form,
otherwise it would be considered to have changed as it

will be posted
back as blank.

Not sure if that will be any help or not, but from your

message it
sounds like a possible cause.

Matt
http://www.3internet.co.uk
"V. Jenks" <sp**@scientifik.com> wrote in message
news:55****************************@phx.gbl...
Long story as short as possible:

I have a page (aspx) that contains a user control
(ascx). In the form the user can enter a username and
password. If they do, the password box auto-posts-back
and checks to see if the user already exists in the
database.

If yes, the rest of the form fields on the page are
populated with that existing user's data.

If no, nothing happens, of course.

Everything works fine until I fire the submit button at
the bottom of the form. In the OnClick event handler for the button, data is inserted and the user is redirected.
However, the event handler isn't fired first, for SOME
reason, the ontextchanged event handler for the password box gets fired first, screws up my page, and creates a
bunch of errors.

First of all, why does that event fire when nothing
changes about this particular field that would fire the
event?

By all means, the OnClick event handler should be getting fired, and it does, but only *after* the OnTextChanged
for the password box is fired (when logically, it
shouldn't have!)

Any ideas?

Thanks ahead of time!

-v

.

Nov 18 '05 #6

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

Similar topics

14
5237
by: Sonic | last post by:
I have an MDE file that is growing exponentially (from 3,900 KB to over 132,000 KB today). I am not saving data in this MDE, although I use a mix of offline and SQL tables for Read Only querying. ...
4
2662
by: BBFrost | last post by:
We have a data entry application written within Framework 1.0 that contains 20+ custom user controls. The controls overlay each other so that only one custom control is visible at a time. What...
1
2156
by: Cy Huckaba | last post by:
We are running our company website on a win2k server running .NET framework 1.0 and IIS 5. The pages consist of mostly static content built from a combination of custom controls (dll is only 148k...
1
3327
by: Earl Teigrob | last post by:
Background: When I create a ASP.NET control (User or custom), it often requires security to be set for certain functionality with the control. For example, a news release user control that is...
6
11057
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
15
6472
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
2
1424
by: Ron | last post by:
I would like some more information on custom controls, what they can do and things like that, what you would use them for etc... Can anyone here share some examples of what you have used a custom...
1
2169
by: Abdo Haji-Ali | last post by:
Previously I used to create user controls if I wanted to use a specific set of controls in multiple pages, however I want to deploy my control in other applications so I thought of creating custom...
4
2463
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...
0
7070
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
7267
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,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6976
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
7449
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
5566
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
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1495
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
372
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.