Hi People...i am fairly new to MVC and have a fundamental implementation
issue.
In asp.net webforms..i can have a usercontrol that has a submit
button...when you click submit...you can change the data on that usercontrol
and it will postback to the same page. All good.
Eg a login usercontrol
When you login(which ever page you're in), it will post back and change the
user control to 'Welcome back Anthony' for example.
How do i do this in MVC? See below for my code..basically it is returning
to my logon partial view on submit instead of the main page.
Main view........Home/Intro
<div>The Cool Website<div/>
@Html.RenderAction("Logon","Account");
<div id="divBackHome">
<img width="18px" height="18px" alt="" src="/images/home.jpg">
<a href="/Home/Index">Home</a>
</div>
Controller.....
Function Logon() As ActionResult
Return View(New LogonModel With {.ReturnUrl = Request.RawUrl})
End Function
<HttpPost()>
Function Logon(ByVal model As LogonModel) As ActionResult
Dim iUserId As Int32
Dim msg As String = ""
Dim sURL As String = model.ReturnUrl
If ModelState.IsValid Then
If Common.Functions.Login(model.Username.Trim,
model.Password.Trim, msg, iUserId, BaseProperties.ResellerId, False) Then
Return PartialView("Logon", model)
Else
model.Username = "test"
ViewData("loginresult") = "login failed"
Return PartialView("Logon", model)
End If
Else
Return PartialView("Logon", model)
End If
End Function