Validate a request in a view "Orchard" - c#

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.

Related

MVC Unrendering Script and Style files

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.

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.

General purpose paging and summary information

I have a query that returns several thousand records and I'm using some paging to make the results present nicely to the user. In my view, however, I need to have a chart control that displays information of the entire result set, not just what page the user is on at any given time. I'm thinking of a couple ways to solve this:
Let the controller do it's paging thing and on the initial get from the page fire an AJAX call to fetch the entire query and set the chart's source with that.
Or add the entire JSON response as a property to a view model for my view. and do something like viewModelChart.JsonResponse = chart.dataSource kind of thing. Is there a particular pattern to follow when doing something like this? Any horror stories down the road to be aware of if I choose one path or the other?

Avoiding making duplicate panels of controls?

I'm making a web application, but I am not using MVC.
I have pages like: create a task, create a project, create a case...
Everyone of these requests standard information like: StartDate ( a calendar widget, etc), Start time, etc.
If, somewhere down the line, I need to change this standard stuff, say, I need to change the calendar for a textbox, I want it to change everwhere where this is used.
What is a proper way to do this sort of thing?
In the ASP .NET code it would be nice to have like:
SchedulePanel.Calendar.Date;
It does not have to be panel based or anything, but I basically have a group of controls that I need in many places.
Thanks
You can put all of those controls into a UserControl and add that whenever it is needed. Like Robert said, if it is needed on virtually every page, then put those controls into the master page.
asp.net UserControls are really idea for this type of situation.
http://asp.net-tutorials.com/user-controls/using/
Please explain more this statement:I want it to change everwhere where this is used.
If I undesrstand correctly you can put all your controls in a User Control and in code behind declare public variable and change your controls in set section

Ideas - storing jquery parameters for later use in partial view

Ok, let me try to clearly explain what I'm attempting to accomplish here.
Basically, I have a site that is using a liberal dose of jquery to retrieve partialviews into a consolidated 'single view'. So far so good - it all works great and is very performant.
However, I would like to have the ability to 'flag' (using a button) any such set and as a consequence of flagging it, add it to a functional area that I have dubbed 'active-tasks'. What I'd like to do is to be able to then goto that 'active-tasks' panel and see a range of ui tabs that represented the consolidated views that I had added. Clicking on any tab would then re-invoke that consolodated view afresh with the parameters that had been used at the time of flagging it. This would therefore mean that I'd have to store the parameters (?) for creating that consolidated view, rather than the generated html (this part i can do at the moment).
So, any thoughts on how to elegantly store the code required to generate the consolidated view on clicking a tab button - no pressure :)
cheers - jim
Actually, after a minimal amount of research, it looks like the newly updated .data() jquery method (with the ability to add an object to the payload) may work for the above.
http://api.jquery.com/data/
basically, this allows you to add hash type keyed data to an id element for use later, so in my scenario above i could simply attach the parameters required to invoke the action method that related to my consolidated view on the tab.
I'll let you know how i progress with this...
jim

Categories