S
Steve Harclerode
This is a standard .Net question, although my starting point is a Commerce
Server 2007 application that I need to modify.
I have a page that includes 2 user controls: a LoginView and a custom
control that is generated dynamically which shows the line items in a
shopping cart. The client does not need to be logged in to see the shopping
cart.
My client has asked me to put a trash can button next to each line item that
can be used to delete that line item. I have everything hooked up and
working, *except* that the postback from the trash button causes validation
for the login form. This means that the validation controls
(RequiredFieldValidator controls) display their error messages after I click
the trash button.
Is there some way to "abort" processing of the validation? It looks as
though the validation is happening on the server side, since I am able to
use the debugger to step into my handler function after hitting the trash
button.
Here's the code for a text field plus the associate validator:
<asp:TextBox ID="UserName" Width="155" runat="server"
CssClass="estoretextbox" ValidationGroup="Login" />
<asp:RequiredFieldValidator ID="reqPassword"
ControlToValidate="Password" ErrorMessage="Please enter Password"
runat="server" Display="Dynamic"
ValidationGroup="Login"></asp:RequiredFieldValidator>
And here's C# code that I use to create the trash button:
ImageButton btnTrash = new ImageButton();
btnTrash.ID =
this.GetUniqueImageControlName(lineItem.LineItemId.ToString());
btnTrash.ImageUrl = "images/trashcan.jpg";
btnTrash.Height = new Unit(15);
btnTrash.Width = new Unit(10);
// Some things I have tried:
//btnTrash.ValidationGroup = "dummy";
//btnTrash.Attributes.Add("onclick", "Page_ValidationActive=false");
//btnTrash.CausesValidation = false;
btnTrash.RenderControl(writer);
btnTrash.ValidationGroup = "dummy";
btnTrash.Attributes.Add("OnServerClick", "TrashButton_Click");
Server 2007 application that I need to modify.
I have a page that includes 2 user controls: a LoginView and a custom
control that is generated dynamically which shows the line items in a
shopping cart. The client does not need to be logged in to see the shopping
cart.
My client has asked me to put a trash can button next to each line item that
can be used to delete that line item. I have everything hooked up and
working, *except* that the postback from the trash button causes validation
for the login form. This means that the validation controls
(RequiredFieldValidator controls) display their error messages after I click
the trash button.
Is there some way to "abort" processing of the validation? It looks as
though the validation is happening on the server side, since I am able to
use the debugger to step into my handler function after hitting the trash
button.
Here's the code for a text field plus the associate validator:
<asp:TextBox ID="UserName" Width="155" runat="server"
CssClass="estoretextbox" ValidationGroup="Login" />
<asp:RequiredFieldValidator ID="reqPassword"
ControlToValidate="Password" ErrorMessage="Please enter Password"
runat="server" Display="Dynamic"
ValidationGroup="Login"></asp:RequiredFieldValidator>
And here's C# code that I use to create the trash button:
ImageButton btnTrash = new ImageButton();
btnTrash.ID =
this.GetUniqueImageControlName(lineItem.LineItemId.ToString());
btnTrash.ImageUrl = "images/trashcan.jpg";
btnTrash.Height = new Unit(15);
btnTrash.Width = new Unit(10);
// Some things I have tried:
//btnTrash.ValidationGroup = "dummy";
//btnTrash.Attributes.Add("onclick", "Page_ValidationActive=false");
//btnTrash.CausesValidation = false;
btnTrash.RenderControl(writer);
btnTrash.ValidationGroup = "dummy";
btnTrash.Attributes.Add("OnServerClick", "TrashButton_Click");