Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 7th, 2011, 02:22 PM
Authorized User
Points: 265, Level: 5
Points: 265, Level: 5 Points: 265, Level: 5 Points: 265, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
  #2 (permalink)  
Old November 7th, 2011, 06:14 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
  #3 (permalink)  
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.
  #4 (permalink)  
Old December 16th, 2011, 03:01 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:31 PM.


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