Firing server side validation & Client side confirm with a single button..

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
hemanth555
2/4/2009 10:23:38 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

6 Replies
1525 Views

Similar Articles

[PageSpeed] 43
Get it on Google Play
Get it on Apple App Store

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
gayathri
2/4/2009 11:56:01 AM

 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
venkatu2005
2/4/2009 11:57:55 AM

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
Ram
2/4/2009 12:47:13 PM

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
2/4/2009 1:43:13 PM

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
budugu
2/4/2009 5:58:57 PM

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
Gary
2/9/2009 3:20:55 AM
Reply:

Similar Artilces:

Firing both Client side event and server side event for server side button
I am having some difficulties getting this to work.. I have button_click (Asp.net) and ClientClick (Javascript).  Javascript is firing fine.  Server script is not. may be you have return return false in the in the javascript which is why its not firing server side event.You should add javascript evelt like thisbutton1.onclientclick = "functionname" Function should nopt return false. Vikram www.vikramlakhotia.comPlease mark the answer if it helped you...

form double validation- server side and client side
Hi! I would like to make a server side validation after calling a js function that makes the client-side validation. I do not understand couple of things: 1. Do i need a server side button or  a simple HTML submit button in order to call both of the tests? 2. How do i call a server side function which is written in csharp  after i finish my JS validation (the submit  button is calling the JS function for validation first.)- is it possible to call it directly from a js function? 3. I know that my toolbox on asp.net  contains validation controls who probably are b...

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in asp.net ( required field, range validator and others)..my question is the required field validator is a server side control. So does that mean that it does a post back?..is it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

Can we check validation both on client side & server side?
 Hi All, Can we check validation both on client side & server side?Thanks & RegardsNeeraj  Yes, the standard asp.net validation controls already do this.Before you process any code on the server side that should have passed through validation you need to check Page.IsValid = trueThis will also catch the situation where the user has javascript disabled. yes you can check validation both the side as per your requirement.Most advantage is that if some user set the JavaScript Enabled False in the Browser settings at that time we don't worry about any validat...

what client-side and server-side events are fired when button X is hit?
Folks,In a web aspx page, I use a client-side (javascript) button named "Cancel" so when users hit it, if the data they enter is not saved yet, then this client-side button prompts users to save data before the page is closed. I code this client-side button with event "onclick" and thing like <input type=button ... onclick="btnCancelClick();" >   My question is if users hit the right top corner button X (next to the maximize and minimize buttons also on the top right corner of the aspx web window page), then what client-side (javascript) and serv...

Client Side HTML Radio Buttons not Posting with Server Side Form
I have a server side form that is posting when an HTML client side button is clicked.  However, the value of my html client side radio button is null when I call Request.Form("htmlradiobuttonlist") on the resulting page.  Does anyone know why the form won't the post the value?  Please help!  Thanks in advance.I'm still using dot net 1.1.  I can use server side buttons or server side radio buttons.  I can explain why if necessary.Below, you can see the HTML radio buttons in the datalist.  The JS function works, but is omitted from below.<form id="form1" a...

custom validator will not fire neither client side or server side
i am trying to validate a dropdownlist but the custom validation will not fire. i want it to fire if the user selects index=0 i have tried client side and server side validation but no luck. plz do not suggest using the required field validation becuse the value of index = 0 is not null or any other validation controll, i need to use the custom validation becuse iam also gonna validat other indexes . <asp:DropDownList ID="categoryDropDownList" runat="server" DataSourceID="catSqlDataSource" DataTextField="cat" DataValueField="catvalue"...

Server side validation affecting client side validation
Hi there I have some client side validation that is working fine and enables/disables buttons based on user selections. This works great. However, when I perform server side validation using custom validators (like checking if the user has entered < HTML > tags or decimals in the integer boxes) and the server side validation returns isValid = false then all of the JavaScript validation that I've already done when the user clicked each control is lost. I don't understand why the enabled/disabled state of the control is not maintained.  What is calling the JavaScr...

client side validation vs server side validation
hello  i see a web form that consists of three controls :textbox,requiredfieldvalidator that weired to the textbox and a button within the click event of the button there is the following: if page.isvalid then response.redirect("Page is valid") else response.redirect("Page is not valid") end if according to my understandings: when the user does not fill anything in the textbox and then clicks the button the the page will not be submitted (i.e no request to the page will be happened or no postback will be happened) then no server event will be happened so it is sure when the us...

Server Side Validation vs Client Side Validation
If your page is using client side validation for required fields, expressions, etc.     What are the benefits or disadvantages of using 'extra' server side validation for max lengths, parsing, etc? Both have their Advantages and Disadvantages... so give this a read http://www.dotnetexpertsforum.com/viewtopic.php?t=172 Regards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeASP.NET hi there, advantage: because you are using javascript some browsers for any reason may not sup...

avoiding redundant server-side validation after client-side validation
I see an inaccurate validation behavior on my asp.net (2.0) form. The EnableClientScript property of my validation control is set to True by default, so it performs the validation on clientside. But as soon as this occurs, it also performs the server-side validation, so the page refreshes. When the validation error occurs on clientside, it should not do the validation on serverside (I'm not calling Page.Validate() or doing Page.IsValid). In my past experience, asp.net handled this automatically, but I guess it's not always the ca...

client side and server side validation
http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/validate/validator8.src&file=CS\validator8.aspx&font=3 i am trying to do custom validation something similar to the above. I hv done the Severvalidate method in the code behind. What about the client validation? do i do it in code behind or in javascript as shown? The goal is to add text like this to the page:<script language='javascript'>function MyFunction(src, args){  // your logic to set args.IsValid here}</script>ASP.NET doesn't care if you typed it directly in...

Client side or server side validation???
I have multiple usercontrols each displayed by pressing a button and then change the apperance to a new user control and so on. I have to check that almost every field in this user controls have a value entered, and then indicate (e.g. with a red star) those textboxes that does'nt have a value entered. How should I do this in the best way, client side or server side with some validator? I have in mind that when using a server side validator, it may dissapear when making a postback. But I'm not sure, and I assume there is a way to come around this problem?What do you all say? Client side or s...

Validations client side or server side ???
Where should the validations (Required field, range, etc.) be done in an web page client side or server side?  As per my knowledge most of the validations are on client side using javascript, unfortunately it won't work if someone has disabled their browsers javascript option. what do we do in this case? Any suggestion please. Both... Client-side for rich client experience. Server-side for data validation and for clients who have disabled javascript. *Always* validate on the server side. You will still get the benefits of client-side validation on browsers setup to handle th...

Web resources about - Firing server side validation & Client side confirm with a single button.. - asp.net.web-forms

Cross-validation (statistics) - Wikipedia, the free encyclopedia
is a model validation technique for assessing how the results of a statistical analysis will generalize to an independent data set. It is mainly ...

Serena Williams eyes history, Caroline Wozniacki craves validation in women's US Open final
As Serena Williams eyes another slice of tennis history, Caroline Wozniacki is craving validation with a watershed US Open final triumph on Sunday ...

Travers Duncan asks High Court to strike down ICAC validation laws
ICAC could be sent back to the High Court as a challenge to new laws validating corruption findings looms.

Adam Scott proclaims Texas win as validation of No.1 ranking
... No.1 golfer, beating American Jason Dufner in the third hole of a play-off at the Colonial event. "It's a good feeling and maybe some validation ...

Hollande to sign gay marriage bill after Constitutional Council's validation
Hollande to sign gay marriage bill after Constitutional Council's validation People's Daily Online ... 26, 27, 28, 29, 30, 31. Jan, Feb, Mar, ...

Marketers, Get Ready for the 'Validation Era'
The public brands included has been engaging in a "friends" arms race. But there are signs that we know we overdid it.

Validation and Uncertainty
What an extraordinary conversation I had recently on Twitter. It started with Neil Killick’s statement that we should not consider our stories ...

Nvidia Icera 410 LTE Modem Passes AT&T Network Validation
... Today's news is a small step and logical precursor toward both goals, Nvidia's Icera 410 LTE and HSPA+ baseband has passed AT&T's network validation ...

Ting’s Q1 Subscriber Growth Suffers from Sprint’s New Unlocking Validation Process
Back in February, Sprint updated the process it uses to validate unlocked devices that customers want to utilize on other carriers or one of ...

[Android M Feature Spotlight] Stricter APK Validation Now Actually Checks If All Of An APK's Files Are ...
While you might file this one under "really? We weren't doing this already?" if you're a security expert, Google has added stricter validation ...

Resources last updated: 12/19/2015 6:36:50 AM