Search code examples
c#imagebrowserfullscreen

Show image in browser in full screen in C# ASP.NET


i want to show an image in the browser page and to stretch it so it would fill the whole browser page.

i tried:

<asp:Image ID="myimage" runat="server" ImageUrl="/Images/mypic.jpg" Width="100%" Height="100%"></asp:Image>

and also tried using css:

<asp:Image ID="myimage" runat="server" ImageUrl="/Images/mypic.jpg"  CssClass="myimage1"></asp:Image>

and in the CSS:

.myimage1{height:100%;width:100%;}

in both cases the browser (IE9), stretches the image with a height that is much bigger then the broswer hight and a right scroll bar is shown.

How can i stretch an image to the exact size of the current page size?


Solution

  • i found the solution using an img html tag and using CSS: http://bytes.com/topic/asp-net/answers/850635-how-stretch-background-image-fill

    add this inside the aspx page inside the body tag:

    <img src="Styles/mypic.jpg" alt="" />
    

    in the css:

    html,body 
    {
        margin: 0; 
        padding: 0;
    }
    
    img
    {
        position:absolute; 
        z-index:-1; 
        width:100%; 
        height:100%;
    }