i making worksystem with razor page in asp
I want to add a value to the input text when a button is pressed.
this is input box
[]
click button
⑤
input box add five
[5]
how to access input text box in code
this is AddWork.cshtml input text
<form class="form-horizontal" method="post">
InputWork: <input type="text" asp-for="boradIds" />
<select asp-for="inputIds" asp-items="Model.seletcIdList">
</select>
<input type="submit" value="Add" />
</form>
this is call AddWork cs func
<form method="post">
<input asp-page-handler="AddItem" [email protected]_id
class="btn" type="submit" value="AddWork" />
</form>
this is cs.
[BindProperty(SupportsGet = true)]
public string boradIds { get; set; }
public IActionResult OnPostAddItem(int bid)
{
//if (bid == 0)
// return Page();
boradIds =boradIds +bid.ToString();
return RedirectToPage();
}
i don't know how to access input text value
If you want to get boradIds in OnPostAddItem,you need to put <input type="text" asp-for="boradIds" />
into the form which will call OnPostAddItem
.
<form method="post">
InputWork: <input type="text" asp-for="boradIds" />
<select asp-for="inputIds" asp-items="Model.seletcIdList">
</select>
<input asp-page-handler="AddItem" [email protected]_id
class="btn" type="submit" value="AddWork" />
</form>
So that when you click AddWork button,it will pass boradIds and resoruceId to handler,if you want to get resoruceId in handler,you need to use int resoruceId
.