Is there anyway I could clean-up all these ElseIF statements with a
select/case or is this the best that can be done ("I can't think of a better
way")?
Private Sub Update_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Update.Click
If Page.IsValid Then
If Me.NewEmailAddress.Text = "" And Me.NewPassword.Text = "" Then
Me.CustomDataCheck.IsValid = False
Me.CustomDataCheck2.IsValid = False
ElseIf Me.NewEmailCheck.Text <> "" And Me.NewEmailAddress.Text = "" Then
Me.CompEmailCheck.IsValid = False
ElseIf Me.NewPasswordCheck.Text <> "" And Me.NewPassword.Text = "" Then
Me.CompPasswordCheck.IsValid = False
ElseIf Me.NewEmailAddress.Text = context.Session("Email") Then
Me.CustomEmailCheck.IsValid = False
Me.CustomEmailCheck.ErrorMessage = "Email update failed - Email Address " &
_
Me.NewEmailAddress.Text & " is already registered to your account."
Me.CustomEmailCheck.Text = "Opps Already In Use By You!"
ElseIf Me.NewEmailAddress.Text <> "" And Me.NewPassword.Text <> "" Then
UpdateAccount(Me.NewEmailAddress.Text, Me.NewPassword.Text)
ElseIf Me.NewEmailAddress.Text <> "" Then
UpdateAccount(Me.NewEmailAddress.Text, Me.CurrentPassword.Text)
ElseIf Me.NewPassword.Text <> "" Then
UpdateAccount(context.Session("Email"), Me.NewPassword.Text)
End If
End If
End Sub 5 2008
Leon,
It looks like a load of page validation which could be done client side with
some validators... This would only allow a postback (and hence Update_Click)
to fire once the Validators have been passed, eliminating the need for the
checking to be done in this method.
Thanks.
Dan.
"Leon" <vn*****@msn.com> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl... Is there anyway I could clean-up all these ElseIF statements with a select/case or is this the best that can be done ("I can't think of a better way")?
Private Sub Update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Update.Click
If Page.IsValid Then
If Me.NewEmailAddress.Text = "" And Me.NewPassword.Text = "" Then
Me.CustomDataCheck.IsValid = False
Me.CustomDataCheck2.IsValid = False
ElseIf Me.NewEmailCheck.Text <> "" And Me.NewEmailAddress.Text = "" Then
Me.CompEmailCheck.IsValid = False
ElseIf Me.NewPasswordCheck.Text <> "" And Me.NewPassword.Text = "" Then
Me.CompPasswordCheck.IsValid = False
ElseIf Me.NewEmailAddress.Text = context.Session("Email") Then
Me.CustomEmailCheck.IsValid = False
Me.CustomEmailCheck.ErrorMessage = "Email update failed - Email Address " & _
Me.NewEmailAddress.Text & " is already registered to your account."
Me.CustomEmailCheck.Text = "Opps Already In Use By You!"
ElseIf Me.NewEmailAddress.Text <> "" And Me.NewPassword.Text <> "" Then
UpdateAccount(Me.NewEmailAddress.Text, Me.NewPassword.Text)
ElseIf Me.NewEmailAddress.Text <> "" Then
UpdateAccount(Me.NewEmailAddress.Text, Me.CurrentPassword.Text)
ElseIf Me.NewPassword.Text <> "" Then
UpdateAccount(context.Session("Email"), Me.NewPassword.Text)
End If
End If
End Sub
How can I do these validation client side?
"Dan Bass" <danielbass [at] postmaster [dot] co [dot] uk> wrote in message
news:e6******************@TK2MSFTNGP12.phx.gbl... Leon,
It looks like a load of page validation which could be done client side with some validators... This would only allow a postback (and hence Update_Click) to fire once the Validators have been passed, eliminating the need for the checking to be done in this method.
Thanks. Dan.
"Leon" <vn*****@msn.com> wrote in message news:OU**************@TK2MSFTNGP09.phx.gbl... Is there anyway I could clean-up all these ElseIF statements with a select/case or is this the best that can be done ("I can't think of a better way")?
Private Sub Update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Update.Click
If Page.IsValid Then
If Me.NewEmailAddress.Text = "" And Me.NewPassword.Text = "" Then
Me.CustomDataCheck.IsValid = False
Me.CustomDataCheck2.IsValid = False
ElseIf Me.NewEmailCheck.Text <> "" And Me.NewEmailAddress.Text = "" Then
Me.CompEmailCheck.IsValid = False
ElseIf Me.NewPasswordCheck.Text <> "" And Me.NewPassword.Text = "" Then
Me.CompPasswordCheck.IsValid = False
ElseIf Me.NewEmailAddress.Text = context.Session("Email") Then
Me.CustomEmailCheck.IsValid = False
Me.CustomEmailCheck.ErrorMessage = "Email update failed - Email Address " & _
Me.NewEmailAddress.Text & " is already registered to your account."
Me.CustomEmailCheck.Text = "Opps Already In Use By You!"
ElseIf Me.NewEmailAddress.Text <> "" And Me.NewPassword.Text <> "" Then
UpdateAccount(Me.NewEmailAddress.Text, Me.NewPassword.Text)
ElseIf Me.NewEmailAddress.Text <> "" Then
UpdateAccount(Me.NewEmailAddress.Text, Me.CurrentPassword.Text)
ElseIf Me.NewPassword.Text <> "" Then
UpdateAccount(context.Session("Email"), Me.NewPassword.Text)
End If
End If
End Sub
A Select Case statement only works when you are comparing against a single
value. If the logic in your code represents the way you want it to run, I
believe you've come up with about the best you can do here.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"Leon" <vn*****@msn.com> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl... Is there anyway I could clean-up all these ElseIF statements with a select/case or is this the best that can be done ("I can't think of a
better way")?
Private Sub Update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Update.Click
If Page.IsValid Then
If Me.NewEmailAddress.Text = "" And Me.NewPassword.Text = "" Then
Me.CustomDataCheck.IsValid = False
Me.CustomDataCheck2.IsValid = False
ElseIf Me.NewEmailCheck.Text <> "" And Me.NewEmailAddress.Text = "" Then
Me.CompEmailCheck.IsValid = False
ElseIf Me.NewPasswordCheck.Text <> "" And Me.NewPassword.Text = "" Then
Me.CompPasswordCheck.IsValid = False
ElseIf Me.NewEmailAddress.Text = context.Session("Email") Then
Me.CustomEmailCheck.IsValid = False
Me.CustomEmailCheck.ErrorMessage = "Email update failed - Email Address "
& _
Me.NewEmailAddress.Text & " is already registered to your account."
Me.CustomEmailCheck.Text = "Opps Already In Use By You!"
ElseIf Me.NewEmailAddress.Text <> "" And Me.NewPassword.Text <> "" Then
UpdateAccount(Me.NewEmailAddress.Text, Me.NewPassword.Text)
ElseIf Me.NewEmailAddress.Text <> "" Then
UpdateAccount(Me.NewEmailAddress.Text, Me.CurrentPassword.Text)
ElseIf Me.NewPassword.Text <> "" Then
UpdateAccount(context.Session("Email"), Me.NewPassword.Text)
End If
End If
End Sub
Thanks!
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... A Select Case statement only works when you are comparing against a single value. If the logic in your code represents the way you want it to run, I believe you've come up with about the best you can do here.
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Neither a follower nor a lender be.
"Leon" <vn*****@msn.com> wrote in message news:OU**************@TK2MSFTNGP09.phx.gbl... Is there anyway I could clean-up all these ElseIF statements with a select/case or is this the best that can be done ("I can't think of a better way")?
Private Sub Update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Update.Click
If Page.IsValid Then
If Me.NewEmailAddress.Text = "" And Me.NewPassword.Text = "" Then
Me.CustomDataCheck.IsValid = False
Me.CustomDataCheck2.IsValid = False
ElseIf Me.NewEmailCheck.Text <> "" And Me.NewEmailAddress.Text = "" Then
Me.CompEmailCheck.IsValid = False
ElseIf Me.NewPasswordCheck.Text <> "" And Me.NewPassword.Text = "" Then
Me.CompPasswordCheck.IsValid = False
ElseIf Me.NewEmailAddress.Text = context.Session("Email") Then
Me.CustomEmailCheck.IsValid = False
Me.CustomEmailCheck.ErrorMessage = "Email update failed - Email Address " & _
Me.NewEmailAddress.Text & " is already registered to your account."
Me.CustomEmailCheck.Text = "Opps Already In Use By You!"
ElseIf Me.NewEmailAddress.Text <> "" And Me.NewPassword.Text <> "" Then
UpdateAccount(Me.NewEmailAddress.Text, Me.NewPassword.Text)
ElseIf Me.NewEmailAddress.Text <> "" Then
UpdateAccount(Me.NewEmailAddress.Text, Me.CurrentPassword.Text)
ElseIf Me.NewPassword.Text <> "" Then
UpdateAccount(context.Session("Email"), Me.NewPassword.Text)
End If
End If
End Sub
Do a search on validators and asp.net...
I found this: http://msdn.microsoft.com/library/de..._userinput.asp
[beware of line wraps]
let me know if you get stuck
"Leon" <vn*****@msn.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... How can I do these validation client side?
"Dan Bass" <danielbass [at] postmaster [dot] co [dot] uk> wrote in message news:e6******************@TK2MSFTNGP12.phx.gbl... Leon,
It looks like a load of page validation which could be done client side with some validators... This would only allow a postback (and hence Update_Click) to fire once the Validators have been passed, eliminating the need for the checking to be done in this method.
Thanks. Dan.
"Leon" <vn*****@msn.com> wrote in message news:OU**************@TK2MSFTNGP09.phx.gbl... Is there anyway I could clean-up all these ElseIF statements with a select/case or is this the best that can be done ("I can't think of a better way")?
Private Sub Update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Update.Click
If Page.IsValid Then
If Me.NewEmailAddress.Text = "" And Me.NewPassword.Text = "" Then
Me.CustomDataCheck.IsValid = False
Me.CustomDataCheck2.IsValid = False
ElseIf Me.NewEmailCheck.Text <> "" And Me.NewEmailAddress.Text = "" Then
Me.CompEmailCheck.IsValid = False
ElseIf Me.NewPasswordCheck.Text <> "" And Me.NewPassword.Text = "" Then
Me.CompPasswordCheck.IsValid = False
ElseIf Me.NewEmailAddress.Text = context.Session("Email") Then
Me.CustomEmailCheck.IsValid = False
Me.CustomEmailCheck.ErrorMessage = "Email update failed - Email Address " & _
Me.NewEmailAddress.Text & " is already registered to your account."
Me.CustomEmailCheck.Text = "Opps Already In Use By You!"
ElseIf Me.NewEmailAddress.Text <> "" And Me.NewPassword.Text <> "" Then
UpdateAccount(Me.NewEmailAddress.Text, Me.NewPassword.Text)
ElseIf Me.NewEmailAddress.Text <> "" Then
UpdateAccount(Me.NewEmailAddress.Text, Me.CurrentPassword.Text)
ElseIf Me.NewPassword.Text <> "" Then
UpdateAccount(context.Session("Email"), Me.NewPassword.Text)
End If
End If
End Sub
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: James |
last post by:
Hi,
I have a form with 2 fields.
'A'
'B'
The user completes one of the fields and the form is submitted.
On the results page I want to run a query, but this will change
subject to which...
|
by: Lauren Quantrell |
last post by:
Is there any speed/resource advantage/disadvantage in using
Select Case x
Case 1
Case 2
etc. many more cases...
End Select
VS.
|
by: Ivan Sergio Borgonovo |
last post by:
First thanks to Tom Lane who helped me promptly.
Now let's come to the problem:
create or replace function testa( )
returns char(32) as
'
begin
if 1=2 then
if 1=2 then
|
by: amrhi |
last post by:
Hy guys , I try to make conditional statement by using if and elseif .
the problem are if i use 2 conditional statement the script run well but if try add more conditinal statement it's not working...
|
by: RobinAG |
last post by:
I'm having a wierd difficulty with my If...ElseIf...Else...End If statement.
I'm having the db put together a string to base a recordset off of, and depending on the ID number, the select...
|
by: patsman77 |
last post by:
Hello All,
I have a slight problem/small question....
I am trying this code out, but am not getting correct results.... any help would be great.
if (($pass-$pass) > ($pass+$pass)) {
echo...
|
by: JRough |
last post by:
I'm trying to get error proof code.
I have this code which seems to work but now I look at it I think it
should be elseif not else and I wonder why it works. It is in the
block:...
|
by: Tim Roberts |
last post by:
JRough <jlrough@yahoo.comwrote:
More than the syntax problems, you also have a logic problem here. How do
you think that "if" statement is ever going to be hit, given the statement
immediately...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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...
|
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...
| |