I just want to be really really sure
-
I just found this wonderful tidbit in a .NET app I'm supporting.
TextBox tbRoute = (TextBox)FindControl("ChkRoute" + cnt.ToString());
if ((tbRoute.Text != "") && (tbRoute.Text != "") && (tbRoute.Text != "")) {
...
}
-
I just found this wonderful tidbit in a .NET app I'm supporting.
TextBox tbRoute = (TextBox)FindControl("ChkRoute" + cnt.ToString());
if ((tbRoute.Text != "") && (tbRoute.Text != "") && (tbRoute.Text != "")) {
...
}
Ignoring the dubiously-named variable
cnt
, you must be really sure that the controlChkRoute_N_
exists, since you never test the value returned fromFindControl
fornull
. :doh:
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Ignoring the dubiously-named variable
cnt
, you must be really sure that the controlChkRoute_N_
exists, since you never test the value returned fromFindControl
fornull
. :doh:
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
The cnt is because this was inside a for loop. Perhaps whoever coded it thought the code could lie the first two times you ask if a value is empty, but not a third. Looking at the HTML I think they meant to find two other controls and add them to the IF statement, but never got around to it. *sigh*
-
I just found this wonderful tidbit in a .NET app I'm supporting.
TextBox tbRoute = (TextBox)FindControl("ChkRoute" + cnt.ToString());
if ((tbRoute.Text != "") && (tbRoute.Text != "") && (tbRoute.Text != "")) {
...
}
The sad thing is that he got paid to write that... :sigh:
The only instant messaging I do involves my middle finger. English doesn't borrow from other languages. English follows other languages down dark alleys, knocks them over and goes through their pockets for loose grammar.
-
I just found this wonderful tidbit in a .NET app I'm supporting.
TextBox tbRoute = (TextBox)FindControl("ChkRoute" + cnt.ToString());
if ((tbRoute.Text != "") && (tbRoute.Text != "") && (tbRoute.Text != "")) {
...
}
So....what exactly is wrong with that?
-
I just found this wonderful tidbit in a .NET app I'm supporting.
TextBox tbRoute = (TextBox)FindControl("ChkRoute" + cnt.ToString());
if ((tbRoute.Text != "") && (tbRoute.Text != "") && (tbRoute.Text != "")) {
...
}
Did you check that the Text property Getter didn't make changes to the underlying data and so make that a valid statement. e.g.
private string _text;
public string Text
{
Get{
if (_text == null)
{
_text = "Empty";
return _text;
}
if (_text == "Empty")
_text = "";return _text;
}
}MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
-
Did you check that the Text property Getter didn't make changes to the underlying data and so make that a valid statement. e.g.
private string _text;
public string Text
{
Get{
if (_text == null)
{
_text = "Empty";
return _text;
}
if (_text == "Empty")
_text = "";return _text;
}
}MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
-
_Maxxx_ wrote:
if (_text = "Empty") _text = "";
This will be always be true no matter what _text is :D except for F# but there the if else operation contains then :)
Microsoft ... the only place where VARIANT_TRUE != true
Thanks for the human compiler - I've fixed it.
MVVM # - I did it My Way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')
-
I just found this wonderful tidbit in a .NET app I'm supporting.
TextBox tbRoute = (TextBox)FindControl("ChkRoute" + cnt.ToString());
if ((tbRoute.Text != "") && (tbRoute.Text != "") && (tbRoute.Text != "")) {
...
}
-
I just found this wonderful tidbit in a .NET app I'm supporting.
TextBox tbRoute = (TextBox)FindControl("ChkRoute" + cnt.ToString());
if ((tbRoute.Text != "") && (tbRoute.Text != "") && (tbRoute.Text != "")) {
...
}
I've unintentionally had that happen after some refactoring. A couple text boxes contained values, and were later converted to a single box. Refactoring the name of the second to be the same as the first created the circumstance found here. Of course, that situation only lasted for a little while, since I did check all the references to make sure nothing too stupid happened...
Software Zen:
delete this;
-
_Maxxx_ wrote:
if (_text = "Empty") _text = "";
This will be always be true no matter what _text is :D except for F# but there the if else operation contains then :)
Microsoft ... the only place where VARIANT_TRUE != true
No it won't. It wouldn't compile...
-
No it won't. It wouldn't compile...
-
I just found this wonderful tidbit in a .NET app I'm supporting.
TextBox tbRoute = (TextBox)FindControl("ChkRoute" + cnt.ToString());
if ((tbRoute.Text != "") && (tbRoute.Text != "") && (tbRoute.Text != "")) {
...
}
At least give the guy credit for ensuring that no variable leaves empty-handed.
-
I just found this wonderful tidbit in a .NET app I'm supporting.
TextBox tbRoute = (TextBox)FindControl("ChkRoute" + cnt.ToString());
if ((tbRoute.Text != "") && (tbRoute.Text != "") && (tbRoute.Text != "")) {
...
}
Somebody knows the "Tell me 3 times and it must be true" rule (see Heinlein's "Number of the Beast")