I am new to ASP MVC3 and I am trying to make a set of pages for creating and editing sales notes records for customers in our database. On the Customer detail page, I have a table that will display all sales notes for the selected customer and it has a "Create Note" button that goes to a create page for sales notes. How do I pass and pre-populate the CustomerID field on the note with the ID of the customer from the previous page? I searched for an example or tutorial that had this scenario but didn't find one. If you know of a public example a link to it or a direct answer to the question would be greatly appreciated.
You can accomplish this fairly easily with routing parameters. First you need to define the route for the create note action that takes a customer Id. Next, you need to create the action so that it accepts the parameter.
A quick Google search or "ASP.NET MVC Routing Parameters" turned up this URL which explains it very well:
http://www.asp.net/mvc/tutorials/older-versions/controllers-and-routing/asp-net-mvc-routing-overview-cs
Related
I am creating a form which will be used to nominate multiple people from a various teams for an award. There is no limit on the amount of people that could be nominated so it is hard to say how many nominee info I should add to the form. I am curious if there is a way to create a nominee info i.e. Full Name , Email , etc with an option too "add another nominee" where the user could specify more than one person info on the form without submitting multiple forms. Also user should be able to edit or view the already added nominee info's
Example:
About your nominee:
Nominee's Name: Steve
Nominee's email : steve#gmail.com Nominee's
Country : drop down list
add another nominee
You could create a form (or a modal popup) with a Html Table, an Add button and a Submit Button.
The Html Table is used to store the nominee information.
The Add button is used to dynamically add rows in the Html Table, inorder to add new nominee information.
The Submit button is used to submit the nominees. Use JQuery to loop through the table and post the list of entities to the action method.
More detail information, please check the following links:
Dynamically add rows to HTML Table in ASP.Net MVC
Pass (Send) List of objects from View to Controller using jQuery AJAX in ASP.Net MVC
I'm working on a Sitecore 8 Update 2 site.
I used web forms for marketers to create a login and register page. These worked fine and were easy to use. On the register form i was able to link fields on the form with fields on the selected user profile, nice and easy.
Now i want a page were user can edit their contact data.
However when i want to link the fields of the form I can only link them to facets. I have filled in the " User Profile " field of the form with my profile. So i would like to link these fields just as a register form does.
Is there any way to achieve this ?
If you want to update contact data you will have to update facets using the Update Contact Details Save Action - this is how xDB works and exerything is a facet. Each bit of information in xDB needs to be updated via a facet
e.g. the Personal Info Facet
var personalInfo = Tracker.Current.Contact.GetFacet<Sitecore.Analytics.Model.Entities.IContactPersonalInfo>("Personal");
personalInfo.FirstName =firstname;
personalInfo.Surname = surname;
To register custom facets there's a good post here:
http://www.sitecore.net/learn/blogs/technical-blogs/getting-to-know-sitecore/posts/2014/09/introducing-contact-facets.aspx
See the pictures below how you need to configure this.
The Create User save action needs to be configured to update user account and profile. NOTE the password field. You cannot change that this way. To change the password there is another action.
The Update Contact Details save action will update the XDB contact.
Screencast pictures
Basically, what you need is to use out-of-the-box "Update Contact Details" Save Action on your form, which will allow you to bind form fields to your contact's facets.
I have blogged a solution for this recently!
Check this post for more details: https://broair.wordpress.com/2016/08/17/wffm-associate-form-fields-with-xdb-contact-facets/
I'm new to MVC and having a rough time with this. I have read many posts and books and done tutorials and I am now going to ask the public for help.
My situation:
I am upgrading part of a classic ASP website to MVC. It is the FAQ portion of the website.
I've got a controller called FAQController and a View Result called, Display, that takes in the parameters Year and faqID and then displays the related FAQ information in the view.
I want to be able to have a user rate how helpful the FAQ was by clicking on a set of links or buttons that will look like stars (1-star through 5-star ratings)
I want the onclick event of the buttons to route to an [HttpPost] ViewResult that then stores the rating in a database and returns them to the previous view with whatever selection they made highlighted. So if they click 4 stars after the information is submitted 4 stars would be highlighted.
So I have an int rating property in my model that I want to be able to change in the view, then update to a database, and then display the change once the view loads again.
My question is what is a good way to change the Rating value of the Model before I resubmit the model to the controller?
I see I can use #Html.Hiddenfor(m => Model.FAQRating) to get the value of the first model rating (which by default is 0) but how should I go about setting that value before I resubmit the form to the controller.
Am I even thinking about this correctly? I thought I might be able to add a "rating" parameter to the Display view result but that seemed dumb.
Hi fellow StackOverflow Members,
I'm tired of bumping my head on the wall, so I would like to explain my problem here, hoping to get a solution for it.
I'm developing an ASP.NET applications, using C# and Razor. I've also implemented the Telerik.MVC.UI for Grid displays.
What I'm trying to do now is, on my Create form, show some sort of Cascading Comboboxes.
I found a lot of tutorials on the internet, explaining how, however, my database structure isn't
identical.
Most tutorials work with 2 or 3 tables (Entities), but all my data fields are in one table.
My table is constructed as follows:
ID Division Department Country
So I would like to have the first dropdown to show a SELECT DISTINCT of Country, next I would like to see the matching Departments, and last I'm searching for the matching Divisions.
As mentionned above, this is all within a create form, so upon POST, I want to pass the related ID to the Controller Action.
Any help is appreciated, as I'm totally stuck...
Thanks in advance.
Use strongly typed view models. Make a viewmodel for your division, department, and country (basically a class which holds a list<> of each field from your db table). In your controller fill the viewmodel holding all three from the database and then pass it in return view(viewmodel). In your view you can then use someHtmlHelperFor(model.division or model.department,etc.).
How do you populate data coming from SQL server based on users request?
Example:
I have a page with about 50 links(all user links) and I want to be able to have the user click on their link and bring another page(template I believe) with all their data. The catch here is that I don't want to create 50 pages(one of each user).
How can I accomplish this in ASP.NET C#?
Its simple as creating an aspx page and a model.
Profile.aspx - this page contains all the view display for the current user or the requesting user. You can pass the user id through the link you had. Example:
John Doe
Now in the page load or the controller (MVC) - code behind you can use that id to retrieve the details of the user and start to populate to your aspx page. Example:
txtName.Text = UserModel.Name
Or if your are using MVC for the web application it will be easy as naming the controls and setup the model in your view aspx.
I think this site could get you started: http://www.asp.net/mvc/tutorials
There should be very similar examples to what you would like to do. Explaining it here would just duplicate existing good material.
If you are completely new to programming, try a C# tutorial first, for example: http://www.csharp-station.com/Tutorials/Lesson01.aspx