i want to use an if statement in MVC 4. This If statement is going to check if the information in my text boxes is correct.
This is my Code in my Controller :
public string SageBankAccountNo;
public string SageBranchCode;
public string SageTypeOfAccount;
public string MyBankValidationMessage = "";
public string MyBankValidationDescription = "";
Bank_Info BankInfo = new Bank_Info();
public ActionResult Validation()
{
if (BankInfo.Type_of_Account != "Outstanding" || BankInfo.Type_of_Account != "")
{
if (BankInfo.Type_of_Account == "Cheque Account")
{
SageTypeOfAccount = "1";
}
if (BankInfo.Type_of_Account == "Savings Account")
{
SageTypeOfAccount = "2";
}
if (BankInfo.Type_of_Account == "Transmission")
{
SageTypeOfAccount = "3";
}
if (BankInfo.Type_of_Account == "Bond Account")
{
SageTypeOfAccount = "1";
}
return View();
}
this is my code in my View :
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>Bank_Info</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Bank_Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Bank_Name)
@Html.ValidationMessageFor(model => model.Bank_Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Type_of_Account)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Type_of_Account)
@Html.ValidationMessageFor(model => model.Type_of_Account)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Account_Number)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Account_Number)
@Html.ValidationMessageFor(model => model.Account_Number)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.BranchCode)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.BranchCode)
@Html.ValidationMessageFor(model => model.BranchCode)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Validation_Messaage)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Validation_Messaage)
@Html.ValidationMessageFor(model => model.Validation_Messaage)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
This is the code in my model :
public partial class Bank_Info : Refer
{
public string Bank_Name { get; set; }
public string Type_of_Account { get; set; }
public string Account_Number { get; set; }
public string BranchCode { get; set; }
public string Validation_Messaage { get; set; }
}
the controller code is restricted due to personal info. if i can get help with the given information. that will be great.
Aucun commentaire:
Enregistrer un commentaire