PC Review


Reply
Thread Tools Rate Thread

C# Form Processing: If Exists

 
 
Matthew Loraditch
Guest
Posts: n/a
 
      21st Nov 2007
I have several different variations of the same form. Some include an asp
Radio Button list option called rb_monthly. If that option exists I need to
do some extra processing on the form.
The following works on the pages with the option :
if(rb_monthly != null)
{
monthly = rb_monthly.SelectedValue;
}

When the option's not there it doesn't work and I get compiler errors as
rb_monthly doesn't exist.
I've tried this:
string valMonthly = findVals("rb_monthly");
if (valMonthly != "")
{
monthly = valMonthly;
}
and some variations thereof, and while that doesn't cause compiler error it
also doesn't get the value and fails to process a later section of the code
that is supposed to process if monthly is true.

There has gotta be some way to do some sort of if exists check but I'm
mostly a newbie and am working off code I have been given.
Any help is majorly appreciated!!!
Thanks
Matthew Loraditch

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      21st Nov 2007
Check for null, as well, as a string can be null. That is quite common,
especially when pulling from a keyed list, like the ASP.NET form or
querystring collections.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
"Matthew Loraditch" <(E-Mail Removed)> wrote in message
news:599F8C1E-A4B0-4FE2-95F7-(E-Mail Removed)...
>I have several different variations of the same form. Some include an asp
>Radio Button list option called rb_monthly. If that option exists I need to
>do some extra processing on the form.
> The following works on the pages with the option :
> if(rb_monthly != null)
> {
> monthly = rb_monthly.SelectedValue;
> }
>
> When the option's not there it doesn't work and I get compiler errors as
> rb_monthly doesn't exist.
> I've tried this:
> string valMonthly = findVals("rb_monthly");
> if (valMonthly != "")
> {
> monthly = valMonthly;
> }
> and some variations thereof, and while that doesn't cause compiler error
> it also doesn't get the value and fails to process a later section of the
> code that is supposed to process if monthly is true.
>
> There has gotta be some way to do some sort of if exists check but I'm
> mostly a newbie and am working off code I have been given.
> Any help is majorly appreciated!!!
> Thanks
> Matthew Loraditch



 
Reply With Quote
 
Matthew Loraditch
Guest
Posts: n/a
 
      21st Nov 2007
Sorry for the newb questions.
Right now I am doing this, but as I previously mentioned, it only works if
the rb_monthly is on the page:
if(rb_monthly != null)
{
monthly = rb_monthly.SelectedValue;
}
Are you saying do this?
if (rb_monthly == null)
{
monthly =false;
} else{
monthly = rb_monthly.SelectedValue;
}

Thanks again,
Matthew

"Cowboy (Gregory A. Beamer)" <(E-Mail Removed)> wrote in
message news:#(E-Mail Removed)...
> Check for null, as well, as a string can be null. That is quite common,
> especially when pulling from a keyed list, like the ASP.NET form or
> querystring collections.
>
> --
> Gregory A. Beamer
> MVP, MCP: +I, SE, SD, DBA
>
> *************************************************
> | Think outside the box! |
> *************************************************
> "Matthew Loraditch" <(E-Mail Removed)> wrote in message
> news:599F8C1E-A4B0-4FE2-95F7-(E-Mail Removed)...
>>I have several different variations of the same form. Some include an asp
>>Radio Button list option called rb_monthly. If that option exists I need
>>to do some extra processing on the form.
>> The following works on the pages with the option :
>> if(rb_monthly != null)
>> {
>> monthly = rb_monthly.SelectedValue;
>> }
>>
>> When the option's not there it doesn't work and I get compiler errors as
>> rb_monthly doesn't exist.
>> I've tried this:
>> string valMonthly = findVals("rb_monthly");
>> if (valMonthly != "")
>> {
>> monthly = valMonthly;
>> }
>> and some variations thereof, and while that doesn't cause compiler error
>> it also doesn't get the value and fails to process a later section of the
>> code that is supposed to process if monthly is true.
>>
>> There has gotta be some way to do some sort of if exists check but I'm
>> mostly a newbie and am working off code I have been given.
>> Any help is majorly appreciated!!!
>> Thanks
>> Matthew Loraditch

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
C# Form Processing: If Exists Matthew Loraditch Microsoft ASP .NET 2 21st Nov 2007 11:53 PM
Closing a form error 2585 This action cannot be carried out while processing a form or report event SDLittle13@gmail.com Microsoft Access Form Coding 4 11th Mar 2007 05:58 PM
Form Processing =?Utf-8?B?TWFyeQ==?= Microsoft Frontpage 3 30th Aug 2006 12:42 PM
Close button on a form will not close form - error 2585 - action cannot be carried out while processing a form Angus Comber Microsoft Access 2 19th Jul 2006 12:21 PM
Form processing tiger Microsoft Access 3 26th Nov 2005 08:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:38 AM.