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

You are currently viewing the ASP.NET 2.0 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 February 15th, 2007, 07:25 PM
Authorized User
 
Join Date: Feb 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am guessing this is VBScript

 
Old February 15th, 2007, 07:48 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Yes, their code is VBScript, however, language is a moot point here as 1)This is the .NET 2.0 forum and 2) The fundamentals don't change across languages. Simply put, in your checkbox you would use the CHECKED attribute to denote any field that should be checked by default, not VALUE=ON. Then when you post your form you do if(Request.Form("checkboxName") == "on"){//do something} If it is not on you know the user did not check the checkbox.

Also, do a response.write on your sql string and let me see it.

Lastly, my appologies, I did not realize you were having problems retrieving values from the form, my mistake.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
 
Old February 16th, 2007, 01:20 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hei Morn!

Sorry, I did not realize that you are on the .net. I was hoping to be at some help when reading your post in the asp 3.0 forum.

Have you had any progress, solved the problem? As I understand, you have problems with pasing the "unchecked value from a checkbox" to your db?

I am not sure, but I do belive the "roules" regarding checkboxes are the same whether it is 3.0 or .net? If you need to, specify a new question or rephrase the question.

Mvh
grstad
 
Old February 19th, 2007, 05:46 AM
Authorized User
 
Join Date: Feb 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for all the help here, I have to admit that I have made a little mistake when I started this post!

I am working in classic ASP, not .NET (I wish I was though). Just to clarify my problem, I am not able to pass
the value of an unchecked checkbox to the database, I understand that it is because an unchecked value is literally
nothing (no value).

So if I may, which of the above is relative to classic asp and which will only work in .NET? I am assuming that I probably
would not have these problems in .NET!

Thanks for your continued support.
Graham


 
Old February 19th, 2007, 01:51 PM
Authorized User
 
Join Date: Feb 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<%
var vartowncity = Request.Form("townName");
var vartowndistance = Request.Form("townDistance");
var vartowndirection = Request.Form("direction");
var varhometype = Request.Form("homeType");
var varflatfloorno = Request.Form("flatfloor");
var varflatblock = Request.Form("flatBlock");
var varmaxpeople = Request.Form("maxPeople");
var varnobed = Request.Form("noBedrooms");
var varnobath = Request.Form("noBathrooms");
var varcarneeded = Request.Form("carYESNO");
var varcarexchange = Request.Form("carExchange");
var varsmoking = Request.Form("smokingYESNO");
var varswim = Request.Form("swimpool");
var varpet = Request.Form("petcare");
var varchildallow = Request.Form("childreAllowed");
var varplantcare = Request.Form("plantCare");
var varadditionalInfo = Request.Form ("additionalInfo");
var varadditional = Request.Form("additionalInfo");
var varpic = Request.Form("housePicture");

if (varcarneeded.value == ""){
varcarneeded.value = "off"
Else
varcarneeded.value = "on"
}
%>

Would this work?

 
Old February 19th, 2007, 01:56 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Yes that should work.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
 
Old February 19th, 2007, 02:01 PM
Authorized User
 
Join Date: Feb 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ahhhh, this is so frustrating. It still passes an undifined value.

Where am I going wrong here?

All I am trying to say is if it blank the give it the value off, I just don't get it.


 
Old February 19th, 2007, 02:07 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

While grstad said not to assing a VALUE attribute to the checkbox, humor me and assign a value to it and see if that corrects your problem.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
 
Old February 19th, 2007, 02:36 PM
Authorized User
 
Join Date: Feb 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In a cruel twist, I set the value of one of the checkboxes to "off"

Code:
<input type ="checkbox" name ="carYESNO" value = "off"/>
and it returned the unexpected 'off' in the sql statement, the problem now however is that it did this when it was checked. Therefore we have changed the defult property of the checkbox.

Code:
INSERT INTO tblHome (memberID, towncity, towndistance, towndirection, propertytype, flatfloor, flatblock, nobedrooms, nobathrooms, maxnoofpeople, carneeded, carexchange, smoking, swimpool, petcare, childrenallowed, plantcare, additionalinfo, picture)values ('2', 'London', '15', 'SE', 'Flat', '3', 'CC', '2', '2', '4', off, on, on, on, on, on, on, 'hello', '');
 
Old February 19th, 2007, 02:38 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Change value to "ON"

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429





Similar Threads
Thread Thread Starter Forum Replies Last Post
Registering checked checkboxes in a database KeviJay VB Databases Basics 4 May 14th, 2008 04:44 PM
MS ACCESS 2003 FRONTEND AND MS SQL SERVER 2005 DB mohankumar0709 SQL Server 2005 3 March 23rd, 2007 12:48 AM
Checkboxes undefined when not checked MS Access Morn Classic ASP Basics 0 February 15th, 2007 05:07 PM
Keep track of checkboxes checked in one CASE stmt markw707 Javascript How-To 0 December 29th, 2006 12:28 PM
how to set checked listbox in access application. Skyblue Access VBA 2 September 5th, 2003 09:52 AM





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