我正在使用Bootstrap(HTML & CSS),Microsoft Access和ASP.NET製作Web服務項目。如何將HTML參數傳遞給ASP.NET?
我發現了一個代碼W3Schools的引導登錄表單:
<body>
<form method="POST" action="Login.aspx">
<div class="container">
<h2>Login area</h2>
<form class="form-inline" role="form">
<div class="form-group">
<label for="email">UserName:</label>
<input type="text" class="form-control" id="username1" name="username" placeholder="Enter UserName"/>
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="password1" name="password" placeholder="Enter password"/>
</div>
<button type="submit" onclick="SubmitForm" class="btn btn-default">Submit</button>
</form>
</div>
這是C#代碼:
protected void SubmitForm(object sender, EventArgs e)
{
if (Page.IsValid)
{
string name=string.Format("{0}",Request.Form["username"]);
string pass = string.Format("{0}", Request.Form["password"]);
int userId;
userId = LoginService.GetUserId(name, pass, 0, 1);
if (userId == 0)
{
MessageBoxShow(Page, "UserName does not exists.");
}
else
{
MessageBoxShow(Page, "You are successfully connected.");
Session["userId"] = userId.ToString();
SalService.DeleteFromSal();
}
}
}
當我運行的網頁,並輸入用戶名和密碼,頁面不顯示消息,我不能連接用戶名。
我不明白我應該在後面寫什麼。 – Linki