Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
get only texts and no Image "System.Web.UI.WebControls.Image"

What I have tried:

C#
<div class="kuven">
<a href="~/ShoppingCart" id="cartCount" class="nav-link style="></a><asp:image id="Kuve" runat="server" width="40" height="40" alt=""></div>

C#
protected void Page_PreRender(object sender, EventArgs e)
        {
            using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
            {
                Image Kuve = new Image();
                Kuve.ImageUrl = "..WebBilleder/indkobskuve.png";
                string cartStr = string.Format(Kuve + "({0})", 
                usersShoppingCart.GetCount());
                cartCount.InnerText = cartStr;
            }
        }
Posted
Updated 29-Apr-20 1:28am
v3
Comments
Sinisa Hajnal 29-Apr-20 3:55am    
If the image is always the same, don't do server side. If it is not, check the path (you may lack slash(/) after double dot).

C#
using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
{
    // delete this
    // Image Kuve = new Image();

    // change the path string to match your folder structure where ~ is the root of your site
    Kuve.ImageUrl = VirtualPathUtility.ToAbsolute("~/WebBilleder/indkobskuve.png");

    // just set the InnerText direct
    cartCount.InnerText = usersShoppingCart.GetCount().ToString();
}
 
Share this answer
 
Thank for yours reply Sinisa
It is always the sam but what I want is image to be connected with the nr. there's in the shoppingcart
 
Share this answer
 
Comments
Richard Deeming 29-Apr-20 10:16am    
If you want to reply to a comment, click the "Reply" button next to the comment.

Do not post your reply as a "solution" to your question.

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