c# - Treeview validation -


treeview leaf node checkboxes. I need to validate treeview at least one of the nodes checked and not Specfic is doing more (3 nodes say) One user can select the number of nodes Note: Treeview does not have an ASP.NET treeview (not an ajax treeview)

OK, since you did not have it not been told what kind of legalization you want, I have both client side and server I will name my TreeView tvTest
First, a CustomValidator add Asp.Net page for you:

  & lt; ASP: CustomValidator id = "CustomValidator1" runat = "server" ClientValidationFunction = "ClientValidate" errorCare = "CustomValidator" display = "dynamic" OnServerValidate = "CustomValidator1_ServerValidate" & gt; * & Lt; / ASP: CustomValidator & gt;  

Note: ControlToValidate property is not set
After this, add this script to customer's party verification (even on your Asp.Net page). :

  & lt; Script type = "text / javascript" & gt; Function ClientValidate (source, argument) {var TreeView = document.getElementById ("k ";); Var checkboxes = tree view.get elementabatatnam ("input"); Var checked = 0; (Var i = 0; i & lt; checkbox = lamps; i ++) {if (checkbox [i] is checked) {checkedCount ++; }} If (Checked number> 0 & amp; checked number & lt; 4) {arguments.IsValid = true; } And {arguments.IsValid = false; }} & Lt; / Script & gt;  

And finally, add it to its code-behind server-side verification:

  Protected Zero CustomValidator1_ServerValidate (Object Source, System.web.UI.WebControls .ServerValidateEventArgs args) {If (TVTest.Caked Nodes.Count & gt; 0 & amp; amp; TVTest.comCored Nodes.Count & lt; 4) {args.IsValid = true; } Else {args.IsValid = false; }}  

Of course, you will want to change the limit for the minimum and maximum nodes which the user can check.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -