Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Question: Are there any Mvc framework solutions that I can leverage to create a clean and concise approach that represents my user control that I am converting? (There are four major design considerations listed below)
This user control has a lot of explanatory text information within. I really want to avoid writing a helper method that is a mile long containing a ton of standard HTML and text.
This user control contains a Grid. I have written my on Grid control in Mvc but I have not had any experience as of yet with composition of html helpers in a clean fashion.
This control is only presented to the user as a result of uploading a spreadsheet for importing purposes.
The design needs to account for being in a standalone dll that is used in other projects.
I was considering the idea of using a Partial View. This would be preferable since it could make calls to the html helper to render my grid and contain the explanatory text.
However, I couldn't find examples online that really lent themselves to my scenario. So I not confident of the details.
Thanks for input in advance.
Explanatory text can be stored in a view model. It'll be stored in a
single place and it can easily point to a resource file with
localization (if needed)
Re-factoring. I can't get into more details as I haven't seen the code
If you opt-in for a partial view, you can render control with #Html.RenderPartial, #Html.EditorFor, #Html.DisplayFor depending on what kind of control this is. In my project I have controls for storing and displaying search criteria. So I have something on the lines of
#Html.EditorFor(model => model.CategorySearch, "CategorySearch")
I'm not sure about a seperate DLL, but if you have a clear seperation between a view and domain model, then you should be able to get away with copying your view model and view related components (e.g. partial view, editor/display templates etc)
I hope this helps
Related
we have a small questionaire application,
and 1 of the main sections is the questionaire itself.
it has a big view for some general templating, introduction and title etc
and it has subviews per question (with next and previous buttons)
we decided to use routing, because from several places one can jump to a specific question
so we use /ivr/4 to show question 4, and /ivr/overview showing the final overview.
so in a way you go from /ivr/1 to /ivr/2 ... to /ivr/overview
now, if one comes from /ivr/1 and arrives on /ivr/2
the big view is there, and it should only update the question to the right question
but when you arrive from /home to /ivr/2
the big view is not loaded, so one should first open the questionaire and then load question 2
currently i have it always rerendering the big view
which works, but is lots of overhead and i would like to refactor this to a better way.
can anyone give me some guidance as to how i would structure routeActions and or views
to only update the big parentview when it actually needs to, and do the question view only, if the parent view is already there.
do i need events?
or would i go with partial routes?
any tip is welcome.
I think both of your proposed solutions sound workable. If you go with events, I'd recommend using the event aggregator pattern to facilitate communication between your views. This seems like the simpler option to me.
The other solution, partial routes, might be more involved. Check out the Backbone.Marionette plugin, which was designed to help manage complex view manipulation.
This question already has answers here:
Closed 11 years ago.
I'd still like my users to have a choice of image to select when sharing links from my site but I would like to restrict certain images from showing in the Facebook sharer. I don't want to select a specific image using meta tags (this has been suggested often).
Would appreciate any help!
EDIT (9 Jul 2012): This question is not an exact duplicate to any others on stack overflow. I asked for a method to restrict images from showing without specifying OG or meta tags, unlike others who have simply asked how to show a specific image. Why do people on this site assume (and rate my question down) before even reading it carefully and considering whether it is a duplicate.
The only way to do this is to specify multiple og:image tags of images that you want to allow and then the user will be able to choose from the images you select.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I have been searching the internet for days now trying to find out how to write my own script, one more complicated than the "Hello World" script.
I understand for the most part how to find specific elements using firebug (I have Firefox). I understand the metadata and how to do all that.
I do not however understand how I am supposed to get whatever I want into the page. Be it links or tabs for Facebook or other sites.
Can anyone help me get a full tutorial/guide that is up to date and easy to understand for total scriptwriting beginners?
From what you have described in the, I suspect that anything that meets your criteria will actually just be a Javascript tutorial with some extra Greasemonkey-specific sections / focus
There's not links to many guides and tutorials (might add them in later) but I really think that what you need is a beginner's guide to Javascript such as sections 1-8 (except 5) of the one provided at the Mozilla Developer Network.
Greasemonkey stuff:
Specifically, the Greasemonkey-related topics that you will need to read up on are related to the DOM, altering styles of DOM nodes, and the Greasemonkey API. All else that you need will be generic Javascript that will be specific to the script you are creating.
DOM Manipulation:
Inserting / editing / deleting "nodes" ( in the HTML code) - for example, <a>nchors, <div>s, <img>s
This is how the extra links and tabs etc are added into the page.
Specifically, look into appendChild(), createNode() and insertNodeBefore().
DOM Traversal
Moving around the DOM (HMTL Document) and selecting where to insert the new nodes / selecting which nodes to editor delete.
Specifically, look into XPATH, getElement(s)By_____, parentNode, querySelectorAll()
Introduction to using XPath in JavaScript - XPath | MDN
Node.parentNode - Web APIs | MDN
CSS Using Javascript
The basics of changing the CSS of a node are to either use .setAttribute() to set the 'style' attribute, or to alter specific CSS properties using nodeReference.style.cssAttribute = 'value'.
Greasemonkey API
Again, this stuff will be specific to what you want to use within the script you create but the basics include GM_getValue(), GM_setValue(), GM_log()
Greasemonkey Manual:API - GreaseSpot Wiki
Look at Greasemonkey Hacks archived, especially the part Avoid Common Pitfalls archived - I'm often returning to the latter.
Edit: the original links are dead, added links to recent archived version in superscript.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
This can be applied to any language/UI project. When the code is automatically generated, is there a need to name all of the UI controls? Presently I only name the ones I am referencing in code (although admittedly sometimes I get lazy and leave them). Or do you stick with the pre-generated names (textbox1, splitContainer1, menuStrip1, etc..)?
If you name them, how do you prevent overlap such as MyDataGridView1, MyDataGridView2, etc..
I only name the ones I reference too - most modern IDEs will easily rename a widget later if I need to reference it in code.
I usually give the names some meaning - accountDataView, currentBalanceDataView - it must relate to a concept like submitButton for the button that submits a form.
I always try to set GenerateMember to false for the controls I don't use in the code, but for the controls I do use in code, I usually choose meaningful names.
For example, if there was a button that submitted something then I would choose submitBtn. If there was a username textbox then I would call it usernameTxt. Etc, etc.
A small list:
Buttons: btn
Textboxes: txt
Labels: lbl
Checkboxes: chk
Radio buttons: rad
List boxes: lst
Dialogs: dlg
...but above all else, just use what makes sense.
I name the controls that I access and have experimented with using the "ux" prefix so that I can find them easily with Intellisense. That way if I can't remember the exact name of a control I know it at lease starts with ux. Also, if I change the control type, the name can stay the same. I came across this a while back, but can't seem to find the article about it now.
uxFirstName
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I need to explain to a not-very-technical manager the MVC (model-view-controller) concept and ran into trouble. The problem is that the explanation needs to be on a "your grandma will get it" level - e.g. even the fairly straightforward explanation offered on MVC Wiki page didn't work, at least with my commentary.
Does anyone have a reference to a good MVC explanation in simple terms?
It would ideally be done with non-techie metaphor examples (e.g. similar to "Decorator pattern is like glasses") - one reason I failed was that all MVC examples I could come up with were development related.
I once saw a list of pattern explanations but to the best of my memory MVC was not on it.
Thanks!
How about this - off the top of my head, hopefully it works for you.
MVC can be metaphorically related to a TV. You have various channels, with different information on them supplied by your cable provider (the model). The TV screen displays these channels to you (the view). You pressing the buttons on the remote controls affects what you see and how you see it (the controller).
I was watching TV, so I got some inspiration from there!
I don't trust metaphors. But it's not hard to explain it:
the Model is the part of the code that knows things
the View is the part of the code that shows the things the Model knows
the Controller is the part of the code that gets commands from the user and tells the View what to show and the Model what to know.
The best way I describe it would be:
The Model is the data source. It's your database storage, it's the
code needed to add/remove/update/change the information you
warehouse.
The View is the part the user sees and interacts with. An HTML
page, an application window.
The Controller is the code that marries the View to the Model. If
you clicked a "Delete" button, it handles the business logic and
rules (are you the authorized person to delete? is it a deletable
record, etc).
The View doesn't need to know anything about the Model. The Model doesn't need to know anything about the View. The Controller is what marries the information source (Model) with the output (View).
Think of it in terms of video games. Way back when - there were tons of different video cards and how they worked. Games needed all kinds of code to talk to them. You had to choose what kind of card you had before you could play the game. Game developers had to create code for different video cards.
Along comes something like OpenGL or DirectX -- and it acted as the middle-layer between them. Game developers could write to the DirectX interface -- instead of different card's instruction sets. It freed game developers from having to know about the specific video card. It freed card makers to be able to design to the DirectX instruction set.
In this case - you playing the game is the View, DirectX is the Controller, and the Model is the video card.
M-V-C Think of it as: "Order Details (including Customer & Employee info)", "HTML/ASP Form (to display the OrderDetails)" and "Order details service class (having methods to SaveOrderDetails, GetOrderDetails etc.).
The Model (Data Class e.g. OrderDetails)
The data you want to Display
The Controller (Service class)
Knows about the Model (Order Details)
Has methods to manage the Model
And as such can be unit tested Its Single Responsibility is to manage the OrderDetails CRUD operations.
It knows NOTHING about the View
The View (ASP Page)
Displays the Model (OrderDetail's ViewData).
It has to know about the Model's structure so it can correctly display the data to the users on screen.
The View's structure (style, layout, HTML etc., locale) can be changed at anytime without it changing anything in the application's functionality.
And as such, many Views can display the same Model in many different ways.
In multi-tenant web applications, Customer specific Views can be stored in a database table and displayed based on Customer information
Tell "your grandma" that you are the model (you are doing the work), he is the controller (i.e., middle manager), and the view is like marketing, they get all the credit.