Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 7th, 2011, 02:22 PM
Authorized User
 
Join Date: Jun 2010
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to put validation for check box?

Dear Imar Sir,
I am designing a service request form like feedback form of
project described in the book the only difference is that i would like to
put a checkbox for term and condtion which is required to check the vistor. I have tried
required field validator but it do not works with check box. Kindly help me.
 
Old November 7th, 2011, 06:14 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can use a custom validator and then do something like

args.IsValid = MyCheckbox.Checked;

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old November 23rd, 2011, 12:56 AM
amaram145
Guest
 
Posts: n/a
Default

if you want the checkbox to update the model via the binder, then you need a boolean value to bind to and name them properly. If Functionality object had bool Selected property then its:

@for(int i=0; i < Model.Functionality.Count; ++i)
{
<tr><td>
@Html.CheckBoxFor(m=>m.Functionality[i].Selected)
@Html.HiddenFor(m=>m.Functionality[i].ID)
@Html.LabelFor(m=>m.Functionality[i].Selected,Model.Functionality[i].DisplayName)
</td></tr>
}
to validate it depends on how you are doing your validation. if you are using unobtrusive validation, then you create a validation attribute, apply to the Selected property. then client side you add a client rule, register it to the adapters. see docs, or google for examples.
 
Old December 16th, 2011, 03:01 AM
Registered User
 
Join Date: Nov 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re:

Quote:
Originally Posted by Imar View Post
You can use a custom validator and then do something like

args.IsValid = MyCheckbox.Checked;

Hope this helps,

Imar

Thanks but i want validate 2 check box at time and forward one check box details to other box.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Validation Check workidoo ASP.NET 3.5 Professionals 3 March 21st, 2009 11:13 AM
put mailto: links on list items in a combo box? webwolf Flash (all versions) 0 September 12th, 2008 08:01 AM
How to put validation with Javascript in Firefox. nitinp ASP.NET 2.0 Professional 0 February 7th, 2007 05:15 AM
How to put a value into another form's text box? alastair Access VBA 3 December 20th, 2006 06:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.