I want to create a wizard that includes a few steps, that in the final steps
we need to include all the steps and save to the data base.
What is the best design to do this ?
Is there an implementation for jquery ?
Do I need to save the steps in session till the final save ?
If you will not go to the database on each wizard page, then you will have to use either sessions or cookies to store the data between page requests.
You can also use client side tricks that will utilize javascript and hidden frames to hold the data.
I have created a few wizard for www usage. If you need to create 2 or more wizards then it is better to create a simple wizard framework responsible for navigation and data storage in session.
In my case every wizard step implements IWizardStep interface responsible for temporary data storage, as well as some common information like step number, display strings, next & previous steps etc. Then I just put them together and the framework takes care of displaying them in order, navigation and processing.
I'm not that sure if this is what you need but the C# has a wizard control that is a good way to implement wizard type processes.
http://weblogs.asp.net/scottgu/archive/2006/02/21/438732.aspx
Else, If you want to implement your own flow, use session to capture the values per step and save it later on the last step. cheers..
Related
I need to create a dynamic form.
The user can add new input box to the form and define if this is gonna be used for text, number or date, he can add N input box
How can I create dynamic forms and then save the data in a database
And what is the best way to save the data in a sql server table?
thanks
What you're trying to achieve is a Form Designer. It can be done as a simple student project, to some large framework supporting lots of features.
A lot of the convenience tools that Asp.Net MVC provides will not be very useful to you and you need to get lower-level to handle this.
Also, lots of architecture decisions will arise, and making the wrong decision in each step can lead to a useless product.
An Exmaple:
Are you going to store all user data in a single table, or you'll create database tables that will match user designs?
Are you going to allow inter-field relationships: Field B is invisible/disabled unless someone fill field B.
What I'm trying to say is that this is deeper than what can be covered in a SO answer.
C# - ASP MVC - .NET 4.5 - Bootstrap - Razor
I have a form wizard (http://vadimg.com/twitter-bootstrap-wizard-example/examples/basic.html) that is used to setup a complex object (obj1). A property of obj1 is a List<obj2>. On one step of the wizard I want to add multiple obj2's to the list. Since obj2 is slightly complex as well, I thought I would use another wizard to help build it. Except I need to persist this List<obj2> on wizard 1, while I'm off in wizard 2 building another obj2.
My first thought was to use a session to hold the List<obj2>, I was just wondering if that's a good option, or if there would be a better one? The user may leave from Wizard1 to go to Wizard2 and come back multiple times.
There's no perfect answer here; each approach has trade-offs. But here are some options that I can think of (and these are independent of ASP.NET/C#)
Session (as you suggest)
This will store data in web server memory (by default). If you have a lot of users, this could be a problem.
You risk the information being lost when the user gets a new cookie/the session times out.
Potentially better performance that a db, depending again on the number of users
Database (as you mentioned)
Could cause more database traffic.
Can save information for user even if they close a browser, switch computer, the power goes out, etc.
Maybe a separate NoSQL database just for transient wizard data would be worth trying.
Cookie (store data on the user's computer)
Users can potentially tamper with/view the data
There is a limit on cookie size (4 KB each?)
Local storage (HTML5)
Similar to cookies
But not such a small limit
Not every browser supports it (may need polyfill)
Form/Post/Hidden/ViewState
You could just post the data and drag the information from response to response
But this gets really annoying with back buttons & timeouts
Lots of work, and again, the user can tamper with the information
I want to be able to maintain a count and a last accessed date across application loads for a web service polling application. I'm not too sure what the best way to do this is. I dont like the idea of storing that data in a database as I would have to create one specifically for the purpose. What other options do I have and are there any particularly nice ways of keeping application state between subsequent runs of the app?
Persisting data eh? I suggest a database or file.
File solutions you can just XML serialize to a file and load it again when the app starts.
If the data is shared or might ever grow, then a database is probably the best solution. You can find one that fits your need among the many free projects if you wish:
couchdb
mysql
postgres
mangodb
membase
sqlite
etc
You could roll your own solution that doesn't involve a database, but most likely there is one that fits your needs and learning it would be useful beyond just the project at hand.
Don't be afraid to make a 'configuration' style table for your website, that simply has only a few rows and let's you store runtime information as needed.
Perfectly fine.
In our application we want to 'translate' labels. I don't want to hit the database multiple times for the same label. So when I already have fetched the term X I want to get this term from the cache.
Now I am thinking on how to implement this. I could think of this options:
Create a Singleton. So basically you are creating a public variable
Create a class with a static list on it which contains the cached translations.
What should you do?
I am using C# winforms.
Edit:
I don't mean lanquage translation, but term translation. Our customers have their own term for the same thing. So this is a setting in our application. Say you have term X, they can say, I'd like to call the Z. So everywhere in the application where X is used, Z must be displayed.
Every form has a few labels with (the same) terms. So the data itself is small (only one word), but it is possible that it goes into the database 20 times to get the terms for one form.
The ASP.NET HttpCache is also available outside ASP.NET. You could use this as a backing mechanism for your cache and access it trough a Singleton.
Another option if it fits your scenario could be a T4 template that would parse your database and generate a class at compile time. This is way faster that doing the database look up at run time. Only if something in your database changes you would have to rerun your T4 and deploy the new assembly.
why don't you try Application Settings. while i don't recommend it for large amount of data bcoz it tend to put a load on application and is not intented for storing large data but you may use it if your data volume is small .
Go to Project>Properties>Settings Tab and add a setting of type User of Type Dataset (Use Browse Option for more types) or something more closer to your needs.
In the Runtime assign or retrieve using
<datatype> obj=Properties.Settings.Default.<yoursettingname>;
I'm trying to build a web application that let the administrator talk to the database through C# and add new tables and columns to fit his requirements (sort of a very simple database studio) but I'm not trying to just create some spaghetti application.
So I'm trying to figure out how to let those things dynamically (automatically) when he creates a table and use the table to build them :
1- The business objects or entities (the classes, it's objects and properties).
2- The Data access layer (some simple methods that connects to the database and add, update, delete retrieve items (objects)).
Is this possible ? any pointers on how to achieve it ?
EDIT
just opened your link!! .. it's talking about the data bound controls and stuff! .. my question is way more advanced than that!.
when you build an N-Layered application you start with the database schema and implementation and it's easy to do programtically then you start building the DAL classes which (add, edit, etc in other words the CRUD operations) in and form this database
what I want to do is to allow the web administrator to choose add the new table through my application and then -dynamically- the application would take the tables names and columns as parameters and create new classes and define within them the CRUD methods that will implement the SQL CRUD operations
then it would also create dynamically the classes and define within them the variables, properties and methods to call and use the DAL methods .. all this based on the table, column names
NOTE : All this happens on the run-time!
You might want to look into ASP.Net Dynamic Data. It's a RAD tool which very easily gives you CRUD functionality for your entities and more. Check it out.
Sometime back I had also asked similar question on SO. I got only one reply.
Today I was digging some information on MSDN and as I had guessed it, MS CRM entity model works based on metadata. So basically whatever a CRM developer is working against is just metadata, they are not real objects as such. Following is the MSDN link.
Extend MS CRM Metadata and here is the MS CRM 4.0 SDK.
I hope this should get you started.
Update: Recently hit upon Visual Studio LightSwitch. I think this is what we wanted to build. A UI which will pick up table information from DB and then create all CRUD screens. VS LightSwitch is in its Beta1 and has quite a lot of potential. Should be a nice starting point.
First, any man trying to create MS Access is doomed to recreate MS Access. Badly.
You are better off using ASP.NET Dynamic Data (as suggested) or ASP.NET MVC Scaffolding. But runtime-generated playforms that actually make decent applications are really pipe dreams. You will need developer time to do anything complex. Or well.
What you are asking is non-sense. Why? Because the idea behind BLL and n-tier is that you know your data model well, and can create a static class model to represent your data model.
If your data model is dynamic, and changing, then you cannot create a static BLL (which is what a BLL is). What you will have to do dynamically build your queries at run-time. This is not something that any of the traditional methods are designed to handle, so you must do everything yourself.
While it's possible to dynamically generate classes at run-time, this is probably not the approach you want to take, because even if you manage to make your BLL adapt to your dynamic database.. the code that calls the BLL will not know anything about it, thus it will never get called.
This is not a problem you will solve overnight, or by copying any existing solution. You will have to design it from scratch, using low level ADO calls rather than relying on ORM's or any automation.