Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   C# Form Processing: If Exists (http://www.velocityreviews.com/forums/t554124-c-form-processing-if-exists.html)

Matthew Loraditch 11-21-2007 04:58 PM

C# Form Processing: If Exists
 
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


Cowboy \(Gregory A. Beamer\) 11-21-2007 10:00 PM

Re: C# Form Processing: If Exists
 
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" <mloradites@yahoo.com> wrote in message
news:599F8C1E-A4B0-4FE2-95F7-94A68D4EFEA4@microsoft.com...
>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




Matthew Loraditch 11-21-2007 11:53 PM

Re: C# Form Processing: If Exists
 
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)" <NoSpamMgbworld@comcast.netNoSpamM> wrote in
message news:#YjUqnILIHA.3916@TK2MSFTNGP02.phx.gbl...
> 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" <mloradites@yahoo.com> wrote in message
> news:599F8C1E-A4B0-4FE2-95F7-94A68D4EFEA4@microsoft.com...
>>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

>
>



All times are GMT. The time now is 02:04 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.