Hi All,
I have a "Update" asp button. onclick of the button i need to check the server side validations like:
if (!IsValidEmail(ctrlEmailAddress.TextBoxControl.Text.Trim())){
MessageBox.Show("Enter valid email address");validateCheck =
false;}
After completion of this type of validations, i need to fire one javascript confirmbox saying "Are you sure you want to update this order?" with "Yes/No" options.
All these things needs to be done in a single button click.
Can any one help me to acheive this ..requirement?
-Hemanth
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
![]() |
0 |
![]() |
This can be done by provinding Onclick & OnClientClick for the Button.
For Example
<
asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" OnClientClick="function();" />
Mark as Answer if it helped you
Gayathri
![]() |
0 |
![]() |
When you using both serverside and client side validation..
first it will check the client side validataion then only ,
it looks for Server side.. code..
Regards,
M.Venkatesan
My Blog : http://venkat-dotnetsamples.blogspot.com
Please remember to click “Mark as Answer” on the post that helps you,and to click “Unmark as Answer” if a marked post does not actually answer your question.
![]() |
0 |
![]() |
If you want you can do like this...
<
asp:TextBox ID="txtemail" runat="server"></asp:TextBox> <asp:Button ID="btnUpdate" runat="server" Text="Update" OnClientClick="return abcd();" OnClick="btnUpdate_Click" /><
script type="text/javascript">function abcd(){
debugger;if(ValidateEmail() == true){
if(ret() == true){
return true;}
else{
return false;}
}
}
function ValidateEmail(){
debugger; var EmaiAddress = window.document.getElementById('<%=txtemail.ClientID %>').value; var RegExEmail = /^(?:\w+\.?)*\w+@(?:\w+\.)+\w+$/; if (!RegExEmail.test(EmaiAddress)){
return false;}
else{
return true;}
}
function ret(){
debugger; var r = confirm('R u sure?')if(r == true){
return true;} else{return false;}}
</script>protected void btnUpdate_Click(object sender, EventArgs e){
//code to update.}
Regards,
Ram Reddy Mekha, +91-994-840-4315
http://abhiramreddymekha.blogspot.com
Please Mark as Answer if the post helps you.
![]() |
0 |
![]() |
Hi Venkatesan,
I know that.. and in the same time you are right... I think you understand my requirement.
But, what to do that is my requirement. If you find any alternative please let me know.
For Others:
=======
Onclick & OnClientClick: I have already tried these thing. But, not suitable for my requirement.
But altimately Button first fires Client side code and then Server side for your information.
-Hemanth
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
![]() |
0 |
![]() |
hemanth555:
But altimately Button first fires Client side code and then Server side for your information.If you are just checking whether it's valid email address or not, how about using regular expression validator for that?
Secondly when you are doing sever side validation first, can do all validations at server right? Then why do you want to go back to client and do client validation?
Let me know if i am missing some thing here.
My Blog
"Don't be afraid to be wrong; otherwise you'll never be right."
![]() |
0 |
![]() |
hemanth555:
Hi Venkatesan,
I know that.. and in the same time you are right... I think you understand my requirement.
But, what to do that is my requirement. If you find any alternative please let me know.
For Others:
=======
Onclick & OnClientClick: I have already tried these thing. But, not suitable for my requirement.
But altimately Button first fires Client side code and then Server side for your information.
I think it is difficult to achieve it if you want to validate the data on Server-Side first. Because it just opposition. It always validate it first on Client-Side. If you do hope to do it, I suggest you achieve it by using Ajax and WebServices.
Gary yang - MSFT
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
![]() |
0 |
![]() |