ASP

samprg
samprg used Ask the Experts™
on
Hi,
If I enter alpha in a field,gives me error ,It should just number:

 fe = Convert.ToDecimal(((TextBox)this.rmv.FindControl("txtFee2")).Text == "" ? "0" : ((TextBox)this.rmv.FindControl("txtFee2")).Text);
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
kaufmedGlanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015

Commented:
Try this:
if (decimal.TryParse(((TextBox)this.rmv.FindControl("txtFee2")).Text == "" ? "0" : ((TextBox)this.rmv.FindControl("txtFee2")).Text, out fe))
{
    // If you make it here, the text was a valid decimal and "fe" holds that value
}
else
{
    // If you make it here, the value did NOT represent a valid decimal. "fe" is unchanged.
}

Open in new window

Author

Commented:
this is  "out fe",gives me error
Glanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015
Commented:
What is the error?

Author

Commented:
No thing, thanks a lot.
kaufmedGlanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015

Commented:
Cool. Glad you got it sorted out  = )

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial