CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 7/30/2003 1:20:08 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 3 Views: 28 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
4 Items, 1 Pages 1 |< << Go >> >|
imonkey
Asp.Net User
Custom Control Problem7/30/2003 1:20:08 PM

0/0

Hello again,

I have just added a custom control to my page whihch validates a card number, if it is wrong it displays a message, as you'd expect.

The problem is that if you do enter in correct details the message is displayed but the form is still submitted, I did not write the control myself but i expected it to stop any further processing like the requirefield validators do.

The other problem I have is that the control is coded in C#, I only know VB.Net (just, lol), but it is as a component which makes it a little harder to change, although I do have all the source files as well.

Is there any way that I could test the isValid for a true or false value as it is isValid that the component returns to the custom control tag?

This is also my first experience of using custom controls.

Any help will be much appreciated!


Thanks,


iMonkey
Thanks,



iMonkey
PLBlum
Asp.Net User
Re: Custom Control Problem7/30/2003 10:50:49 PM

0/0

Hi iMonkey,

I'm not clear if you have received a control that subclasses from Microsoft's BaseValidator class. This is the first step in getting something to eventually work with Microsoft's JavaScript code that makes things happen on the client-side.

Microsoft's RegularExpressionValidator control, available from your toolbox, is often a terrific way to validate any pattern of text, like a credit card number. All you need to do is find the "regular expression" that matches the desired pattern. The RegularExpressionValidator fully supports the client-side validation testing to stop the page.

Here are my favorite links for regular expressions:
The JavaScript language implemention of regular expressions: http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/regexp.html - 1193136
Validation Made Simple with JScript Regular Expressions: http://www.microsoft.com/mind/1098/jscript/jscript.asp
RegExLib.com, A Regular Expression Library: http://www.regexlib.com/
3Leaf Solutions .Net Regular Expression depository: http://www.3leaf.com/default/NetRegExpRepository.aspx

Finally, if the control you have is a CustomValidator or subclasses from BaseValidator, the author must code some JavaScript support for the client-side to set the IsValid property. Since the RegularExpressionValidator may work well for you, I recommend that you go with it.

Quick promo: I have written a replacement to Microsoft's Validation Framework that overcomes its limitations and greatly expands the concepts. It's called "Professional Validation And More". You can learn about it at http://www.PeterBlum.com/VAM/Home.aspx.

--- Peter Blum
Creator of Professional Validation And More Suite, Peter's Date Package, and Peter's Polling Package
www.PeterBlum.com
imonkey
Asp.Net User
Re: Custom Control Problem8/2/2003 9:23:37 AM

0/0

Hi Peter, I have been engrossed in other aspects of the site so have only just got around to following up on this post. First thanks for replying.

Secondly I am not 100% what this code uses, I think I said before I only know VB.NET and not C#, anyway I thought you may be interested to see the code that I am using, this is compiled as a C# component and I just reference it in my code. Its setup seems very similar to that of the Microsoft validators in that you specify the control that it checks and it returns an error message when the validation finds an error.
I have this on a form, as you would, when you click the submit button the form will be submitted and data added to the database but if I press 'Back' (browser button) then it show my data in the form with a message saying that the card is invalid. So I guess it is not stopping the page from submitting.

The component:
using System;

using System.Web.UI;
using System.Web.UI.WebControls;

namespace CustomValidators
{
/// <summary>
/// Summary description for Class1.
/// </summary>

//-- This is allowing us to inherit the BaseValidator's functionality
public class CreditCardValidator : BaseValidator
{
protected override bool EvaluateIsValid()
{
//-- Set valueToValidate to the validation control's controltovalidate value.
string valueToValidate = this.GetControlValidationValue(this.ControlToValidate);
int indicator = 1; //-- will be indicator for every other number
int firstNumToAdd = 0; //-- will be used to store sum of first set of numbers
int secondNumToAdd = 0; //-- will be used to store second set of numbers
string num1; //-- will be used if every other number added is greater
//-- than 10, store the left-most integer here
string num2; //-- will be used if ever yother number added
//-- is greater than 10, store the right-most integer here

//-- Convert our creditNo string to a char array
char[] ccArr = valueToValidate.ToCharArray();

for (int i=ccArr.Length-1;i>=0;i--)
{
char ccNoAdd = ccArr[i];
int ccAdd = Int32.Parse(ccNoAdd.ToString());
if (indicator == 1)
{
//-- If we are on the odd number of numbers, add that number to our total
firstNumToAdd += ccAdd;
//-- set our indicator to 0 so that our code will know to skip to the next piece
indicator = 0;
}
else
{
//-- if the current integer doubled is greater than 10
//-- split the sum in to two integers and add them together
//-- we then add it to our total here
if ((ccAdd + ccAdd) >= 10)
{
int temporary = (ccAdd + ccAdd);
num1 = temporary.ToString().Substring(0,1);
num2 = temporary.ToString().Substring(1,1);
secondNumToAdd += (Convert.ToInt32(num1) + Convert.ToInt32(num2));
}
else
{
//-- otherwise, just add them together and add them to our total
secondNumToAdd += ccAdd + ccAdd;
}
//-- set our indicator to 1 so for the next integer
//-- we will perform a different set of code
indicator = 1;
}
}
//-- If the sum of our 2 numbers is divisible by 10,
//-- then the card is valid. Otherwise, it is not
bool isValid = false;
if ((firstNumToAdd + secondNumToAdd) % 10 == 0)
{
isValid = true;
}
else
{
isValid = false;
}
return isValid;
}
}
}


Thank you once again for your help.

iM
Thanks,



iMonkey
PLBlum
Asp.Net User
Re: Custom Control Problem9/8/2003 10:53:21 PM

0/0

Hi iM,

I'm sorry that I didn't see your response until now. I hope you found your solution. If not, here's a quick answer. You are definitely using Microsoft's BaseValidator so your new control will work on the client. But only if you supply a JavaScript or VBScript function on your page that is called on the client side. Please see the CustomValidator class in the .Net documentation for the ClientValidationFunction property for all the details. Until you add this, the page will submit without validating on the client-side.

--- Peter Blum
Creator of Professional Validation And More Suite, Peter's Date Package, and Peter's Polling Package
www.PeterBlum.com
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
ASP.NET 2.0 Cookbook Authors: Michael A. Kittel, Geoffrey T. Leblond, Pages: 989, Published: 2005
ASP.NET 2.0 Website Programming: Problem-design-solution Authors: Marco Bellinaso, Pages: 576, Published: 2006
International Trade in Endangered Species: A Guide to CITES Authors: David S. Favre, Pages: 415, Published: 1989
Pro .NET 2.0 Windows Forms and Custom Controls in C#: From Professional to Expert Authors: Matthew MacDonald, Pages: 1037, Published: 2005
Instrument Engineers' Handbook: Process Control and Optimization Authors: Bela G. Liptak, Pages: 2464, Published: 2005

Web:
Custom Control problem, please help, WPF, C#,VB.NET,XAML,.NET Home » WPF » Custom Control problem, please help ... I have created a Custom Control Project with two controls inside : - NavBar : TabControl ...
Custom control problem (Templated Control) - ASP.NET Forums In UpdatePanel this works fine the stuff within the template are never null but in my control they are always null, even though I'm exposing ...
MSDN Windows Presentation Foundation (WPF) Custom control problems ... Custom control problems(EDIT). Hi w0lfshad3. I think that this is because the calculation formula is not right. The following example has similar situation ...
custom control problem - Developer Discussion Boards custom control problem Symbian User Interface. ... Re: custom control problem - 2006-06-26, 22:50. Hi, to define your own custom control, ...
Custom Control problems - telerik Forum NET · Input for ASP.NET Custom Control problems ... I want to create a web custom control which is inherited from the Rad input box (masked ...
TheMSsForum.com >> Compact >> Custom control problem under VS 2005 ... File in PDA have to bo transferred automatically when the device is connected to Wnidows ce.NET through USB cable. Tag: Custom control problem under VS 2005 ...
Custom Control problem with ViewState - ASP.NET Forums Re: Custom Control problem with ViewState. 07-20-2008, 7:08 AM. Contact ... Re: Custom Control problem with ViewState. 07-20-2008, 7:42 AM ...
Registry custom control problem... Please help!!!? - Yahoo! Answers Registry custom control problem... Please help!!!? Hi, I have a couple of registry cleaners that can't seem to fix my problem. Registry mechanic tells me ...
compactframework Custom control problem under VS 2005 Beta 2 CF 2.0 Now the custom control works with form inheritance. However this creates a big problem for me. I need to see the datagrid on forms that ...
Color public property of custom user control problem : c# csharp c ... I have created a partially working custom control that basically draws a grid of lines. The two public color properties do not seem to work.

Videos:
Political Rant #24 : UK Problem Reaction Solution Scam The Problem Reaction Solution Paradigm. 1) The Government creates or exploits a problem blaming it on others. 2) The people react by asking the Gove...
How To Enable Custom Themes In Windows Vista (+ SP1) Have a problem? Ask in the forum: http://www.mob3.co.uk/forum or the live chat: http://www.mob3.co.uk/chat Try Vistaglazz first to patch your sys...
The Kitchen of the Future How many times has THIS happened to you: You're making toast... but you wish you were playing a samba! Frustrating, isn't it? But now with The Evolu...
JBL Control Now speaker video JBL Control Now speakers are a new approach to a real problem. How do you integrate good sound into your room without speakers hangining in places th...
All The World's Problems Thank you Bungie for your simple solution to all of the world's problems. *** please take a moment to submit this to xbox360fanboy.com by clicking ...
Tachyon XC Trailer The Tachyon XC - Extreme Camera - is a 2nd-generation video and still helmet cam designed for filming extreme action. It is extremely rugged and v...
How to: Put Custom Songs in GH3 PC Download Guitar Hero 3: Control Panel at http://www.scorehero.com/forum/viewtopic.php?t=69818 Make sure you get the latest version. You also need to...
Ultralight Flying The Tachyon XC - Extreme Camera - is a 2nd-generation video and still helmet cam designed for filming extreme action. It is extremely rugged and v...
Motorocross Helmet Cam The Tachyon XC - Extreme Camera - is a 2nd-generation video and still helmet cam designed for filming extreme action. It is extremely rugged and v...
Shure 515SA Custom Vintage Harp Mic This cool Shure stick mic has been fitted with a female 1/4" jack (to solve the problem of the hard-to-come-by original cable) and a volume control, ...




Search This Site:










compiling to separate dll's question?

.text access

what the text...!?!

pre-set <asp:checkbox> check

using ontextchange with form..

stupid question?

login loses focus to button

update webcontrol on page from server

how to organize my solution

deploying dnn from development to production

database connection

<% %> in dnn

lazy synch userroles

checkout extensions

creating skin objects dynamically?

get computer user without logging in

password recover question error

forgotten password control?

custom skin for win app

themes

how can i set staticmenustyle without using css?

procedure or function has too many arguments specified

release date of vs.net 2005?

to modify the textbox's value of another web application,how to do?

anyway to do a simple pageback ?

too few parameters. expected 16

treeview populateondemand working in firefox and opera, but not in ie 7.0?

web parts in asp.net 3.5 [drag and drop mozilla problem]

inamingcontainer and client side script question

asp.net and c# --- unable to modify textbox from method in class - simple code - beginner

 
All Times Are GMT