Strings in ASP?
I have some APSX code that I am trying to modify for a programmer that is out on medicaly leave. I am not an ASP guy, but rather C++
So what I want to do is delare a s开发者_如何学运维tring, check the first 4 characters and if it is 'http' do something, if not, something else.
Here is what I have:
string strYT= Left(objFile, 4);
if (strYT=="http") {
pnlYT.Visible = true;
pnlIntro.Visible = false;
pnlVideo.Visible = false;
}
else {
pnlYT.Visible = false;
pnlIntro.Visible = false;
pnlVideo.Visible = true;
PrintText(objFile);
}
But I get errors like:
Compiler Error Message: CS0103: The name 'Left' does not exist in the class or namespace 'ASP.zen_aspx'
My googling turns up many examples of doing it just like this.....
Here is is in VB
Dim str as String = "http://mywebsite.com"
If str.StartsWith("http://") Then
''# This is the true stuff
pnlYT.Visible = True
pnlIntro.Visible = False
pnlVideo.Visible = False
Else
''# This is the false stuff
pnlYT.Visible = False
pnlIntro.Visible = False
pnlVideo.Visible = True
End If
Here it is in C#
string str = "http://mywebsite.com";
if (str.StartsWith("http://")) {
// This is the true stuff
pnlYT.Visible = true;
pnlIntro.Visible = false;
pnlVideo.Visible = false;
} else {
// This is the false stuff
pnlYT.Visible = false;
pnlIntro.Visible = false;
pnlVideo.Visible = true;
}
if (myString.StartsWith("http"))
// do stuff
else
// do other stuff
string myString = getStringFromSomeWhere();
if(myString.StartsWith("http"))
{
doSomething();
}
else
{
doSomethingElse();
}
精彩评论