Hello!
I have some problems with validatng fields through radGrid/popup edit form. The fields to be validated are used in both 'Add' and 'Edit' popups, but validation works only in 'Add' form. Here is my approach. In ascx file:
And on cs file the validation function:
Aditionally the ascx file is build in a way that the same file defines edit and add forms so that fields used in both are the same. So basically the submit is done by following button definitions:
So, basically when using the 'Add' popup the system prints an error text if the field is not valid, but doesn't do the same when using 'Edit'. I don't know where to start digging. Help on this would be much appreciated.
-Sami
I have some problems with validatng fields through radGrid/popup edit form. The fields to be validated are used in both 'Add' and 'Edit' popups, but validation works only in 'Add' form. Here is my approach. In ascx file:
<
th
>Amount:</
th
>
<
td
><
asp:TextBox
ID
=
"txtAmount"
runat
=
"server"
/>
<
asp:CustomValidator
ID
=
"ResourceValidator2"
runat
=
"server"
Display
=
"dynamic"
ValidateEmptyText
=
"true"
ControlToValidate
=
"txtAmount"
ErrorMessage
=
"Amount has to be entered and it has to be numeric value. "
OnServerValidate
=
"Validate_RealizationAmount"
/>
</
td
>
And on cs file the validation function:
protected
void
Validate_RealizationAmount(
object
source, ServerValidateEventArgs args)
{
double
priceNum;
if
(txtAmount.Text ==
""
||
!
double
.TryParse(txtAmount.Text.Trim(),
out
priceNum))
{
args.IsValid =
false
;
}
}
Aditionally the ascx file is build in a way that the same file defines edit and add forms so that fields used in both are the same. So basically the submit is done by following button definitions:
<
asp:LinkButton
ID
=
"btnUpdateEdited"
runat
=
"server"
CommandName='<%# DataItem is Telerik.Web.UI.GridInsertionObject ? "PerformInsert" : "UpdateEdited" %>'>
<
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
/>
<%# DataItem is Telerik.Web.UI.GridInsertionObject ? "Add" : "Update"%>
</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"btnCancel"
runat
=
"server"
CommandName
=
"CancelAll"
>
<
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
/>Peruuta
</
asp:LinkButton
>
So, basically when using the 'Add' popup the system prints an error text if the field is not valid, but doesn't do the same when using 'Edit'. I don't know where to start digging. Help on this would be much appreciated.
-Sami