Hi,
Can anyone please post a working example about how to useConfirmOnFormSubmit property ofConfirmButtonExtender ?
Thanks!
Here is a video tutorial on the extender.
http://www.asp.net/learn/ajax-videos/video-119.aspx
Hi,
I'd say ConfirmOnFormSubmit is either deprecated or was never implemented. I don't see it in my object browser. There's not much out there, other than this documentation which seems to be inaccurate:
http://asp.net/ajax/control-toolkit/live/ConfirmButton/ConfirmButton.aspx
It says:
ConfirmOnFormSubmit - True if the confirm dialog should wait until just before the form submits to display. This is useful when ASP.NET validators are in use and the confirm should be shown only after all validators pass.
Pete
Yes Pete. This is the only information I got from the web search.
I tried many time to use it because my project need to do the validation first and ONLY when the validation passed, we need show the confirmation popup.
Thanks anyway!
Within the Button properties, under theConfirmButtonExtender you must set theConfirmOnFormSubmit to'True'
Only then will the Pop-up only appear if validation has passed true.
Here is my code, the ConfirmOnFormSubmit DOES NOT work. Did I get it wrong? Apprecite your help!
TestConfirmButton.aspx
<%@. Page Language="C#" AutoEventWireup="true" CodeFile="TestConfirmButton.aspx.cs" Inherits="TestConfirmButton" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> Enter an even number: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator" ControlToValidate="TextBox1" OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator> <br /> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text="Save" OnClick="Button1_Click" /> <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" ConfirmText="Warning!"ConfirmOnFormSubmit="true" TargetControlID="Button1" Enabled="True"> </ajaxToolkit:ConfirmButtonExtender> <br /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></div> </form></body></html>
TestConfirmButton.aspx.cs
using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partialclass TestConfirmButton : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) { Label1.Text =""; Label2.Text =""; }protected void Button1_Click(object sender, EventArgs e) { Label1.Text ="Saved!";// Display whether the page passed validation.if (Page.IsValid) { Label2.Text ="Page is valid."; }else { Label2.Text ="Page is not valid!"; } }protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) {try {// Test whether the value entered into the text box is even.int i =int.Parse(args.Value); args.IsValid = ((i % 2) == 0);//args.IsValid = false; }catch (Exception ex) { args.IsValid =false; } }}
Correct me, but are you trying to use the 'ConfirmButtonExtender' as a popup for the validation of the even number?
I just used the evaluation of the even number as an example to use the ConfirmButtonExtender's ConfirmOnFormSubmit.
The thing I wanted to achieve is:
The confirm message popups only when the number is even; if the number is odd, then don't popup the confirm message.
Is this do-able at all?
Thanks!
Hi,
The ConfirmOnFormSubmit property indicates that the ConfirmMessage will popup when the page is to be submitted. So, only the failure of client side validation( That's to say, you need to enable clientValidation for this customValidator. ) is able to prevent the form from being submitted, subsequently the ConfirmMessage won't be shown.
Now consider your situation, the confirm box has to be shown when the validation fails, which means the form isn't able to submit. It's a paradox. You may need to implement it withconfirm method.
Hope this helps.
No comments:
Post a Comment