Should I create my search filters box like as a ViewComponent?












0















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?



Search Filtered Box










share|improve this question

























  • 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











  • 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
















0















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?



Search Filtered Box










share|improve this question

























  • 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











  • 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














0












0








0








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?



Search Filtered Box










share|improve this question
















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?



Search Filtered Box







asp.net-core asp.net-core-viewcomponent






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 4:38









Foo

1




1










asked Nov 24 '18 at 4:24









agpcardosoagpcardoso

125




125













  • 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











  • 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



















  • 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











  • 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

















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












1 Answer
1






active

oldest

votes


















0














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.






share|improve this answer



















  • 1





    I appreciate your answer. it was very helpful for me

    – agpcardoso
    Nov 25 '18 at 1:39











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
});


}
});














draft saved

draft discarded


















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









0














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.






share|improve this answer



















  • 1





    I appreciate your answer. it was very helpful for me

    – agpcardoso
    Nov 25 '18 at 1:39
















0














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.






share|improve this answer



















  • 1





    I appreciate your answer. it was very helpful for me

    – agpcardoso
    Nov 25 '18 at 1:39














0












0








0







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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














  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Sphinx de Gizeh

Dijon

Guerrita