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(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles Update.Click
If Page.IsValid Then
If Me.NewEmailAddr ess.Text = "" And Me.NewPassword. Text = "" Then
Me.CustomDataCh eck.IsValid = False
Me.CustomDataCh eck2.IsValid = False
ElseIf Me.NewEmailChec k.Text <> "" And Me.NewEmailAddr ess.Text = "" Then
Me.CompEmailChe ck.IsValid = False
ElseIf Me.NewPasswordC heck.Text <> "" And Me.NewPassword. Text = "" Then
Me.CompPassword Check.IsValid = False
ElseIf Me.NewEmailAddr ess.Text = context.Session ("Email") Then
Me.CustomEmailC heck.IsValid = False
Me.CustomEmailC heck.ErrorMessa ge = "Email update failed - Email Address " &
_
Me.NewEmailAddr ess.Text & " is already registered to your account."
Me.CustomEmailC heck.Text = "Opps Already In Use By You!"
ElseIf Me.NewEmailAddr ess.Text <> "" And Me.NewPassword. Text <> "" Then
UpdateAccount(M e.NewEmailAddre ss.Text, Me.NewPassword. Text)
ElseIf Me.NewEmailAddr ess.Text <> "" Then
UpdateAccount(M e.NewEmailAddre ss.Text, Me.CurrentPassw ord.Text)
ElseIf Me.NewPassword. Text <> "" Then
UpdateAccount(c ontext.Session( "Email"), Me.NewPassword. Text)
End If
End If
End Sub 5 2036
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.co m> wrote in message
news:OU******** ******@TK2MSFTN GP09.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(By Val sender As System.Object, ByVal e As System.EventArg s) Handles Update.Click
If Page.IsValid Then
If Me.NewEmailAddr ess.Text = "" And Me.NewPassword. Text = "" Then
Me.CustomDataCh eck.IsValid = False
Me.CustomDataCh eck2.IsValid = False
ElseIf Me.NewEmailChec k.Text <> "" And Me.NewEmailAddr ess.Text = "" Then
Me.CompEmailChe ck.IsValid = False
ElseIf Me.NewPasswordC heck.Text <> "" And Me.NewPassword. Text = "" Then
Me.CompPassword Check.IsValid = False
ElseIf Me.NewEmailAddr ess.Text = context.Session ("Email") Then
Me.CustomEmailC heck.IsValid = False
Me.CustomEmailC heck.ErrorMessa ge = "Email update failed - Email Address " & _
Me.NewEmailAddr ess.Text & " is already registered to your account."
Me.CustomEmailC heck.Text = "Opps Already In Use By You!"
ElseIf Me.NewEmailAddr ess.Text <> "" And Me.NewPassword. Text <> "" Then
UpdateAccount(M e.NewEmailAddre ss.Text, Me.NewPassword. Text)
ElseIf Me.NewEmailAddr ess.Text <> "" Then
UpdateAccount(M e.NewEmailAddre ss.Text, Me.CurrentPassw ord.Text)
ElseIf Me.NewPassword. Text <> "" Then
UpdateAccount(c ontext.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******** **********@TK2M SFTNGP12.phx.gb l... 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.co m> wrote in message news:OU******** ******@TK2MSFTN GP09.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(By Val sender As System.Object, ByVal e As System.EventArg s) Handles Update.Click
If Page.IsValid Then
If Me.NewEmailAddr ess.Text = "" And Me.NewPassword. Text = "" Then
Me.CustomDataCh eck.IsValid = False
Me.CustomDataCh eck2.IsValid = False
ElseIf Me.NewEmailChec k.Text <> "" And Me.NewEmailAddr ess.Text = "" Then
Me.CompEmailChe ck.IsValid = False
ElseIf Me.NewPasswordC heck.Text <> "" And Me.NewPassword. Text = "" Then
Me.CompPassword Check.IsValid = False
ElseIf Me.NewEmailAddr ess.Text = context.Session ("Email") Then
Me.CustomEmailC heck.IsValid = False
Me.CustomEmailC heck.ErrorMessa ge = "Email update failed - Email Address " & _
Me.NewEmailAddr ess.Text & " is already registered to your account."
Me.CustomEmailC heck.Text = "Opps Already In Use By You!"
ElseIf Me.NewEmailAddr ess.Text <> "" And Me.NewPassword. Text <> "" Then
UpdateAccount(M e.NewEmailAddre ss.Text, Me.NewPassword. Text)
ElseIf Me.NewEmailAddr ess.Text <> "" Then
UpdateAccount(M e.NewEmailAddre ss.Text, Me.CurrentPassw ord.Text)
ElseIf Me.NewPassword. Text <> "" Then
UpdateAccount(c ontext.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.co m> wrote in message
news:OU******** ******@TK2MSFTN GP09.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(By Val sender As System.Object, ByVal e As System.EventArg s) Handles Update.Click
If Page.IsValid Then
If Me.NewEmailAddr ess.Text = "" And Me.NewPassword. Text = "" Then
Me.CustomDataCh eck.IsValid = False
Me.CustomDataCh eck2.IsValid = False
ElseIf Me.NewEmailChec k.Text <> "" And Me.NewEmailAddr ess.Text = "" Then
Me.CompEmailChe ck.IsValid = False
ElseIf Me.NewPasswordC heck.Text <> "" And Me.NewPassword. Text = "" Then
Me.CompPassword Check.IsValid = False
ElseIf Me.NewEmailAddr ess.Text = context.Session ("Email") Then
Me.CustomEmailC heck.IsValid = False
Me.CustomEmailC heck.ErrorMessa ge = "Email update failed - Email Address "
& _
Me.NewEmailAddr ess.Text & " is already registered to your account."
Me.CustomEmailC heck.Text = "Opps Already In Use By You!"
ElseIf Me.NewEmailAddr ess.Text <> "" And Me.NewPassword. Text <> "" Then
UpdateAccount(M e.NewEmailAddre ss.Text, Me.NewPassword. Text)
ElseIf Me.NewEmailAddr ess.Text <> "" Then
UpdateAccount(M e.NewEmailAddre ss.Text, Me.CurrentPassw ord.Text)
ElseIf Me.NewPassword. Text <> "" Then
UpdateAccount(c ontext.Session( "Email"), Me.NewPassword. Text)
End If
End If
End Sub
Thanks!
"Kevin Spencer" <ks******@takem pis.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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.co m> wrote in message news:OU******** ******@TK2MSFTN GP09.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(By Val sender As System.Object, ByVal e As System.EventArg s) Handles Update.Click
If Page.IsValid Then
If Me.NewEmailAddr ess.Text = "" And Me.NewPassword. Text = "" Then
Me.CustomDataCh eck.IsValid = False
Me.CustomDataCh eck2.IsValid = False
ElseIf Me.NewEmailChec k.Text <> "" And Me.NewEmailAddr ess.Text = "" Then
Me.CompEmailChe ck.IsValid = False
ElseIf Me.NewPasswordC heck.Text <> "" And Me.NewPassword. Text = "" Then
Me.CompPassword Check.IsValid = False
ElseIf Me.NewEmailAddr ess.Text = context.Session ("Email") Then
Me.CustomEmailC heck.IsValid = False
Me.CustomEmailC heck.ErrorMessa ge = "Email update failed - Email Address " & _
Me.NewEmailAddr ess.Text & " is already registered to your account."
Me.CustomEmailC heck.Text = "Opps Already In Use By You!"
ElseIf Me.NewEmailAddr ess.Text <> "" And Me.NewPassword. Text <> "" Then
UpdateAccount(M e.NewEmailAddre ss.Text, Me.NewPassword. Text)
ElseIf Me.NewEmailAddr ess.Text <> "" Then
UpdateAccount(M e.NewEmailAddre ss.Text, Me.CurrentPassw ord.Text)
ElseIf Me.NewPassword. Text <> "" Then
UpdateAccount(c ontext.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.co m> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. How can I do these validation client side?
"Dan Bass" <danielbass [at] postmaster [dot] co [dot] uk> wrote in message news:e6******** **********@TK2M SFTNGP12.phx.gb l... 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.co m> wrote in message news:OU******** ******@TK2MSFTN GP09.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(By Val sender As System.Object, ByVal e As System.EventArg s) Handles Update.Click
If Page.IsValid Then
If Me.NewEmailAddr ess.Text = "" And Me.NewPassword. Text = "" Then
Me.CustomDataCh eck.IsValid = False
Me.CustomDataCh eck2.IsValid = False
ElseIf Me.NewEmailChec k.Text <> "" And Me.NewEmailAddr ess.Text = "" Then
Me.CompEmailChe ck.IsValid = False
ElseIf Me.NewPasswordC heck.Text <> "" And Me.NewPassword. Text = "" Then
Me.CompPassword Check.IsValid = False
ElseIf Me.NewEmailAddr ess.Text = context.Session ("Email") Then
Me.CustomEmailC heck.IsValid = False
Me.CustomEmailC heck.ErrorMessa ge = "Email update failed - Email Address " & _
Me.NewEmailAddr ess.Text & " is already registered to your account."
Me.CustomEmailC heck.Text = "Opps Already In Use By You!"
ElseIf Me.NewEmailAddr ess.Text <> "" And Me.NewPassword. Text <> "" Then
UpdateAccount(M e.NewEmailAddre ss.Text, Me.NewPassword. Text)
ElseIf Me.NewEmailAddr ess.Text <> "" Then
UpdateAccount(M e.NewEmailAddre ss.Text, Me.CurrentPassw ord.Text)
ElseIf Me.NewPassword. Text <> "" Then
UpdateAccount(c ontext.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 field is completed.
|
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 only 2 conditional it select.
thanks to help me
my script
//condtional//
if ($ttl_dur > 10 and $bay!=$stand and $dpt_reg==0){
$fail=1;
}elseif($ttl_dur > 15 and $bay==$stand and categori==0){
$fail=1;
...
|
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 statement changes.
Basically it looks like this:
If Me.ProjectID.Value <=1835 Then
str = _Select statement 1
ElseIf 1836 <= Me.ProjectID.Value <= 5109 Then
| |
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 "$pass is Winner.\n";
} elseif (($pass-$pass) < ($pass+$pass)) { echo "$pass wins.\n";
} else {
|
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:
if($_POST('assign']='Open in Excel')]...{
}elseif($_POST=='Open in Excel')]...
?
shouldn't it be else instead of elseif?
or should it be
|
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 before it?
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
|
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...
|
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,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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,...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
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...
| |