I am designing a pretty complex webform with Master/Detail structure. Is it a good move to keep the add/edit form on the same webpage ?
My current scenario has 2 separate web pages (add new & edit), On add new page the add details is disabled until user saves the master.
On edit page everything works out of the box.
Both the forms have exactly similar controls
I am thinking about the following new structure - Same webpage for Add/Edit (User adds master
record (add mode) -> Saves -> Gets
redirected to the same page with edit
mode-> Can add,update delete new
Details or Update the master he
just entered
What do you guys prefer in such scenarios ?
On a note, separate webform for edit page means duplicating everything
with just some minor changes to Save/Edit functionality. Also for the details I have to provide Add/Edit/Delete on the same page anyway
Thanks Damien.
No, it's not a good idea. My experience is that add/edit might look quite similar, but they have things that differ. The number of differences usually grows as the project grows.
Use different forms, or you'll end up with spaghetti.
You might however move parts that will not change to user controls and include those in both pages.
I suggest to use JQuery and Open Popups for such operations for new and edit case. This will also make reuse of your controls.
Related
I have been doing typical menu from code behind where i just show and hide divs based on their role but code becomes very long cause i have to hide every single div of each role for each user.
My question is... Is there a better practice to do this? I also just found out about Login View, is this the way to go in Web Forms?
Your code behind should not take the responsibility of altering how the View is displayed, that's the job of the view (and that's why asp controls exist).
One approach would be to have a logic that builds up a List and this list is passed as DataSource of an asp control.
Actually there's a good control that allows you to iterate a collection of elements defining a display template for each element in that list, here you can find the details:
https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.repeater?view=netframework-4.7.2
I hope this sets you in the right path.
A common way to do this is in a WebForms app is to use a SiteMap.
A site map can be linked to roles, so that only those elements that are accessible for a user's roles are displayed. And recent versions can be made to display reasonable cleanly, as divs that can be styled how you want (the original version generated a lot if inline styles).
For an MVC sitemap there are similar solutions, such as this one.
Lets say you are developing an web app that requires that you are able to Add/Edit items. The item form contains several input control. Would you separate the add/edit pages or use the page for add/edit and control via querystring (i.e. ItemAddEdit.aspx?isEdit=1)
The advantage I see in separating is that it is easier for the (non-technical) user to type the page and to determine whether it is add or edit. Also, when there would be specific changes to each page (if ever), it would be easier to change.
For the single page, well, you reuse code which eliminates some duplicate code and avoid possible problems.
And no, I can't use routing.
This is generally something which could be a subjective thing, because there's as many ways of doing things as there are coders, and a lot of it can be depending on how your system is set up generally.
But, if I were to recommend, I'd say the way you should do it if working with asp.net web-forms is to make two web pages (add/ edit) and then you use a user-control on those to group up the shared logic between the two pages. After all - that's why we have user controls.
In this way you can have both of your situations, by keeping logic in one file/class, but still have two entry points.
This would also mirror more how MVC does it, which could be considered a plus.
That being said - if your administration functionality is behind login etc, there's nothing to hinder for actually doing it in one and separate with the query string approach, and then just load the data if editing or display "empty"/base data when creating.
You shouldn't have the user type the addresses anyway, but click through the links to follow your flow, so the query string should be a minimal issue.
But for the sake of keeping your functionality clean and divided, I'd personally recommend going for two page / usercontrol approach.
Well, I am trying to implement a wizard interface to help the user to choose the right service then add it to the shopping cart then possible checkout or discard.
This is similar to the concept of the t-mobile / att. Where we select the type of plan then the services we want ( minutes , data plan, mobile phone device then checkout) . The UI should be very web 2.0 like there would be help text , suggestions.. etc.
The technology is asp.net 4.0 (mvp - codebehind model)
I did a lot of research, looked around using state design pattern , commander pattern.
My thinking is like a pattern where we have a Wizard controller which controls the wizard steps then once done hands over to the checkout process the end user can always go back and change any options during the wizard. Incase if its a existing customer then we have to skip few steps as we already few details.
Its all custom UI, I was thinking to use asp.net mutliview and each view loads based on current and next step.
In Brief I am confused and need some directions
Be aware that the multiview actually loads all details behind the scenes, one reason I don't like using it.
You could easily just have several ajax update panels. Each is the step of the wizard and when you post each item, you hide that panel and show the next step and potentially update and step indicator you have on your screen.
You have several choices -
1. jQuery and ajax calls to load details into divs
2. update panels (as described above - my choice here)
3. wizard and multiviews - Im not a fan of using them. Certain customization issues exist with these built in controls at times and you need to be wary of certain details - like multiview actually processing all data for hidden items (if they contain queries this could significantly impact your system when you don't expect them to run and they do even though the view is hidden)
I'm an ASP.NET newbie, but not so new at programming in general.
I'm creating a commercial website, and I want to allow an admin to add new articles (an article consists of text, images and various properties such as category).
I am trying to decide the optimal Modus Operandi. This site is commercial, so SEO is a major consideration. This means that I want each url to be "unique". That is, if someone navigates to an article about raccoons, he should be redirected to www.mysite.com/articles/raccoons. This means - I can't have one page that loads the appropriate article dynamically a-la AJAX (gotta use deep-linking)
So how exactly do I do this? suppose the admin entered his text, uploaded the images and set the article properties. I create a new subfolder, save the images to the server (I understand that saving images to a DB is a big no-no), their addresses in a DB, and the content itself to the DB. But now what?
How do I go about creating the actual page?
Is there a function for creating a new aspx file? then what about its corresponding cs file? Or is it unwise to use aspx? Maybe plain html? but then how does it work with my site's master page? Or maybe just create another copy of a general aspx file which is populated with an article according to a parameter?
I would like to know what is the "smartest" approach before I dive in too deep.
You can Consider ASP.Net MVC for this. What you need is more like a Content Management System rather than a Blog, as you mentioned an administrator will add articles.
By Using ASP.Net MVC, you have a very clean implementation there, your urls will stay as you need it for SEO, You dont have to create aspx pages on the fly but the framework will let you deal with new urls from your class files.
I am doing a small human resource web application in my workplace and i have a CV section were employees can add their CVs to be displayed to the human resource manager.
I want to make something similar to what Stackoverflow Careers has done in the Experience and Education sections where the users can click the "add more experience" or "add more education" links for new form elements to appear and a remove, move up and/or move down links appear.
I think that this was possible using jQuery and either the append or appendTo functions. That's as much as I know about jQuery and have no idea on how to go about implementing that.
The solution that i require should:
Enable me to add a template one for
the Experience section and the other
for Education
On the loading of the page at least
one education section and one
Experience section appears on the
form
Form controls must have an
identifying value added to them to
distinct them from other sections.
For instance, when the page first
appears each form control should end
with 0, when the add more button
is clicked, each form control's name
should end with 1, and so on.
Some sort of validaion
I am using ASP.NET WebForms if such information is needed.
Thanks,,
I'm assuming you know how to code C# / .NET.
Make the code which dispays CV.
Then start learning jQuery by going here: http://docs.jquery.com/How_jQuery_Works
Understand jQuery, and things will get less complicated.