Should I create my search filters box like as a ViewComponent?
All examples that I found in web, use the ViewComponents for complex components that resolve itself, in other words, components that execute some logic and show some result without interact with the caller view.
But I have the search box bellow that will be used in some views and will should interact with the caller view
When the user to click in search button, the caller view will be load with the filtered data in a grid or table.
In asp.net webforms, I could create my own search filter box in a usercontrol, but in netcore, I don't know if I should use this new feature called ViewComponent for that.
what do you think?

asp.net-core asp.net-core-viewcomponent
add a comment |
All examples that I found in web, use the ViewComponents for complex components that resolve itself, in other words, components that execute some logic and show some result without interact with the caller view.
But I have the search box bellow that will be used in some views and will should interact with the caller view
When the user to click in search button, the caller view will be load with the filtered data in a grid or table.
In asp.net webforms, I could create my own search filter box in a usercontrol, but in netcore, I don't know if I should use this new feature called ViewComponent for that.
what do you think?

asp.net-core asp.net-core-viewcomponent
ViewComponentis not a new feature in ASP.NET Core. Since you're new to it, I suggest you to take a tour here: View components in ASP.NET Core. However, there are a lot of ways to achieve this goal, not justViewComponent
– Foo
Nov 24 '18 at 4:37
Yeah, I agree, but, what do you think in I use ViewComponent to achieve this goal?
– agpcardoso
Nov 24 '18 at 4:43
I have no idea since you are learning how to useViewComponent. Just learn it and you will know how it's good, when to avoid.
– Foo
Nov 24 '18 at 4:47
add a comment |
All examples that I found in web, use the ViewComponents for complex components that resolve itself, in other words, components that execute some logic and show some result without interact with the caller view.
But I have the search box bellow that will be used in some views and will should interact with the caller view
When the user to click in search button, the caller view will be load with the filtered data in a grid or table.
In asp.net webforms, I could create my own search filter box in a usercontrol, but in netcore, I don't know if I should use this new feature called ViewComponent for that.
what do you think?

asp.net-core asp.net-core-viewcomponent
All examples that I found in web, use the ViewComponents for complex components that resolve itself, in other words, components that execute some logic and show some result without interact with the caller view.
But I have the search box bellow that will be used in some views and will should interact with the caller view
When the user to click in search button, the caller view will be load with the filtered data in a grid or table.
In asp.net webforms, I could create my own search filter box in a usercontrol, but in netcore, I don't know if I should use this new feature called ViewComponent for that.
what do you think?

asp.net-core asp.net-core-viewcomponent
asp.net-core asp.net-core-viewcomponent
edited Nov 24 '18 at 4:38
Foo
1
1
asked Nov 24 '18 at 4:24
agpcardosoagpcardoso
125
125
ViewComponentis not a new feature in ASP.NET Core. Since you're new to it, I suggest you to take a tour here: View components in ASP.NET Core. However, there are a lot of ways to achieve this goal, not justViewComponent
– Foo
Nov 24 '18 at 4:37
Yeah, I agree, but, what do you think in I use ViewComponent to achieve this goal?
– agpcardoso
Nov 24 '18 at 4:43
I have no idea since you are learning how to useViewComponent. Just learn it and you will know how it's good, when to avoid.
– Foo
Nov 24 '18 at 4:47
add a comment |
ViewComponentis not a new feature in ASP.NET Core. Since you're new to it, I suggest you to take a tour here: View components in ASP.NET Core. However, there are a lot of ways to achieve this goal, not justViewComponent
– Foo
Nov 24 '18 at 4:37
Yeah, I agree, but, what do you think in I use ViewComponent to achieve this goal?
– agpcardoso
Nov 24 '18 at 4:43
I have no idea since you are learning how to useViewComponent. Just learn it and you will know how it's good, when to avoid.
– Foo
Nov 24 '18 at 4:47
ViewComponent is not a new feature in ASP.NET Core. Since you're new to it, I suggest you to take a tour here: View components in ASP.NET Core. However, there are a lot of ways to achieve this goal, not just ViewComponent– Foo
Nov 24 '18 at 4:37
ViewComponent is not a new feature in ASP.NET Core. Since you're new to it, I suggest you to take a tour here: View components in ASP.NET Core. However, there are a lot of ways to achieve this goal, not just ViewComponent– Foo
Nov 24 '18 at 4:37
Yeah, I agree, but, what do you think in I use ViewComponent to achieve this goal?
– agpcardoso
Nov 24 '18 at 4:43
Yeah, I agree, but, what do you think in I use ViewComponent to achieve this goal?
– agpcardoso
Nov 24 '18 at 4:43
I have no idea since you are learning how to use
ViewComponent. Just learn it and you will know how it's good, when to avoid.– Foo
Nov 24 '18 at 4:47
I have no idea since you are learning how to use
ViewComponent. Just learn it and you will know how it's good, when to avoid.– Foo
Nov 24 '18 at 4:47
add a comment |
1 Answer
1
active
oldest
votes
There is not that true answer to this. My rule of thumb: If your views that use this search filter box share the same view model and it is not likely that the search box will be used later for very different views: start with a partial view. If the search box will be used on very different views with different view models: Implement a view component.
View components are more independent from partial views since they have its own code in its corresponding class, so they can construct their own view models for example. Thus your search box will only be loosely coupled to your views and you won't have to alter so much outside your component if you want to adjust something later on.
If you just want to save a piece of otherwise repeating cshtml code, a partial view will definitely suffice.
1
I appreciate your answer. it was very helpful for me
– agpcardoso
Nov 25 '18 at 1:39
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455120%2fshould-i-create-my-search-filters-box-like-as-a-viewcomponent%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There is not that true answer to this. My rule of thumb: If your views that use this search filter box share the same view model and it is not likely that the search box will be used later for very different views: start with a partial view. If the search box will be used on very different views with different view models: Implement a view component.
View components are more independent from partial views since they have its own code in its corresponding class, so they can construct their own view models for example. Thus your search box will only be loosely coupled to your views and you won't have to alter so much outside your component if you want to adjust something later on.
If you just want to save a piece of otherwise repeating cshtml code, a partial view will definitely suffice.
1
I appreciate your answer. it was very helpful for me
– agpcardoso
Nov 25 '18 at 1:39
add a comment |
There is not that true answer to this. My rule of thumb: If your views that use this search filter box share the same view model and it is not likely that the search box will be used later for very different views: start with a partial view. If the search box will be used on very different views with different view models: Implement a view component.
View components are more independent from partial views since they have its own code in its corresponding class, so they can construct their own view models for example. Thus your search box will only be loosely coupled to your views and you won't have to alter so much outside your component if you want to adjust something later on.
If you just want to save a piece of otherwise repeating cshtml code, a partial view will definitely suffice.
1
I appreciate your answer. it was very helpful for me
– agpcardoso
Nov 25 '18 at 1:39
add a comment |
There is not that true answer to this. My rule of thumb: If your views that use this search filter box share the same view model and it is not likely that the search box will be used later for very different views: start with a partial view. If the search box will be used on very different views with different view models: Implement a view component.
View components are more independent from partial views since they have its own code in its corresponding class, so they can construct their own view models for example. Thus your search box will only be loosely coupled to your views and you won't have to alter so much outside your component if you want to adjust something later on.
If you just want to save a piece of otherwise repeating cshtml code, a partial view will definitely suffice.
There is not that true answer to this. My rule of thumb: If your views that use this search filter box share the same view model and it is not likely that the search box will be used later for very different views: start with a partial view. If the search box will be used on very different views with different view models: Implement a view component.
View components are more independent from partial views since they have its own code in its corresponding class, so they can construct their own view models for example. Thus your search box will only be loosely coupled to your views and you won't have to alter so much outside your component if you want to adjust something later on.
If you just want to save a piece of otherwise repeating cshtml code, a partial view will definitely suffice.
answered Nov 24 '18 at 12:32
GrimmGrimm
18110
18110
1
I appreciate your answer. it was very helpful for me
– agpcardoso
Nov 25 '18 at 1:39
add a comment |
1
I appreciate your answer. it was very helpful for me
– agpcardoso
Nov 25 '18 at 1:39
1
1
I appreciate your answer. it was very helpful for me
– agpcardoso
Nov 25 '18 at 1:39
I appreciate your answer. it was very helpful for me
– agpcardoso
Nov 25 '18 at 1:39
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455120%2fshould-i-create-my-search-filters-box-like-as-a-viewcomponent%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
ViewComponentis not a new feature in ASP.NET Core. Since you're new to it, I suggest you to take a tour here: View components in ASP.NET Core. However, there are a lot of ways to achieve this goal, not justViewComponent– Foo
Nov 24 '18 at 4:37
Yeah, I agree, but, what do you think in I use ViewComponent to achieve this goal?
– agpcardoso
Nov 24 '18 at 4:43
I have no idea since you are learning how to use
ViewComponent. Just learn it and you will know how it's good, when to avoid.– Foo
Nov 24 '18 at 4:47