Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > checkbox syntax

Reply
Thread Tools

checkbox syntax

 
 
Mike P
Guest
Posts: n/a
 
      11-14-2007
I am posting a form to a page and then trying to pick up the value of a
checkbox. But I can't get the syntax right. Can anybody help?

dim blnInboundLead4

blnInboundLead4 = true

if (Request("inboundlead2") = "off") then
blnInboundLead4 = false
end if



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Dooza
Guest
Posts: n/a
 
      11-14-2007
Mike P wrote:
> I am posting a form to a page and then trying to pick up the value of a
> checkbox. But I can't get the syntax right. Can anybody help?
>
> dim blnInboundLead4
>
> blnInboundLead4 = true
>
> if (Request("inboundlead2") = "off") then
> blnInboundLead4 = false
> end if
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***


Try using Request.Form instead
 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      11-14-2007
Mike P wrote:
> I am posting a form to a page and then trying to pick up the value of
> a checkbox. But I can't get the syntax right. Can anybody help?
>
> dim blnInboundLead4
>
> blnInboundLead4 = true
>
> if (Request("inboundlead2") = "off") then
> blnInboundLead4 = false
> end if
>
>

If the checkbox is not selected, it does not appear in the Form
collection. What you have to do is check for the existence of the key
and set the boolean variable accordingly:

dim blnInboundLead4
if len(Request.Form("inboundlead2")) > 0 then
blnInboundLead4 = true
else
blnInboundLead4 = false
end if
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
Mike P
Guest
Posts: n/a
 
      11-14-2007
It worked once I had changed true and false to "true and "false" :

dim blnInboundLead4
if len(Request.Form("inboundlead2")) > 0 then
blnInboundLead4 = "true"
else
blnInboundLead4 = "false"
end if




*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      11-15-2007
"Mike P" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> It worked once I had changed true and false to "true and "false" :
>
> dim blnInboundLead4
> if len(Request.Form("inboundlead2")) > 0 then
> blnInboundLead4 = "true"
> else
> blnInboundLead4 = "false"
> end if
>


In which case perhaps your variable name should be strInbound ?

--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASPNET CheckBox and a CheckBox in a TemplateField Jason Huang ASP .Net 0 06-29-2007 12:35 AM
DataGrid and embeded Checkbox..How to find if checkbox clicked =?Utf-8?B?RG90TmV0RGV2?= ASP .Net 1 10-06-2006 04:11 PM
disable checkbox list checkbox Vikram ASP .Net 1 01-25-2006 02:59 PM
Howto bind CheckBox to the datagrid/ Then update the database field when the checkbox is clicked. Joey Pang ASP .Net Datagrid Control 4 06-13-2005 02:29 AM
Text on Checkbox below the checkbox tshad ASP .Net 0 04-14-2005 11:26 PM



Advertisments