TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Marius Vasile
594
1.9k
144.8k
How can I have a specific tab refreshed on post in Asp.Net Core Razor
Aug 7 2020 2:27 AM
I have a tabbed Razor page, on load there is no data to be retrieved from server, active tab set for first tab. However, when I update data on one tab and post it I want the page to get only data for that tab. What I have so far is
:
html:
<
ul
class
=
"nav nav-tabs"
id
=
"PTWTab"
role
=
"tablist"
>
<
li
class
=
"nav-item"
>
<
a
class
=
"nav-link active"
id
=
"PTW-tab"
data-toggle
=
"tab"
href
=
"#PTW"
aria-controls
=
"ptw"
aria-selected
=
"true"
style
=
"width:200px"
>
Permit To Work
</
a
>
</
li
>
<
li
class
=
"nav-item"
>
<
a
class
=
"nav-link"
id
=
"HazId-tab"
data-toggle
=
"tab"
href
=
"#HazId"
aria-controls
=
"hazid"
aria-selected
=
"false"
style
=
"width:200px"
>
Hazard Identification
</
a
>
</
li
>
<
li
class
=
"nav-item"
>
<
a
class
=
"nav-link"
id
=
"GasTest-tab"
data-toggle
=
"tab"
href
=
"#GasTest"
aria-controls
=
"gt"
aria-selected
=
"false"
style
=
"width:200px"
>
Gas Testing
</
a
>
</
li
>
<
li
class
=
"nav-item"
>
<
a
class
=
"nav-link"
id
=
"IsoCert-tab"
data-toggle
=
"tab"
href
=
"#IsoCert"
aria-controls
=
"isocert"
aria-selected
=
"false"
style
=
"width:200px"
>
Isolation Certificate
</
a
>
</
li
>
</
ul
>
cshtml for post:
public
async Task<IActionResult> OnPostIsoCertAsync(
int
? PTWNo)
{
if
(!ModelState.IsValid)
{
return
Page();
}
var newIsoCert = await _context.ICContents.FindAsync(PTWNo);
if
(newIsoCert ==
null
)
{
return
NotFound();
}
if
(await TryUpdateModelAsync<ICContent>(
newIsoCert,
"ICContent"
,
// Prefix for form value.
c => c.IdICD,
c => c.IsoStep,
c => c.EquipmentID,
c => c.EquipmentDescription,
c => c.EnSource,
c => c.IsType,
c => c.IsMethod,
c => c.LockNo,
c => c.PreparedBy,
c => c.ImplementedBy,
c => c.VerifiedBy,
c => c.IsStatus))
{
await _context.SaveChangesAsync();
return
Page();
}
return
Page();
}
and cshtml for Get is:
public
async Task<IActionResult> OnGetIsoCertAsync(
int
ptwNoId)
{
PTWIsoCert = await (from a
in
_context.ICDatas.Where(a => a.PTWNo == ptwNoId)
orderby a.IdICD
join b
in
_context.ICContents on a.IdICD equals b.IdICD into TempData1
from c
in
TempData1
select
new
PTWIsoCert
{
IdICD = a.IdICD,
PTWNo = ptwNoId,
IsoDate = a.IsoDate,
IsoStep = c.IsoStep,
EquipmentID = c.EquipmentID,
EquipmentDescription = c.EquipmentDescription,
EnSource = (
int
)c.EnSource,
IsType = (
int
)c.IsType,
IsMethod = (
int
)c.IsMethod,
LockNo = c.LockNo,
PreparedBy = c.PreparedBy,
ImplementedBy = c.ImplementedBy,
VerifiedBy = c.VerifiedBy,
IsStatus = (
int
)c.IsStatus
}).ToListAsync();
return
Page();
}
What I want is after I post data in the selected tab, to get it from server and keep the tab active and display it. Html for display is already setup, I didn't post it to not load too much data
Reply
Answers (
4
)
how to host a webapi in world wide web
jstree with asp.net MVC5