.NETGURU
Regular Expressions with ASP.NET
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngregexp' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Info@slickworm.com
-- Moved from [aspclient] to [aspngregexp] by Ken Schaefer <Click here to reveal e-mail address> --

I am making a few textbox controls whos values will be added together( so the
input will obviously have to be in the form of an integer).

I will also have form validation controls in this form, and I don't want the
add button to cause validation.

With that, i am going to make a server side validation script that will add the
value of the two text boxes only if they are numbers. I am not too sure what
I'm doing here, but all i know is that 7 hours of my research through
documentation and internet info hasn't helped me at all. I hope someone here
will.
Here is what i have so far...

<%@ Page Language="VB" %>
<Script Language="VB" Runat="Server">
    Sub Text_Change(obj as object, e as eventargs)

    End Sub
    Sub Button_Cont(obj as object, e as eventargs)
        Dim r as New RegEx("[0-9]*")
        Dim m as Match = r.match(tb1.text)
        If m.empty is "1" then
            response.write("No go!")
Else
response.write("Yes!")
        End If
    End Sub
</Script>
<Html>
<Body>
<Form runat="Server">
<asp:textbox id="tb1" OnTextChanged="Text_Change" runat="Server" />

<asp:textbox id="tb2" OnTextChanged="Text_Change" runat="Server" />

<asp:button id="add" OnClick="Button_Cont" Text="Add" runat="Server" />
</form>

Reply to this message...
 
    
Bob Levittan (VIP)
The asp button objects (asp:button, asp:linkbutton, etc) have a
'CausesValidation' property that, when set to 'False', prevents validation
from occuring when the button is clicked.

----Original Message Follows----
From: Click here to reveal e-mail address
Reply-To: "aspngregexp" <Click here to reveal e-mail address>
To: "aspngregexp" <Click here to reveal e-mail address>
Subject: [aspngregexp] Regular Expressions with ASP.NET
Date: Fri, 15 Mar 2002 00:56:01 -0500 (EST)

-- Moved from [aspclient] to [aspngregexp] by Ken Schaefer
<Click here to reveal e-mail address> --

I am making a few textbox controls whos values will be added together( so
the
input will obviously have to be in the form of an integer).

I will also have form validation controls in this form, and I don't want the
add button to cause validation.

With that, i am going to make a server side validation script that will add
the
value of the two text boxes only if they are numbers. I am not too sure what
I'm doing here, but all i know is that 7 hours of my research through
documentation and internet info hasn't helped me at all. I hope someone here
will.
Here is what i have so far...

<%@ Page Language="VB" %>
<Script Language="VB" Runat="Server">
    Sub Text_Change(obj as object, e as eventargs)

    End Sub
    Sub Button_Cont(obj as object, e as eventargs)
        Dim r as New RegEx("[0-9]*")
        Dim m as Match = r.match(tb1.text)
        If m.empty is "1" then
            response.write("No go!")
Else
response.write("Yes!")
        End If
    End Sub
</Script>
<Html>
<Body>
<Form runat="Server">
<asp:textbox id="tb1" OnTextChanged="Text_Change" runat="Server" />

<asp:textbox id="tb2" OnTextChanged="Text_Change" runat="Server" />

<asp:button id="add" OnClick="Button_Cont" Text="Add" runat="Server" />
</form>
| [aspngregexp] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngregexp.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

Reply to this message...
 
    
Wayne King
Is this what you're trying to do in your button click handler?:
Sub Button_Cont(obj as object, e as eventargs)
Dim r as New RegEx("^\d+$")
If r.IsMatch(tb1.Text) AndAlso r.IsMatch(tb2.Text) Then
Trace.Write("Both are integers");
Else
Trace.Write("Both are not integers");
End If
End Sub

This pattern would permit whitespace before or after the number (but not =
within the number):
^\s*\d+\s*$

-----Original Message-----
From: Bob Levittan [mailto:Click here to reveal e-mail address]

The asp button objects (asp:button, asp:linkbutton, etc) have a=20
'CausesValidation' property that, when set to 'False', prevents =
validation=20
from occuring when the button is clicked.

----Original Message Follows----
From: Click here to reveal e-mail address

I am making a few textbox controls whos values will be added together( =
so=20
the
input will obviously have to be in the form of an integer).

I will also have form validation controls in this form, and I don't want =
the
add button to cause validation.

With that, i am going to make a server side validation script that will =
add=20
the
value of the two text boxes only if they are numbers. I am not too sure =
what
I'm doing here, but all i know is that 7 hours of my research through
documentation and internet info hasn't helped me at all. I hope someone =
here
will.
Here is what i have so far...

<%@ Page Language=3D"VB" %>
<Script Language=3D"VB" Runat=3D"Server">
    Sub Text_Change(obj as object, e as eventargs)

    End Sub
    Sub Button_Cont(obj as object, e as eventargs)
        Dim r as New RegEx("[0-9]*")
        Dim m as Match =3D r.match(tb1.text)
        If m.empty is "1" then
            response.write("No go!")
Else
response.write("Yes!")
        End If
    End Sub
</Script>
<Html>
<Body>
<Form runat=3D"Server">
<asp:textbox id=3D"tb1" OnTextChanged=3D"Text_Change" runat=3D"Server" =
/>

<asp:textbox id=3D"tb2" OnTextChanged=3D"Text_Change" runat=3D"Server" =
/>

<asp:button id=3D"add" OnClick=3D"Button_Cont" Text=3D"Add" =
runat=3D"Server" />
</form>

Reply to this message...
 
 
System.Diagnostics.Trace




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification