C#'s case sensitivity can be a real headache to folks more accustomed to the languages like VB.
"isPost" is not the same as "IsPost" or "ISPOST" or ...
When you see an error like "The name 'i<whatever>' does not exist in the current context", this means the compiler does not recognize a name of that exact spelling and case as being present within the scope of the operation.
Another way you can get the error is to define the variable name within a loop's code block (or an if statement's code block) and then try to refer to it from somewhere NOT within that block. Check out the concept of variable "SCOPE" in any C# tutorial
- it will save you a lot of grief.
RRR
Marked as answer by Dino He - MSFT on May 22, 2012 07:28 AM
wavemaster
Participant
1291 Points
1128 Posts
Warning... newbie, dumb questions and ignorance / if(isPost)
May 15, 2012 06:19 PM|LINK
Complete newbie here.
making some nice progresss but I hit a stumbling block with the isPost.
error CS0103: The name 'isPost' does not exist in the current context
What am I missing here>
TIA
@{
var CustFirstName="";
var CustLastName="";
var CustEmail="";
var CustPhone="";
var CustAddress1="";
var CustAddress2="";
var CustCity="";
var CustState="";
var CustZip="";
var CustCountry="";
if(isPost)
{
CustFirstName=Request["formFirstName"];
CustLastName=Request["formLastName"];
CustEmail=Request["formEmail"];
CustPhone=Request["formPhone"];
CustAddress1=Request["formAddress1"];
CustAddress2=Request["formAddress2"];
CustCity=Request["formCity"];
CustState=Request["formState"];
CustZip=Request["formZip"];
CustCountry=Request["formCountry"];
var SQLINSERT = "INSERT INTO CustInfo (CustFirstName, CustLastName, CustEmail, CustPhone, CustAddress1, CustAddress2, CustCity, CustState, CustZip, CustCountry) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10)";
var db = Database.Open("try1");
db.Execute(SQLINSERT, CustFirstName, CustLastName, CustEmail, CustPhone, CustAddress1, CustAddress2, CustCity, CustState, CustZip, CustCountry);
}
<form action="" method="post">
<p>First Name:<input type="text" name="formFirstName" /></p>
<p>Last Name:<input type="text" name="formLastName" /></p>
<p>Email:<input type="text" name="formEmail" /></p>
<p>Phone:<input type="text" name="formPhone" /></p>
<p>Address1:<input type="text" name="formAddress1" /></p>
<p>Address2:<input type="text" name="formAddress2" /></p>
<p>City:<input type="text" name="formCity" /></p>
<p>State:<input type="text" name="formState" /></p>
<p>Zip:<input type="text" name="formZip" /></p>
<p>Country:<input type="text" name="formCountry" /></p>
<p><input type="submit" value="Add Customer" /></p>
</form>
}
GmGregori
Contributor
5470 Points
737 Posts
Re: Warning... newbie, dumb questions and ignorance / if(isPost)
May 15, 2012 06:32 PM|LINK
Try with if (IsPost): pay attention to the case.
rrrsr7205
Participant
1304 Points
313 Posts
Re: Warning... newbie, dumb questions and ignorance / if(isPost)
May 15, 2012 07:41 PM|LINK
C#'s case sensitivity can be a real headache to folks more accustomed to the languages like VB.
"isPost" is not the same as "IsPost" or "ISPOST" or ...
When you see an error like "The name 'i<whatever>' does not exist in the current context", this means the compiler does not recognize a name of that exact spelling and case as being present within the scope of the operation.
Another way you can get the error is to define the variable name within a loop's code block (or an if statement's code block) and then try to refer to it from somewhere NOT within that block. Check out the concept of variable "SCOPE" in any C# tutorial - it will save you a lot of grief.