This is a migrated thread and some comments may be shown as answers.

[Solved] Tabstrip, partial views CRUD scenario issues

3 Answers 170 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jack
Top achievements
Rank 1
Jack asked on 05 Mar 2012, 01:11 PM
Hopefully someone here can help me with this as been struggling with this for a bit. Designing some input forms that depends heavly on Tab strip to break up the information and and issue i am having is that when updates are submitted the partial views are returning as whole pages.

Can someone tell me what i am doing wrong/missing?

Parent view (Edit.html):
<snip>
@Html.Telerik().TabStrip().Name("TabStrip")
.ClientEvents(events => events.OnLoad("Select"))
.ClientEvents(events=>events.OnContentLoad("onContentLoad"))
.Items(parent =>
{
parent.Add().Text("User").LoadContentFrom(Url.Action("_CoreEdit", "User", new { id = ViewBag.SUID })).Selected(true);
parent.Add().Text("Meeting Records").LoadContentFrom(Url.Action("_MeetingRecords", "User", new { id = ViewBag.SUID }));
})
<snip>
  <script type="text/javascript">
    function Select() {
        var tabstrip = $("#TabStrip").data("tTabStrip");
        var item = $("li", tabstrip.element)[@ViewBag.Tab];
        tabstrip.select(item);
    }
      function onContentLoad(e) {
        $.validator.unobtrusive.parse(e.contentElement);
    }
<snip>

Partial View (_CoreEdit.cshtml)
@using (Html.BeginForm())
{
 
    @Html.ValidationSummary(true)
<snip the various fields>
 <fieldset style="padding-top: 1.4em;">
        <input type="submit" value="Edit" id="SubmitButton" />

    </fieldset>           
}

Controler (UserController.cs)

[Authorize]
      public ActionResult _CoreEdit(int id)
      {
          var user = _db.ServiceUsers.Find(id);
          return PartialView(user);
      }
      [Authorize]
      [HttpPost]
      public ActionResult _CoreEdit(User user)
      {
          if (ModelState.IsValid)
          {
              _db.Entry(user).State = EntityState.Modified;
              _db.SaveChanges();
   return PartialView("_CoreDetails", user); 
          }
 
          return PartialView("_CoreEdit", user);
 
      }

3 Answers, 1 is accepted

Sort by
0
Matt
Top achievements
Rank 1
answered on 22 Mar 2012, 07:32 PM
Im having the same issue. The workaround Im currently doing is if the update was successful, then just load a static "Update successful" page outside of the tab structure, and then the user can re-navigate, or an error page if the update wasnt successful. I dont like this. Potentially you could redirect to the page hosting the tabs and pass the selected tab value in the query string then use
.SelectedIndex(index) on the tabstrip. I havent tested the second option. 
0
Ed
Top achievements
Rank 1
answered on 22 Mar 2012, 07:53 PM
You should have your "update" method return a json result instead of a view or partial view.

See this post where I describe how I did it recently:

http://www.telerik.com/community/forums/aspnet-mvc/tabstrip/tab-and-ajax.aspx
0
Rajesh
Top achievements
Rank 1
answered on 13 Apr 2012, 07:28 AM
If i do not have a submit button on the tab partial view, is there any event i can handle to submit changes?
Tags
TabStrip
Asked by
Jack
Top achievements
Rank 1
Answers by
Matt
Top achievements
Rank 1
Ed
Top achievements
Rank 1
Rajesh
Top achievements
Rank 1
Share this question
or