-1
首先,如果您給出示例,您是否可以在aspx引擎中執行此操作。我對此非常熟悉。如果沒有,我想這沒關係,我會嘗試將剃鬚刀發動機的例子弄清楚。按用戶ID搜索類,然後在表中顯示類
這是從我最後一個問題的升級中取得的進展。
我想創建一個搜索框,需要在用戶ID然後顯示與用戶輸入相關的類,然後將其顯示在表中。如果沒有它,搜索按鈕下面的消息應該顯示找不到類。這是我迄今爲止所擁有的。我的例子中有很多紅色的下劃線。我不知道我在哪搞亂。
HTML
<div align="center">
<form id="searchUser" method="post" action="what do I put here?">
<table align="center">
<tr>
<td class="label">
Enter ID:
</td>
<td>
<input type="text" name="UserId" id="UserId" value="<%(string)(ViewBag.userid)%>" />
</td>
</tr>
<tr>
<td>
<button class="searchButton" id="searchButton">Search</button>
</td>
</tr>
</table>
</form>
</div>
<hr />
<%if(ViewBag.searchClass !=null)
{ %>
<h2>Search Resuls</h2>
<br />
<%AAlexUsers.Models.SearchClass searchClassList= ViewBag.searchClass;%>
<table>
<tr>
<th>
UserID:
</th>
<th>
Email:
</th>
<th>
Last Four Digits:
</th>
</tr>
<tr>
<td class="content">
<%=searchClassList.userId%>
</td>
<td class="content">
<%=searchClassList.email%>
</td>
<td class="content">
<%=searchClassList.lastFourdigits%>
</td>
</tr>
<%} %>
</table>
<% else %>
<% { %>
<h2>No Class found.</h2>
<% } %>
控制器這是我做的搜索按鈕一類的我的實例找到
public ActionResult Search()
{
string userId = Request["UserId"];
bool view = false;
if (Request["UserId"] == null)
{
view = true;
}
if (!view)
{
AAlexUsers.Models.SearchClass searchClass = new Models.SearchClass();
{
searchClass.lastFourdigits = "2222";
searchClass.userId = "12345";
searchClass.email = "[email protected]";
string lastFourdigits = searchClass.lastFourdigits;
string userIdd = searchClass.userId;
string email = searchClass.email;
ViewBag.searchClass = searchClass;
ViewBag.lastFourdigits = lastFourdigits;
ViewBag.userId = userIdd;
ViewBag.email = email;
}
}
return View();
型號
namespace AAlexUsers.Models
{
public class SearchClass
{
public string userId { get; set; }
public string email { get; set; }
public string lastFourdigits { get; set; }
public SearchClass()
{
userId = "";
email = "";
lastFourdigits = "";
}
}
}
action =「我在這裏放什麼?」應該是行動=「搜索」 – prashanth
我的if語句在它下面有一條紅線。你知道爲什麼會發生這種情況。你能檢查我的語法嗎? – Yusuf
什麼是確切的異常/錯誤? – prashanth