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

Using @ViewBag in Title of MobileView

2 Answers 486 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 03 Jun 2016, 04:09 PM

This isn't really specific to MobileView but I'm using a MobileView in a partial view that I'm using as a layout template and I want to make the Title dynamic by using ViewBag.Title as the string.

@(Html.Kendo().MobileView()
                .Title(ViewBag.Title)
                .Name("two-drawer-home")
                .Header(obj => Html.Kendo().MobileNavBar().Content(navbar =>
                    @<text>
                        @(Html.Kendo().MobileButton().Name("btnLeftDrawer").Align(MobileButtonAlign.Left).Rel(MobileButtonRel.Drawer).Url("#left-drawer").ClickOn("down"))
                        @navbar.ViewTitle("Hello there")
                        @(Html.Kendo().MobileButton().Name("btnRightDrawer").Align(MobileButtonAlign.Right).Rel(MobileButtonRel.Drawer).Url("#right-drawer").ClickOn("down"))
                    </text>)
                .HtmlAttributes(new { style = "height: 46px;" })
                )
                .Content(@<text>@RenderBody()</text>)
)

 

But this isn't valid. I've also tried @ViewBag.Title and various other incarnations. I'm wondering if this type of thing is possible in the Title of the MVC controls. 

2 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 07 Jun 2016, 01:37 PM
Hi Mike,

You can try assigning the ViewBag.Title value to a string variable first and then assign this variable to the Title method. 

@{
    string title = ViewBag.Title;
}
 
@(Html.Kendo().MobileView()
    .Title(title)
    ...
)


Regards,
Ianko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Mike
Top achievements
Rank 1
answered on 07 Jun 2016, 02:43 PM
Awesome! Pretty simple and works (of course). Thanks very much. 
Tags
General Discussions
Asked by
Mike
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Mike
Top achievements
Rank 1
Share this question
or