Custom Validation Not Working With Delete Buttons?
Oct 11, 2010
In a ListView, I have a CustomValidator set up to validate a field whenever a button with CommandName="Delete" is clicked.
<ItemTemplate>
<asp:TextBox ID="NameTextBox" Text=<%# Eval("Name") %> runat="server" />
<asp:Button ID="DeleteButton" Text="Delete" CommandName="Delete" ValidationGroup="Delete" runat="server" />
<asp:CustomValidator ValidationGroup="Delete" SetFocusOnError="true" Display="Dynamic" OnServerValidate="CustomValidator_ServerValidate" runat="server">You can't delete this.</asp:CustomValidator>
</ItemTemplate>
However, the error message is never displayed and the processing continues. What's strange is that the custom validation method is called, finds the field, and properly sets up e.IsValid to false. It does not matter whether I check Page.IsValid or not, because the error message is not displayed anyway. It works if I remove the CommandName="Delete" from the button.
With Google I found the following solution, which seems to indicate someone has had a similar issue:
[URL]
But I want to make sure that this solution is the way to go. I mean, is custom validation really not supposed to work with a delete button in a databound control, seriously?
View 1 Replies
Similar Messages:
Sep 4, 2010
I have problem with the buttons Edit and Delete in Gridview for very long time and i really need about it. So the when i click edit i get in edit mode and when click update the values in the row i was changing disappear but only in the gridview. When check in the Database nothing happens. The delete button not works at all, i mean when click on it only refresh the table.
See how looks my page:
Now here's my code in aspx:
[Code]....
Now here's my code in cs:
[Code]....
I'm not sure if the statements not working. P.S. the cancel button works fine.
View 25 Replies
Nov 18, 2010
How do I reference the delete button to add the delete confirmation box when I have both the Edit and Delete buttons as the last two columns in the Gridview control. The following code works fine without any issues when I have the delete button only:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.DataRow) return;
int lastCellIndex = e.Row.Cells.Count - 1;
Button db = (Button)e.Row.Cells[lastCellIndex].Controls[0];
db.OnClientClick = "if (!window.confirm('Are you sure you want to delete this record?')) return false;";
}
But, when I have both the Edit and the Delete buttons, I get the following error when I click the edit button while the delete button works fine.
Specified argument was out of the range of valid values. Parameter name: index
How do I reference the delete button so the edit button is not affected in this case?
View 4 Replies
Dec 25, 2010
Custom Validation Client-Side not working
View 9 Replies
Jan 15, 2010
Here is a code for my web form control
<asp:TextBox runat="server" ID="txtUsername"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtUsername" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:CustomValidator OnServerValidate="checkUsername" ID="CustomValidator1" runat="server" ControlToValidate="txtUsername" EnableClientScript="true" ClientValidationFunction="checkUsername" ErrorMessage="CustomValidator"></asp:CustomValidator>
Client side validation
<script type="text/javascript">
function checkUsername(source,args){
alert("test");
/* alert(args.Value);
[Code]....
View 2 Replies
Feb 5, 2010
i do have a form. inside specific asp:textboxes are "secured" by RequiredFieldValidator and RegularExpressionValidator running. in another div-element i do have buttons, which are expected to load different pages of my website. the problem is: when i click on either of these buttons it is not working as my validation-controls are fired prior to the onclick-button-events.
View 10 Replies
Jan 7, 2010
Does anybody know how to implement this new feature of the MVC 2 RC?
Here is verbatim what ASP.NET MVC 2 Release Candidate Release Notes says:
"...Buttons in a form can specify that they do not cause validation logic to run. The default is that every button in a form causes validation logic to run, and if validation fails, the validation logic blocks submission of the form. Enabling validation selectively for buttons lets you create forms .
View 4 Replies
Mar 29, 2011
How can I show data of a table into a page by using Data controls and add insert, update, and delete buttons?
View 2 Replies
Oct 14, 2011
Creating a list of users with a "Delete" linkbutton next to each". Seems I got it all wrong (again..away from webforms a long time).
Here's what I do:
Building a list of users with delete buttons:
Code:
foreach (var user in users)
{
var usr = user as UserInfo;
var row = new TableRow();
var cell = new TableCell();
[Code] ....
The "Delete""event handler:
Code:
protected void btnRemoveModUser_Click(object sender, EventArgs e)
{
var button = sender as LinkButton;
var userController = new UserController();
var user = userController.GetUser(PortalId, int.Parse(button.CommandArgument));
RemoveUserFromRole(Enums.KnowledgebaseRole.KB_Moderators, user);
}
I got a hunch though it's because of the when/where I'm loading that list of users. I call the function (getting a list of all users, clearing the table and populate it again):
In the page load, if not a postback.
Every time the "Add user" function have been called (that works fine).
Every time the "Delete user" function are called.
The last will not delete the user (still in database) but reload the ^&* form without any users.
I just found that the delete handler does not get called at all, but the button post back the form, so my list of user's don't get loaded.
View 3 Replies
Nov 25, 2013
I have a GridView inside my Asp.Net page, that contains some data from my Sql DataBase.
so my question is how can I add a button in the GridView to update or delete rows from the GridView.
View 1 Replies
May 19, 2010
I am trying to create a custom password validation attribute which has these requirements
1. cannot be empty.
2. doesn't contain space or other special chracters, which I'll define later.
3. length is between 6 - 12
[Code]....
it works fine on the server-side but I'd like to make this work on the client side as well, so I created a PasswordAttributeAdapter class
[Code]....
and in global.asax I added
[Code]....
View 6 Replies
Nov 8, 2010
I have a simple 2 tab panel setup with 2 validation groups. My problem is that my buttons fire both validation groups.
<cc1:TabPanel ID="TP2" runat="server" HeaderText="" Enabled="true">
<HeaderTemplate>Loan Main</HeaderTemplate>
<ContentTemplate>
[code]...
View 1 Replies
Jul 21, 2010
I need a Listview that will show info from several database tables. My delete button, will not delete the record from the database. I cannot get DeleteOnSubmit() to work at all. I am in the very beginner stage. This is my first project. I thought this would be a good project for learning purposes.
Here is my code:
[Code]....
View 4 Replies
Aug 28, 2010
Custom Validation Attribute is not called by validation mechanism?
[Code]....
ViewModel
[Code]....
View 3 Replies
Apr 16, 2010
I have a form, in apge, with validator!
I want it only affects one of buttons! otherwise it does not let the user to change the tabs or do other stuff!!! it keep asks to validate the form!
View 4 Replies
Sep 14, 2010
is there a way to replace the autogenerated edit/delete buttons with icons instead of hyperlinks?
View 2 Replies
Jan 13, 2010
I've been trying to get a custom validator component working that ensures at least one checkbox from a checkboxlist has been checked. I've been used some code I found on dotnetjunkies.com but the client-side validation didn't work. I've been attempting to modify it to get the client-side javascript validation to work with no luck. Basically, I compile the below code into a DLL and add it to my bin folder.
[Code]....
View 2 Replies
Mar 19, 2010
I am creating dropdown controls in code behind. in some conditions I need to add validation control to dropdowlist. But Validation not firing when I submit button.
If mQuestion.RequiredToAnswer = True Then
Dim mValidator As New RequiredFieldValidator
mValidator.ControlToValidate = mDDL.ID
mValidator.InitialValue = mDDL.Items(0).Text
mValidator.Display = ValidatorDisplay.Dynamic
mValidator.ErrorMessage = "* Required!"
mTableCell.Controls.Add(mValidator)
End If
I have other dropdown controls on aspx page with validation comtrols. Those are working fine. Only when I ddl and validations from code not working?
View 1 Replies
Nov 30, 2010
jQuery validation is working fine on my machine, when i pushed it to test server it won't it's throwing some errors which is kind of surprising.These are the errors I am getting: $.validator is null or not an object...I've never gotten this error before and it throwing an error when I declared a variable like var isValid.I don't know what to do. I am doing the custom validation methods not in the document.ready(). Does this cause this error? I wonder because all jquery validations are passing and hitting the server side validations.
View 1 Replies
May 25, 2010
I've got a custom control with asp:hyperlinks that's causing validation which I don't want... Is there anyway I can stop this from happening?
View 1 Replies
Mar 3, 2011
i am having an mvc 2 application in which i have a form that contains two buttons
[Code]....
Now my requirement is to disable validation when the user clicks `Add` button. But validate when the user clicks `Save` Button.
View 5 Replies
Jul 8, 2010
I have a gridview (gridview-a) with a link button when the user click on this link button it opens a separate modal pop up extender with another grid view (gridview-b) (working fine) I added a close button inside the panel. When the user click on it the modal pop up is getting closed. Excellent.
Now my problem is When I add Edit,Save and Update buttons to the gridview-b ( i.e. Present inside Popup) when ever I click on the edit , or save or update buttons it is going to the gridview-a. How can I avoid that? Do I have to keep the gridview inside a update Panel and make the update mode conditional? If thats true how can I edit , save and delete the rows ( I need to call stored prcedures and all row-databound functions to do that)
View 5 Replies
Oct 3, 2010
It should be simple, but I didn't found yet how to do it. There is only one user (Admin with user name and passowrd, he has a cookie so I know when he is watching the page) I would like to show him the Update/Delete/Insert button options in my ListView, but to the other users I don't want them to be able doing this kind of things, So it should be hidden from them. How I am doing it in C# code? Showing/Hiding these buttons?
View 3 Replies
Mar 12, 2010
When to go for custom validation control and when to do validation in javascript? What are pros and cons of each of them?
View 3 Replies
Aug 5, 2010
i made a after delete trigger on a table1 and in this trigger i insert the deleted data in another table name tab2.
when i execute the delete stored procedure of table1 from sql server 2005 then trigger working fine but when i execute delete stored procedure of table1 from c# then it is not working properly.
View 1 Replies