Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
135
UltraWebToolbar, TBarButton and validation
posted

I have a question regarding the UltraWebToolbar control and client-side validation. I only found the CausesValidation property on the UltraWebToolbar control instead of the property being on the individual TBarButton (and other items). This seems like poor design and I really hope I'm just missing something obvious here.

Imagine the following scenario - a web form with some fields, a toolbar with a Save and Close buttons on it. Save should cause validation, Close shouldn't. Right now I had to set CausesValidation to false on the toolbar and then call the ASP.NET validation methods manually in the handler for the Save toolbar button, and this is a really annoying workaround - I actually have a lot of pages with a lot of buttons in toolbars.

Any tips on how to handle such scenarios?

Thank you in advance.

Parents
  • 28407
    posted

    HI,

    you can embedded a standard web button into the a customer control in the webtoolbar.

    here is the code behind

    using System;
    using System.Data;
    using System.Configuration;
    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;
    using Infragistics.WebUI.UltraWebToolbar;

    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            UltraWebToolbar1.CausesValidation = false;
            Button bt = new Button();
            bt.ID = "button2";
            bt.Text = "validate";
           
            bt.CausesValidation = true;
            TBCustom tb = new TBCustom(bt);
            this.UltraWebToolbar1.Items.Add(tb);
            tb.Key = "custom1";
            tb.Children.Add(bt);


        }
    }
    Here is the page

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <%@ Register Assembly="Infragistics2.WebUI.UltraWebToolbar.v7.2, Version=7.2.20072.61, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
        Namespace="Infragistics.WebUI.UltraWebToolbar" TagPrefix="igtbar" %>

    <%@ Register Assembly="Infragistics2.WebUI.WebDateChooser.v7.2, Version=7.2.20072.61, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
        Namespace="Infragistics.WebUI.WebSchedule" TagPrefix="igsch" %>

    <!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>

       

       

       

        <script id="igClientScript" type="text/javascript">
    <!--
    var odate1 = null;
    var odate2 = null;

    function WebDateChooser1_ValueChanged(oDateChooser, newValue, oEvent){
     //Add code to handle your event here.
     debugger;
     var d1 = odate1.getValue();
     var d2 = odate2.getValue();
     if (d2 != null)
      {
        if (d1 > d2)
        {
          odate2.setValue(null);
          alert("bad date");
        }
      }
    }

    function WebDateChooser2_ValueChanged(oDateChooser, newValue, oEvent){
     //Add code to handle your event here.
     debugger;
     var d1 = odate1.getValue();
     var d2 = odate2.getValue();
     if (d2 < d1)
     {
    // alert (d2)
     alert("bad date" + d2);
     odate2.setValue(null);
     }
    }

    function WebDateChooser1_InitializeDateChooser(oDateChooser){
     //Add code to handle your event here.
     odate1 = oDateChooser;
    }

    function WebDateChooser2_InitializeDateChooser(oDateChooser){
     //Add code to handle your event here.
     odate2 = oDateChooser;
    }
    // -->
    </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <igsch:WebDateChooser ID="WebDateChooser1" runat="server">
                <ClientSideEvents ValueChanged="WebDateChooser1_ValueChanged" InitializeDateChooser="WebDateChooser1_InitializeDateChooser" />
            </igsch:WebDateChooser>
            <igsch:WebDateChooser ID="WebDateChooser2" runat="server">
                <ClientSideEvents ValueChanged="WebDateChooser2_ValueChanged" InitializeDateChooser="WebDateChooser2_InitializeDateChooser" />
            </igsch:WebDateChooser>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="WebDateChooser1"
                ErrorMessage="RequiredFieldValidator start date needed"></asp:RequiredFieldValidator>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="WebDateChooser2"
                ErrorMessage="RequiredFieldValidator end date needed"></asp:RequiredFieldValidator>
            <asp:Button ID="Button1" runat="server" Text="Button" />
            <igtbar:UltraWebToolbar ID="UltraWebToolbar1" runat="server">
            </igtbar:UltraWebToolbar>
        </div>
        </form>
    </body>
    </html>

Reply Children
No Data