|
-
Mar 3rd, 2005, 08:09 AM
#1
Thread Starter
Member
Using Validator cancels my use of attribut
Hello everyone !!
This is my problem, Im justing a alert to ask the user to if he is realy sure to delete something. If he clicks ok it is delete of not, nothing happens.
Everything was fine so far.
(btw I'm talking about a code behinde page combined with asp.net)
This is how I lanch the popup
Code:
Button2.Attributes.Add("OnClick","return confirm('Are you sure you want to delete the item?')");
So I add an Attribiute to my button.
Next I use a RequiredFieldValidator to check if a textbox is fill in.
Code:
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
and in my asp page
Code:
<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"
Now the problem is, that the validation works, but one way or an other it cancels the pop up.
Does someone know what the problem is , or if there is a way to use them both at the same time?
Greetzz ChenZy
-
Mar 3rd, 2005, 12:28 PM
#2
Re: Using Validator cancels my use of attribut
Code:
button2.CausesValidation = false;
-
Mar 8th, 2005, 02:07 AM
#3
Thread Starter
Member
Re: Using Validator cancels my use of attribut
This will make them both work?? The validation and the messagebox?
-
Mar 8th, 2005, 06:52 AM
#4
Re: Using Validator cancels my use of attribut
Just a hunch, but try this:
Code:
Button2.Attributes.Add("OnClick","return confirm('Are you sure you want to delete the item?');");
(note the semicolon)
Although I think that if you're going to do two things for one element, they should be combined. So you could validate and confirm in your own javascript function.
-
Mar 8th, 2005, 12:34 PM
#5
Re: Using Validator cancels my use of attribut
 Originally Posted by Draven Chen Zhen
This will make them both work?? The validation and the messagebox?
Any reason why you want to force the user to enter valid information when they're going to delete the record?
On a related note, when a button causes validation, the .Net framework will automatically render "if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate();" within the "onClick" client side event; clearing any user defined code in the process. Thus, your confirmation will not work if <DeleteButton>.CausesValidation is set to true.
Last edited by axion_sa; Mar 8th, 2005 at 12:42 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|