How to loop data on html using mvc?What are valid values for the id attribute in HTML?How do I enumerate an enum in C#?How to horizontally center a <div>?How to change an element's class with JavaScript?How to check whether a checkbox is checked in jQuery?HTML 5: Is it <br>, <br/>, or <br />?How to create an HTML button that acts like a link?How to disable resizable property of textarea?Why does HTML think “chucknorris” is a color?Cannot display HTML string
Why is an old chain unsafe?
Copenhagen passport control - US citizen
How can bays and straits be determined in a procedurally generated map?
What are these boxed doors outside store fronts in New York?
Are tax years 2016 & 2017 back taxes deductible for tax year 2018?
Today is the Center
How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?
Why is the design of haulage companies so “special”?
What defenses are there against being summoned by the Gate spell?
Should I join office cleaning event for free?
Japan - Plan around max visa duration
Suffixes -unt and -ut-
Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)
Draw simple lines in Inkscape
If I cast Expeditious Retreat, can I Dash as a bonus action on the same turn?
declaring a variable twice in IIFE
"which" command doesn't work / path of Safari?
How is it possible for user to changed after storage was encrypted? (on OS X, Android)
What typically incentivizes a professor to change jobs to a lower ranking university?
How to get the available space of $HOME as a variable in shell scripting?
How can I automatically replace [[ and ]] with the [LeftDoubleBracket] and [RightDoubleBracket] operators?
How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?
Can I make popcorn with any corn?
Do airline pilots ever risk not hearing communication directed to them specifically, from traffic controllers?
How to loop data on html using mvc?
What are valid values for the id attribute in HTML?How do I enumerate an enum in C#?How to horizontally center a <div>?How to change an element's class with JavaScript?How to check whether a checkbox is checked in jQuery?HTML 5: Is it <br>, <br/>, or <br />?How to create an HTML button that acts like a link?How to disable resizable property of textarea?Why does HTML think “chucknorris” is a color?Cannot display HTML string
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
my user interface
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home") ">
<img src="@Url.Content("~/Content/mytemplate/")img/pic1.jpg" alt="pic1" width="600" height="400">
</a>
<div class="desc">Category Menu 1</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic2.jpg" alt="pic2" width="600" height="400">
</a>
<div class="desc">Category Menu 2</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic3.jpg" alt="pic3" width="600" height="400">
</a>
<div class="desc">Category Menu 3</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic4.jpg" alt="pic4" width="600" height="400">
</a>
<div class="desc">Category Menu 4</div>
</div>
</div>
i want to know how can i auto generate the pic 1 by 1..not add on code but by database.I mean example like admin want add some menu into his website so he use his dashboard to add the menu so how i can make when the admin add it,the user interface auto create the layout or pic list..just like loop php right?How can i do with mvc platform?
c# html asp.net-mvc bootstrap-4
add a comment |
my user interface
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home") ">
<img src="@Url.Content("~/Content/mytemplate/")img/pic1.jpg" alt="pic1" width="600" height="400">
</a>
<div class="desc">Category Menu 1</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic2.jpg" alt="pic2" width="600" height="400">
</a>
<div class="desc">Category Menu 2</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic3.jpg" alt="pic3" width="600" height="400">
</a>
<div class="desc">Category Menu 3</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic4.jpg" alt="pic4" width="600" height="400">
</a>
<div class="desc">Category Menu 4</div>
</div>
</div>
i want to know how can i auto generate the pic 1 by 1..not add on code but by database.I mean example like admin want add some menu into his website so he use his dashboard to add the menu so how i can make when the admin add it,the user interface auto create the layout or pic list..just like loop php right?How can i do with mvc platform?
c# html asp.net-mvc bootstrap-4
Please edit your question and add more details that show where this data comes from and whether your view is strongly typed or any else?
– er-sho
Mar 9 at 5:52
add a comment |
my user interface
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home") ">
<img src="@Url.Content("~/Content/mytemplate/")img/pic1.jpg" alt="pic1" width="600" height="400">
</a>
<div class="desc">Category Menu 1</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic2.jpg" alt="pic2" width="600" height="400">
</a>
<div class="desc">Category Menu 2</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic3.jpg" alt="pic3" width="600" height="400">
</a>
<div class="desc">Category Menu 3</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic4.jpg" alt="pic4" width="600" height="400">
</a>
<div class="desc">Category Menu 4</div>
</div>
</div>
i want to know how can i auto generate the pic 1 by 1..not add on code but by database.I mean example like admin want add some menu into his website so he use his dashboard to add the menu so how i can make when the admin add it,the user interface auto create the layout or pic list..just like loop php right?How can i do with mvc platform?
c# html asp.net-mvc bootstrap-4
my user interface
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home") ">
<img src="@Url.Content("~/Content/mytemplate/")img/pic1.jpg" alt="pic1" width="600" height="400">
</a>
<div class="desc">Category Menu 1</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic2.jpg" alt="pic2" width="600" height="400">
</a>
<div class="desc">Category Menu 2</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic3.jpg" alt="pic3" width="600" height="400">
</a>
<div class="desc">Category Menu 3</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic4.jpg" alt="pic4" width="600" height="400">
</a>
<div class="desc">Category Menu 4</div>
</div>
</div>
i want to know how can i auto generate the pic 1 by 1..not add on code but by database.I mean example like admin want add some menu into his website so he use his dashboard to add the menu so how i can make when the admin add it,the user interface auto create the layout or pic list..just like loop php right?How can i do with mvc platform?
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home") ">
<img src="@Url.Content("~/Content/mytemplate/")img/pic1.jpg" alt="pic1" width="600" height="400">
</a>
<div class="desc">Category Menu 1</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic2.jpg" alt="pic2" width="600" height="400">
</a>
<div class="desc">Category Menu 2</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic3.jpg" alt="pic3" width="600" height="400">
</a>
<div class="desc">Category Menu 3</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic4.jpg" alt="pic4" width="600" height="400">
</a>
<div class="desc">Category Menu 4</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home") ">
<img src="@Url.Content("~/Content/mytemplate/")img/pic1.jpg" alt="pic1" width="600" height="400">
</a>
<div class="desc">Category Menu 1</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic2.jpg" alt="pic2" width="600" height="400">
</a>
<div class="desc">Category Menu 2</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic3.jpg" alt="pic3" width="600" height="400">
</a>
<div class="desc">Category Menu 3</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home")">
<img src="@Url.Content("~/Content/mytemplate/")img/pic4.jpg" alt="pic4" width="600" height="400">
</a>
<div class="desc">Category Menu 4</div>
</div>
</div>
c# html asp.net-mvc bootstrap-4
c# html asp.net-mvc bootstrap-4
edited Mar 9 at 6:40
Muhammad Syafiq
asked Mar 9 at 3:41
Muhammad SyafiqMuhammad Syafiq
34
34
Please edit your question and add more details that show where this data comes from and whether your view is strongly typed or any else?
– er-sho
Mar 9 at 5:52
add a comment |
Please edit your question and add more details that show where this data comes from and whether your view is strongly typed or any else?
– er-sho
Mar 9 at 5:52
Please edit your question and add more details that show where this data comes from and whether your view is strongly typed or any else?
– er-sho
Mar 9 at 5:52
Please edit your question and add more details that show where this data comes from and whether your view is strongly typed or any else?
– er-sho
Mar 9 at 5:52
add a comment |
3 Answers
3
active
oldest
votes
You need to pass your model to the view and then you can iterate... assuming your model is called PictureModel
, you can pass a list of PictureModel
and iterate like below:
@model List<PictureModel>
@for(int i = 0; i < @Model.Count; i++)
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home") ">
<img src="@Url.Content("~/Content/mytemplate/")img/@Model[i].PictureName.jpg" alt="@Model[i].PictureName" width="600" height="400">
</a>
<div class="desc">@Model[i].CategoryMenuName</div>
</div>
</div>
can u more specific?on html just stay like that?
– Muhammad Syafiq
Mar 9 at 6:41
Yes, that's Razor though (not HTML)... it would be rendered to HTML. You need to pass your Model to View...
– Hooman Bahreini
Mar 9 at 6:45
add a comment |
you can pass your model or list to your razor view and then perform an action as needed
for example
for loop
@for(var i = 0; i < 10; i++)
<p> @i </p>
or foreach
@foreach (var x in model.list)
<p> @x </p>
add a comment |
Create model and pass.
@model List<WebMVC.Models.Images>
@foreach (var item in Model)
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("submenu","Home")">
<img src=@item.path alt="pic" + @item.Sqno width="600" height="400" />
</a>
<div class="desc">Cagtegory Menu @item.Sqno</div>
</div>
</div>
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%2f55073766%2fhow-to-loop-data-on-html-using-mvc%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to pass your model to the view and then you can iterate... assuming your model is called PictureModel
, you can pass a list of PictureModel
and iterate like below:
@model List<PictureModel>
@for(int i = 0; i < @Model.Count; i++)
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home") ">
<img src="@Url.Content("~/Content/mytemplate/")img/@Model[i].PictureName.jpg" alt="@Model[i].PictureName" width="600" height="400">
</a>
<div class="desc">@Model[i].CategoryMenuName</div>
</div>
</div>
can u more specific?on html just stay like that?
– Muhammad Syafiq
Mar 9 at 6:41
Yes, that's Razor though (not HTML)... it would be rendered to HTML. You need to pass your Model to View...
– Hooman Bahreini
Mar 9 at 6:45
add a comment |
You need to pass your model to the view and then you can iterate... assuming your model is called PictureModel
, you can pass a list of PictureModel
and iterate like below:
@model List<PictureModel>
@for(int i = 0; i < @Model.Count; i++)
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home") ">
<img src="@Url.Content("~/Content/mytemplate/")img/@Model[i].PictureName.jpg" alt="@Model[i].PictureName" width="600" height="400">
</a>
<div class="desc">@Model[i].CategoryMenuName</div>
</div>
</div>
can u more specific?on html just stay like that?
– Muhammad Syafiq
Mar 9 at 6:41
Yes, that's Razor though (not HTML)... it would be rendered to HTML. You need to pass your Model to View...
– Hooman Bahreini
Mar 9 at 6:45
add a comment |
You need to pass your model to the view and then you can iterate... assuming your model is called PictureModel
, you can pass a list of PictureModel
and iterate like below:
@model List<PictureModel>
@for(int i = 0; i < @Model.Count; i++)
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home") ">
<img src="@Url.Content("~/Content/mytemplate/")img/@Model[i].PictureName.jpg" alt="@Model[i].PictureName" width="600" height="400">
</a>
<div class="desc">@Model[i].CategoryMenuName</div>
</div>
</div>
You need to pass your model to the view and then you can iterate... assuming your model is called PictureModel
, you can pass a list of PictureModel
and iterate like below:
@model List<PictureModel>
@for(int i = 0; i < @Model.Count; i++)
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("Submenu", "Home") ">
<img src="@Url.Content("~/Content/mytemplate/")img/@Model[i].PictureName.jpg" alt="@Model[i].PictureName" width="600" height="400">
</a>
<div class="desc">@Model[i].CategoryMenuName</div>
</div>
</div>
answered Mar 9 at 4:11
Hooman BahreiniHooman Bahreini
4,19231034
4,19231034
can u more specific?on html just stay like that?
– Muhammad Syafiq
Mar 9 at 6:41
Yes, that's Razor though (not HTML)... it would be rendered to HTML. You need to pass your Model to View...
– Hooman Bahreini
Mar 9 at 6:45
add a comment |
can u more specific?on html just stay like that?
– Muhammad Syafiq
Mar 9 at 6:41
Yes, that's Razor though (not HTML)... it would be rendered to HTML. You need to pass your Model to View...
– Hooman Bahreini
Mar 9 at 6:45
can u more specific?on html just stay like that?
– Muhammad Syafiq
Mar 9 at 6:41
can u more specific?on html just stay like that?
– Muhammad Syafiq
Mar 9 at 6:41
Yes, that's Razor though (not HTML)... it would be rendered to HTML. You need to pass your Model to View...
– Hooman Bahreini
Mar 9 at 6:45
Yes, that's Razor though (not HTML)... it would be rendered to HTML. You need to pass your Model to View...
– Hooman Bahreini
Mar 9 at 6:45
add a comment |
you can pass your model or list to your razor view and then perform an action as needed
for example
for loop
@for(var i = 0; i < 10; i++)
<p> @i </p>
or foreach
@foreach (var x in model.list)
<p> @x </p>
add a comment |
you can pass your model or list to your razor view and then perform an action as needed
for example
for loop
@for(var i = 0; i < 10; i++)
<p> @i </p>
or foreach
@foreach (var x in model.list)
<p> @x </p>
add a comment |
you can pass your model or list to your razor view and then perform an action as needed
for example
for loop
@for(var i = 0; i < 10; i++)
<p> @i </p>
or foreach
@foreach (var x in model.list)
<p> @x </p>
you can pass your model or list to your razor view and then perform an action as needed
for example
for loop
@for(var i = 0; i < 10; i++)
<p> @i </p>
or foreach
@foreach (var x in model.list)
<p> @x </p>
answered Mar 9 at 5:25
ArunPratapArunPratap
1,50431128
1,50431128
add a comment |
add a comment |
Create model and pass.
@model List<WebMVC.Models.Images>
@foreach (var item in Model)
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("submenu","Home")">
<img src=@item.path alt="pic" + @item.Sqno width="600" height="400" />
</a>
<div class="desc">Cagtegory Menu @item.Sqno</div>
</div>
</div>
add a comment |
Create model and pass.
@model List<WebMVC.Models.Images>
@foreach (var item in Model)
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("submenu","Home")">
<img src=@item.path alt="pic" + @item.Sqno width="600" height="400" />
</a>
<div class="desc">Cagtegory Menu @item.Sqno</div>
</div>
</div>
add a comment |
Create model and pass.
@model List<WebMVC.Models.Images>
@foreach (var item in Model)
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("submenu","Home")">
<img src=@item.path alt="pic" + @item.Sqno width="600" height="400" />
</a>
<div class="desc">Cagtegory Menu @item.Sqno</div>
</div>
</div>
Create model and pass.
@model List<WebMVC.Models.Images>
@foreach (var item in Model)
<div class="responsive">
<div class="gallery">
<a href="@Url.Action("submenu","Home")">
<img src=@item.path alt="pic" + @item.Sqno width="600" height="400" />
</a>
<div class="desc">Cagtegory Menu @item.Sqno</div>
</div>
</div>
edited Mar 9 at 6:45
Hooman Bahreini
4,19231034
4,19231034
answered Mar 9 at 5:52
Ghanshyam KumarGhanshyam Kumar
214
214
add a comment |
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%2f55073766%2fhow-to-loop-data-on-html-using-mvc%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
Please edit your question and add more details that show where this data comes from and whether your view is strongly typed or any else?
– er-sho
Mar 9 at 5:52