We have different clients asking for home page with different design layout so what is an efficient way to have multiple pages with different styles, layout for the same data coming from the database in a mvc project?
You could have different css and change the design according to the user that has logged in. If the different design includes placement of elements in different places, then you could use a grid system and store in JSON (preferably) the schema of the page. Then, on each login you should load the JSON and place the elements accordingly. Hope that gave you a small hint!
Related
In our current application there is a new requirement of our client.As they told that they need n numbers of forms at different stages of their business and those are changing time to time. Even a new forms can be added. Their requirement is once the product is delivered to them they will not come back to us again and again for each change and will create those form by their own.
Simply they want a user interface where they can create the form by drag and drop manner.
What they want :
In our application there will be a form building section where a non technical person can be able to create a form.
Mapping the controls with existing data of their existing database so that the form is populated with the corresponding data ( data will be inserted into the database using another user interface).
Once the data is populated they will take the print out of the filled up form and will proceed as per their business flow.
As they introduce new form time to time we can't provide any predefined template to them and they are not agree to design the form in HTML.
Is there any way of doing this in Asp.Net MVC (without using any CMS ).
there are a number of asp.net forms builders. And I been wanting to build my own for years. (you store the control, the location etc in a database, or even as xml, and then on page load, read the xml, and crank out the controls and layout into the page. We all built these for desktop, and you can do the same for the web.
The open source evolutility project has a FANTASTIC system for this, but it does NOT include the GUI part. But, it would be a good start. You would have to build the GUI part, but the rendering part, and save of the forms layout is all done for you. So, your forms builder would offer a set of controls to drop and move around in the form. When you save, you would have a corresponding "xml" markup bit that you save to the one "forms layout" file. On forms load, you read that xml file and produce the form (that's the part evolutility does for you). So, you need the part that has each control in a tool box (along with the xml for that control). you drop control into form, and add the xml to the "form layout in xml".
As I stated, evolutility has all the parts to render forms and layout and place controls on the final finished form for display - it just don't have a GUI for doing this part.
You can look at the project here:
http://evolutility.com/
there are others. But, it really depends on how complex of a form builder or content builder you wish to make.
But, a xml, or json based layout and definition of the controls placed on a page is a good start. You could store such "layout" information in a database. Heck have a classic master to child table, and thus save each control in evolutiity format, and simple append then all together, and then have evolutility render that xml into a working form for you.
I don't know of a open source project that combines both the "layout" and "define" of the controls AND ALSO has a GUI to build the forms. But, to be fair, the hard part (how to layout, and how to have each control defined in some json (or xml) is done for you.
I have an application that needs to support both desktop and tablet browsing. Both versions will be significantly different, using different Layouts in /Views/Shared/
In the Controller I am currently reading the user agent string and returning different Partial Views, which are parsed within the one Layout. I want to have two different Layouts, one which gets rendered for tablets and one for desktop. Currently I have:
/Views/Shared/_HomeLayout.cshtml
/Views/Shared/_HomeLayoutTablet.cshtml
How do I read the user agent string and have the server render the correct View before my own Controllers get called?
You can still use mobile views and the contextcondition to return a different view, even for partials.
http://www.asp.net/mvc/tutorials/mvc-4/aspnet-mvc-4-mobile-features
From the examples in this post, if you wanted a view to be considered only for a mobile, you create 2 versions, one with the .mobile.cshtml extension.
I have two landing pages with the same exact BizForm. How can I tell if a user has submitted the form on page A vs. page B - testing page design effectivness? I want to keep the BizForm exactly the same; otherwise, I'll end up with a bunch of forms to manage. I don't have access to the web part code, so it would have to be a solution I can do through the CMS GUI.
Using Kentico v5.5.
Look at using an Alternative Form. It's basically a copy of the same BizForm, and you can modify/change a few of the fields. Create one extra field on the BizForm, and assign the value of it based on which form you're using (main or alternate). Just don't display the value on the form itself.
Then, on the page, specify whether to use the main BizForm, or the Alternative BizForm.
I have an ASP.Net web page that displays various chunks of data based on a user's search string. In this web page I'm using a <Panel> tag because I need to have a vertical scrollbar that displays when needed to display all of the data.
I've thought about defining an HTML page (in code behind, with all the tags and data included), and displaying that inside a <div>, inside the <Panel>.
I've also explored the possibility of displaying an ASP.Net web page with the data/tags/etc. and placing each page in its own <Iframe> element. I'm afraid that this solution would be slow to load (as compaired to the HTML method described above) especially when there's 100's of individual pages to be loaded.
My question is what's the best way to display N number of individual pages of data and have a vertical scrollbar when there's a need?
Displaying various data pieces on ASP.NET pages is a big subject, I suppose, and many methods can be used, including the ones you've mentioned.
How about making use of Dynamic Data framework .NET v2,3,4. The most powerful is the latest one of course.
Then you don't need to create 100's of individual pages, just onthe fly redirect using metatable names used in your model/context. All you data will also be wonderfully linked where appropriate. Also need to carefully design you model based on however your data needs be presented. The controls for that could be GridView or other, but all done on server side.
I have an issue where I have two pages that deal with very similar things and as such quite a few of their methods and aspx server controls have identical method names and variables. In short, it's pretty obvious that the code was copy/pasted and the innards were merely altered. I have a pending request that the two pages be merged so I've explored a number of options as to how I should best merge them.
First I thought that perhaps I could put one of the pages in a masterpage that will allow for a content place holder wherein I'd then put the code/controls, but it looked to be a bad idea once I started to make plans. For one the similar names would probably still be a problem and second it seems a rather clunky way to merge two pages together.
I've considered renaming all the methods and controls but on the other hand it's going to take a lot of time picking over the code and the controls to rename them all. My worry is that if I try to change the problematic method names, controls, IDs, I'll introduce a lot of bugs in the code.
Is there a better way to view two pages in one webpage?
You can do so with iFrames. But I think the website gets better maintaining with .net controls (.ascx files), and then calling them in a new page
That thing is called user control.
UserControl class
read this official tutorial
I think there can be 3 options that will work for you:
1. Put all common stuff in a user control and use it in both pages. This is the most straight forward solution and this is the main reason user controls exist - reuse of both UI and code behind. This is most likely the best option.
2. Have a utility class that will contain all common methods. The disadvantage of this solution is that you will only share code, not UI.
3. You can have a BasePage that inherits from Page, and have both pages inherit from BasePage. Again, you will shared only the code, not the UI. This is usually a good solution when you want to add some functionality for all your web pages.
If it is for ASP.Net Web Forms have you checked out Nested Master Pages, not merely a single MastPage?
If you have a common Theme or layout this goes in the Base MasterPage, your nested MasterPage then exposes common UI controls, Events Handlers etc that are common between the next group of Pages (the layer you referred to), your final ASPX Page then exposes the individual page functionality that is different between the ASPX Pages, UI controls, Events etc for each unique page.
By using the # MasterType page declaration you ASPX Page has a strongly typed reference to one or all MasterPages which would allow the ASPX page to easily access methods and properties of the common MasterPage.