MVC Unrendering Script and Style files - c#

I have 2 different layouts in my project that based on the view that is called, I will tell the view which layout to use. I'm having an issue where my first layout is rendered (my landing page), I render a certain set of scripts/styles. Once I want to render my 2nd layout, the browser is holding on to all the styles/scripts from my previous layout. Is there anyway to decouple those scripts/styles when changing layouts?

Never mind, I'm dumb. I forgot to change one of my script and style render strings. Once I put the right one in it works.

Related

Merge seperate scroll views into one scroll view, from seperate view controllers

I have 3 different views and view controllers. 1 is responsible for displaying some review text, it has a UIScrollView and a UILabel. Another is responsible for displaying comments, it has a UIScrollView a nested UIStackView. The third one, I want to combine the previous 2 and be able to scroll them them together, and it has a UIScrollView (the contained element at this stage can be anything).
I want to keep this separation because the review text will be displayed elsewhere, by itself or with other information as well and I've abstracted the comments so that the same code can be used with a different comment model to display different comments depending on the context; with this particular context being a discussion on the review text.
The end result I'm looking for is that review text and the comments can be scrolled together.
Naively, I've tried adding the view controllers as children and the views to a UIStackView within the UIScrollView and I ended up with two views that scroll independently, more or less. Which makes sense, but is not what I want. I'm finishing testing using UICollectionView and it doesn't seem to work (the child view controllers don't seem to get notified when the view appears, which is where I'm setting the UILabel's text for the review and building the nested UIStackViews for the comments). My next idea is to somehow 'rip' the content out of the views' scroll views and place it into the third's UIScrollView's container (probably a UIStackView). But before I do that, I wanted to see if there was an easier way to effectively merge these 2 scroll views (and their associated view controllers) into a third, containing scroll view (and its view controller).
As per comments from the OP...
You can add the VCs as child view controllers, and then add their views to a UIStackView.
The key to getting that to work is to set the height of the child views (and their scroll views) to match the height of the scroll views' content.
Note that the "root view" of a VC loaded as a child will have .translatesAutoresizingMaskIntoConstraints = true ... so if you're going to use auto-layout constraints, remember to set it to false.

Xamarin Forms: Nesting a visual element across multiple views

I would like to add a Floating Action Button to multiple views. I was wondering if there is a method similar to the ASP.NET _Layout.cshtml pages. Is there a way to house the view in a page and render the content underneath it?
I have tried adding it to the MasterDetailPage, but I am not sure if it's me doing it wrong or if it's just not supported.
I can add the view to each page, but I'd really prefer to explore this method from a maintainability point of view.
if it's possible ?
Of course you can implement it. No matter MasterDetailPage or Tabbed Page . Each View is a ContentPage. So you can create a general ContentPage (for example we call it BaseContentPage).
And define the floating button in it. Then create its subclass as each view so that you can handle the different logic in different pages .

C# (MVC) and Bootstrap for dynamic layouts

I work with C# (MVC) to generate websites. We use Bootstrap to position elements.
If I wanted to let a page have a toggle to display a menu either vertically or horizontally, what is my best design approach?
If I wasn't using Bootstrap or C# I might produce an XML file with the data to be displayed. The XML would be marked up with with no thought of how it would be displayed.
So it might look like this for example:
<page>
<footer>This most likely will render at bottom of page</footer>
<menu>
<ol>
<li>Home</li>
<li>Foo</li>
<li>Bar</li>
</ol>
</menu>
<content>Some page content here</content>
<header>This most likely will render at top of page</header>
</page>
...and then maybe use XSLT (along with CSS) to transform that page so visually elements would be positioned as I chose (menu at top, side, bottom, wherever) based upon the selected theme/layout.
Is there a standard way to do allow for dynamic layouts using Bootstrap when working with C# and razor files? Is an #IF statement in my razor file that renders a different row/column layout my best/only choice?
Maybe there is a standard markup so that you can easily switch between different themes with different layouts? Although I don't see this documented if so.
I've spent the last hour Googling this without much luck.
I would recommend you look on the various web sites that provide this sort of functionality (some $$ some free) . I used one on a project last year, and TBH it would have taken a HTML/CSS/js expert 6 months to create all the included features from scratch (and it cost less than $50).
Check Jquery Menus. You can toggle Vertical to Horizontal using css. Refer this post - How to make jQuery UI nav menu horizontal?
If you want to specifically use Bootstrap then check Bootstrap Navbar. I believe you can use CSS to toggle here as well.
In my opinion, for changing layouts we should always use css. The advantage is, page will not be reloaded if the layout/viewport changes and we do not need to maintain separate codebase. This is why we use responsive webdesign which makes use of css to update the look and feel based on size of the device (4K, desktop, tablet, mobile etc.)
I think what I'll end up doing is making one shared View per type of layout:
~/Views/Shared/_Layout.cshtml
~/Views/Shared/_leftMenuLayout.cshtml
etc
... and then I'll create file "Views/_ViewStart" and in this file set the default shared layout I want used based on the desired layout. ie:
Layout = "~/Views/Shared/_leftMenuLayout.cshtml";

How to use Html.TextAreaFor using many Ajax.BeginForms in same view

I'm not sure about how to ask my question, so I'll show my screen.
I have a control for subscriptions in a page. The context of the page inst to post data, so the model is some kind of "read-only". My model has the inscriptions (left site), the inviteds (second tab of left side) and the approveds (right side). The green buttons, turn the current item as approved (send it to right side by ajax, removing the html from the left panel and inserting in the right panel). The red buttons (remover) do the opposite, unapproving the user.
Ok, until now I was just trying to explaining the picture. Now, my real problem.
Every m is a button. It opens a messagebox like the 2nd item on the right panel shows. The m turn into ^ to close the accordion.*
My problem is: I'm using a Ajax.BeginForm in those textarea + submit button but without model binder. I'm using
#Html.TextArea("message")
instead
#Html.TextAreaFor(m=>m.Message)
because my view model, like a said before, has another context. Now, I really dont know the right approach to do that. I want the jquery validation unobstrusive to work with this textarea. I was thinking about use a #Html.RenderAction for each partial with messagebox, but I'm worried about performance. There is any kind of help me with that?
Doesnt matter if takes longer, I'm looking for the right stuff.
Thanks
*the + sign, m and ^ will be changed by nice icons later.
If the model for this page has another context make up another page with the right context and let it pop up in an iframe...
From your screenshot I would assume that this is about programming of the last 10%. The concept of approval has a 'lesser-reject-nature': People that give away something for approval typically try to follow the rules to allow a fluent approval. As soon as you articulate the approval rules clearly any need to respond with messages becomes a minor issue.
"because my view model, like a said before, has another context..."
You're in control of the view model? Why not arrange it so it properly fits the view, and map your data to it. Then you would be able to use the strong typed html helper.
Otherwise, consider rendering a partial view. You can then redefine the #model type for the partial, it could be a property of you main view's model, and use the Html helper on that.

Validate a request in a view "Orchard"

I just want to validate/detect whether a specific VIEW'S request is through projection-widget or projection page, can anyone help me in this matter ?
Did you try adding a layout to the query? When you create your project page or widget, you can select the layout that you want to use. So, just create a layout for your pages to use, and another layout for your widgets to use. If that's not enough, you could also use Alternates for total control, but it doesn't sound like you really need that.

Categories