Last post Nov 10, 2019 09:14 PM by bruce (sqlwork.com)
Nov 10, 2019 02:56 PM|mhanisafa|LINK
Partial view and View Component are good in sharing view between page but for display only , how can i create a share page that take input from user and used it in other pages , for example
is it possible to create a page that select a group of users from a list and then use it in other pages , in each page i supply the list of users to select from and get the selected users.
other example , if i have a create user page that want to use in school create to create admin user and in office create to create office admin , both school and office creation pages have other related info , but they user the same user info
PS: Im using ASP core pages
Nov 10, 2019 09:14 PM|bruce (sqlwork.com)|LINK
first you need to understand how browsers work. they make a request via user entering a url in the browser bar, clicking on an anchor or a form submit. the the first two cases only parameter on the url are sent to the server, in the form submit, only form
fields in the form. a browse page can support multiple forums (but not nested), but only the data from one will be submitted.
so a shared component it can be part of the page form, and thus be one of the form submit values or it can be a separate form with only its own submit values or none if the page form is submitted.
if a component is part of the page form, you need to standardize its form element names, and add to all models. this can be done by an interface for models, or base model that has these field names for binding. you could also write middleware that would
harvest the values.
once you have decided how to manage the post values, you can write the component.
another common approach is client code and ajax so the compoenent can be totally independent.