Click here to Skip to main content
15,891,688 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am writing you because I a bit lost.

I would like to create a page where there are 3 images, and each images are clickable.
When I click on one of the image, on the same page it should appear a partial view.

If I click another image, the all other partial view should disappear, and show only the partial view desired.

I have learned that in order to call a partial view the command line should be:
<pre>
@{
   Html.RenderPartial("_Android");
}



Do I need to do a script in JS or I can make a peace of code in c#?
What should I think at first?


Thanks in advance

What I have tried:

<pre><div class="container-fluid">
    <h2>MDMSection</h2>
    <p>The .thumbnail class can be used to display an image gallery.</p>
    <p>The .caption class adds proper padding and a dark grey color to text inside thumbnails.</p>
    <p>Click on the images to see all Q&A</p>
    <div class="row">
        <div class="col-md-4">
            <img alt="Bootstrap Image Preview" src="http://lorempixel.com/140/140/" class="img-rounded" />
            <div class="caption">
                <p>Android</p>
            </div>
        </div>
        <div class="col-md-4">
            <img alt="Bootstrap Image Preview" src="http://lorempixel.com/140/140/" class="img-rounded" />
            <div class="caption">
                <p>iOS</p>
            </div>
        </div>
        <div class="col-md-4">
            <img alt="Bootstrap Image Preview" src="http://lorempixel.com/140/140/" class="img-rounded" />
            <div class="caption">
                <p>Windows Phone</p>
            </div>
        </div>
    </div>
</div>
<div>
    <br/>
</div>
<div>
<p>
here it should appear my partial view.
</p>
@{
   Html.RenderPartial("_Android");
}
@{
   Html.RenderPartial("iOS");
}
@{
   Html.RenderPartial("_WindowsPhone");
}
</div>
Posted
Updated 8-Jan-18 3:01am

1 solution

Load ASP.NET MVC partial views on link click | dotnetthoughts[^]

The above solution doesn't match with your requirement completely but, you can come to know how to implement at least.
 
Share this answer
 
Comments
Francesco Bigi 9-Jan-18 4:56am    
Actually I tried to execute what your link say, but the image are no clickable.

    <div class="row">
        <div class="col-md-4">
            <img id="Button1" alt="Bootstrap Image Preview" src="http://lorempixel.com/140/140/" class="img-rounded" />
            <div class="caption">
                <div id="Button1">test</div>
                <p>Android</p>
            </div>
        </div>
        <div class="col-md-4">
            <img id="image2" alt="Bootstrap Image Preview" src="http://lorempixel.com/140/140/" class="img-rounded" />
            <div class="caption">
                <p>iOS</p>
            </div>
        </div>
        <div class="col-md-4">
            <img id="image3" alt="Bootstrap Image Preview" src="http://lorempixel.com/140/140/" class="img-rounded" />
            <div class="caption">
                <p>Windows Phone</p>
            </div>
        </div>
    </div>


<div id="output">
    
</div>


<script type="text/javascript">
    jQuery(function ($) {
        $('#Button1').click(function () {
            $.get('@Url.Action("_AndroidView","PartialView")', {}, function (response) {
                $("#output").html(response);
        });
    });
</script>



in this case my Button1 is doing nothing.
[no name] 9-Jan-18 5:02am    
Your image should have an anchor tag like
<a href=""><img id="image3" alt="Bootstrap Image Preview" src="http://lorempixel.com/140/140/" class="img-rounded" /></a>


If you are using Asp.Net then also try ASP Image button
Francesco Bigi 9-Jan-18 5:39am    
Actually I have tried even with ´´

but what it does is just refreshin the page and nothing else.
WHat I want to do is to click the image and it shows me a partialview, under my image.
[no name] 9-Jan-18 6:19am    
Debug the javascript and C# code then check if something is failing. Also try to replace image button with a link and test

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900