[Mono-dev] CausesValidation="false" for asp:Button behavior changed in xsp for v1.1.9.2 vs. v1.0.9.0

Gregory Cook monodev at birdsnestsoftware.net
Tue Oct 11 11:02:13 EDT 2005


It looks like the behavior has changed with xsp ver. 1.1.9.2 with regard
to the CausesValidation attribute on a button.  I am unsure if this is a
problem with mono or my code.

ver. 1.1.9.2 - http://65.12.160.30:8080/DeptAdd.aspx  

For the page above, the cancel button should take you to the main page
at  http://65.12.160.30:8080/Dept.aspx.  This was the behavior with xsp
ver. v1.0.9.0 (mono ver. 1.1.8.3).   The good part is a submit is no
longer performed when attempting to validate prior to submit from the
"Add" button (nice!), client side validation, this was not happening
before.  The bad part is I wanted to have the "Cancel" button take a
user back to the main screen.  Am I doing this correctly?  I know there
are other ways to do this, but since it was working I would like to
understand why it is not working now.  It did used to work, actually it
still does on my laptop, which still has the old xsp version, but same
source code.  Any help is greatly appreciated.  

Just an FYI, I'm still working on this, only departments B-100, and
T-300 have and haven't added a cancel from Details screen yet...

The buttons are declared inside a form in the file DeptAdd.aspx like so:
<!-- // created on 10/7/2005 at 10:52 PM -->
<!-- /* Departments Demo Application  */ -->
<!-- /* Author: Gregory A. Cook       */ -->
<%@ Page language="c#" 
        Codebehind=DeptAdd.aspx.cs 
        AutoEventWireup="false"
        Inherits="NonIT.DeptAdd" %>
<%@ Assembly name="Dept" %>
...
...
...
        
        <asp:Button id="btnAddDept" Text="Add"
OnClick="btnAddDept_Click" CausesValidation="true"
runat="server" />&nbsp;&nbsp;&nbsp;
        <asp:Button id="btnCancel"  Text="Cancel"
OnClick="btnCancel_Click"  CausesValidation="false" runat="server" />
...
...
...
        
I am using code-behind for the events in a file DeptAdd.aspx.cs like so:

    public class DeptAdd: System.Web.UI.Page
    {
                protected System.Web.UI.WebControls.Literal
litError;
                protected System.Web.UI.WebControls.TextBox
txtDepartmentName;
                protected System.Web.UI.WebControls.DropDownList
drpSelectCoreTeam;
                protected System.Web.UI.WebControls.TextBox
txtDepartmentNbr;
                protected System.Web.UI.WebControls.Button
btnAddDept;
                protected System.Web.UI.WebControls.Button
btnCancel;
                protected
System.Web.UI.WebControls.RequiredFieldValidator reqvDepartmentName;
                protected
System.Web.UI.WebControls.RequiredFieldValidator reqvDepartmentNbr;
...
...
...
                private void InitializeComponent()
                {
                        this.Load       += new
System.EventHandler(this.Page_Load);
                        this.PreRender  += new
System.EventHandler(this.PreRender_Handler);
                        this.Unload     += new
System.EventHandler(this.Page_Unload);
                        this.btnAddDept.Click += new
System.EventHandler(this.btnAddDept_Click);
                        this.btnCancel.Click  += new
System.EventHandler(this.btnCancel_Click);
                }
...
...
...
                // Access-level must be protected due to bug fixed in
svn r50950
                //On Wed, 2005-09-28 at 12:35 +0200, Kornél Pál wrote:
                //> Hi,
                //> 
                //> The error is the following:
                //> 
                //> System.Web.UI.HtmlControls/HtmlHead.cs(162,55):
error CS0122:
                //> `System.Web.UI.CssStyleCollection.BagToString()' is
inaccessible due to its
                //> protection level
                //
                //This is fixed in svn r50950.
                //Sorry about that.
                //
                //-Gonzalo              
                protected void btnAddDept_Click(object sender, EventArgs
e)
                {
                        if (!Page.IsValid)
                        {
                                litError.Text = "Some Required fields
are missing!";
                        } 
                        
                }
                
                // Access-level must be protected due to bug fixed in
svn r50950 
                // ...(see comments for btnAddDept_Click() 
                protected void btnCancel_Click(object sender, EventArgs
e)
                {
                        Response.Redirect("../Dept.aspx");
                }
...
...
...


-- 
Gregory A. Cook
Principal, Galexan LLC
Email: gregory.cook at galexan.com





More information about the Mono-devel-list mailing list