473,606 Members | 3,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to validate() User Control at Page submit?

Hi all,

I've created an User control. It's an extension of a textbox wich has
some extra properties so that validation becomes a lot faster.

The control wordks great if autopostback is on. When there's a value
in the textbox, the (overridden) textchanged event fires and
validation is performed.

Now I want to turn off autopostback. So I want my contol only validate
if the submit button is pressed. I've tried Page.Validate() , but It
seems only to trigger Validators. My control doesn't have to have
validators, but just raises an error.

So, I think the question is: how do I trigger the overridden
textchanged event of my custom control, preferably without writing
code in de click event of the submit-button?

Greetz,
Owin
Amsterdam

Nov 18 '05 #1
4 15674
"owingruter s" <ow*********@ho tmail-dot-com.no-spam.invalid> wrote in message
news:40******** @Usenet.com...
Hi all,

I've created an User control. It's an extension of a textbox wich has
some extra properties so that validation becomes a lot faster.

The control wordks great if autopostback is on. When there's a value
in the textbox, the (overridden) textchanged event fires and
validation is performed.

Now I want to turn off autopostback. So I want my contol only validate
if the submit button is pressed. I've tried Page.Validate() , but It
seems only to trigger Validators. My control doesn't have to have
validators, but just raises an error.

So, I think the question is: how do I trigger the overridden
textchanged event of my custom control, preferably without writing
code in de click event of the submit-button?

Owin, perhaps you'd do better to use the validation framework. I hope the
following will help:

ASP.NET Validation in Depth
(http://msdn.microsoft.com/library/de...-us/dnaspp/htm
l/aspplusvalid.as p).
--
John Saunders
johnwsaundersii i at hotmail

Nov 18 '05 #2
The text changed event should fire if the text in the box is different on
post back whether that post back was triggered by an auto post back or by
the submit button.

To make certain the control is valid use: If Page.IsValid Then

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"owingruter s" <ow*********@ho tmail-dot-com.no-spam.invalid> wrote in message
news:40******** @Usenet.com...
Hi all,

I've created an User control. It's an extension of a textbox wich has
some extra properties so that validation becomes a lot faster.

The control wordks great if autopostback is on. When there's a value
in the textbox, the (overridden) textchanged event fires and
validation is performed.

Now I want to turn off autopostback. So I want my contol only validate
if the submit button is pressed. I've tried Page.Validate() , but It
seems only to trigger Validators. My control doesn't have to have
validators, but just raises an error.

So, I think the question is: how do I trigger the overridden
textchanged event of my custom control, preferably without writing
code in de click event of the submit-button?

Greetz,
Owin
Amsterdam

Nov 18 '05 #3
Thank you both.

The article did not contain a solution, but it made some things clear
about the sequence in which events are handled.

And S. Justin...You were right. The event does fire. But there is one
difference: When my usercontrols Non_Validating event fires and
valdation failes, I turn the IsValid property of a CustomValidator to
false, to prevent the page from Validating.

With the autopostback property on, this is the only event that fires,
so the cuctomvalidator and the page are invalid.
When I turn the autopostback off and use a submit button to submit the
page, the bottum_click event also fires and as I found out does a
Page.Validate() .
If I turn the IsValid property to false in the Non_validating event,
the Page.IsValid property also changes to falsen. Then the
Page.Validate() method is executes, and the Page.IsValid property is
set to true again.

The only way I can solve this seemes to me to make a private variable
to remember if the control valided or not and set the
customvalidator .Isvald property again in the button_click event.

This works, but I don't want the users of my custum control to have to
know all these things.

Have u got any ideas of how to solve this?
My only idea left is to not make a custom textbox, but a custom
customvalidator :) that performs the validation that I want.

Thanx for any help,
Owin

Nov 18 '05 #4
Owen,

I think you've thought this out well. A "custom" custom validator is
probably the best way to go.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"owingruter s" <ow*********@ho tmail-dot-com.no-spam.invalid> wrote in message
news:40******** @Usenet.com...
Thank you both.

The article did not contain a solution, but it made some things clear
about the sequence in which events are handled.

And S. Justin...You were right. The event does fire. But there is one
difference: When my usercontrols Non_Validating event fires and
valdation failes, I turn the IsValid property of a CustomValidator to
false, to prevent the page from Validating.

With the autopostback property on, this is the only event that fires,
so the cuctomvalidator and the page are invalid.
When I turn the autopostback off and use a submit button to submit the
page, the bottum_click event also fires and as I found out does a
Page.Validate() .
If I turn the IsValid property to false in the Non_validating event,
the Page.IsValid property also changes to falsen. Then the
Page.Validate() method is executes, and the Page.IsValid property is
set to true again.

The only way I can solve this seemes to me to make a private variable
to remember if the control valided or not and set the
customvalidator .Isvald property again in the button_click event.

This works, but I don't want the users of my custum control to have to
know all these things.

Have u got any ideas of how to solve this?
My only idea left is to not make a custom textbox, but a custom
customvalidator :) that performs the validation that I want.

Thanx for any help,
Owin

Nov 18 '05 #5

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

Similar topics

10
3162
by: Alphonse Giambrone | last post by:
I have a web form with 2 user controls on it (UC1 and UC2). Each control has a bound datagrid with textboxes in the footer to add a new row. There are also requiredfieldvalidators in each footer. When I try to add a new row to UC1 the requiredfieldvalidators for UC2 fire and therefore the page is not posted. If I remove one control, everything works fine. I have 2 questions. 1. How can I get the validators for each control to only...
4
4277
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage I know I need to call a function that will save data but I'm not sure exactly when to call this function. I've tried two ways and both seem to have 'gotcha's':
3
2840
by: Bijoy Naick | last post by:
I've written a simple file upload user control in VB .NET. It comprises of an InputFile HTML Server Control, an Upload button and a message label. User clicks on the Browse button of the InputFile control, selects a file, then clicks on the Upload button. The file is saved to a folder on the server and the message label displays the appropriate msg. The user control also has a SetFilePath method.. This is used by the page which includes...
11
2114
by: wolf | last post by:
There are three webcontrol on my asp.net form: a TextBox, a submit button and a RegularExpressionValidator. And I had set ControlToValidate property of the RegularExpressionValidator to the TextBox. But now, when I input a string in the textbox and press Enter key, the form was submit without client javascript validate. Why? And what should I do to enable client validate before submit the form whethe press Enter key or click Submit...
13
6216
by: Michael | last post by:
I have setup a public variable in the Master Page "code-behind-file". Now I would like to set that value from the UserControl, but I can't seem to find a way to do this. Does anyone have any ideas? I'm basically trying to set it up so that I can keep the User infor (userid, ect) in the Masterpage so that other pages can access it. Thanks for any ideas. Michael
1
4420
by: Smokey Grindle | last post by:
to start off with the page the free text box (version 3) is on has validateRequest="false" in the page directive already... but even with that when I am in the page and then click on a link to another page (as long as its changing pages, not posting back) it says this System.Web.HttpException was unhandled by user code ErrorCode=-2147467259 Message="Error executing child request for /msg/Secure/Default.aspx." Source="System.Web"
2
4810
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be required: <%@ Register TagPrefix="UC" TagName="MyUserCtrl" Src="MyUC.ascx" %> Assuming that the ASPX page doesn't use a code-behind, I can access the properties, events etc. of the user control in the ASPX page in this way (assume that the ASPX page...
10
6841
by: kelvin | last post by:
Hi, A difficult question. I have a form that I used to submit to https://www. paypal.com/cgi-bin/ webscr <form action="https://www. paypal.com/cgi-bin/webscr" method="post"> Now I need to validate some inputs of this form, so I submit it to a PHP page in my own server first.
2
5718
by: thj | last post by:
Hi. I've got this form that I'm trying to validate: <form id="periodForm" action="" method="post"> <p> Periode: <input id="startDate" name="startDate" type="text" size="7" value="<%= ViewData %>" /> -
0
8036
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7978
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8461
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8126
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8317
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
3948
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4010
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2454
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 we have to send another system
0
1313
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.