Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4110634
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:57:34+00:00 2026-05-20T21:57:34+00:00

Is there a way I can put a link inside a div using c#/css

  • 0

Is there a way I can put a link inside a div using c#/css and then create a function in c# asp.net to delete that div?

Im looking to add Delete to the top right hand corner of my div which is like a link then in my code behind call a function which will delete that entry from my database.

My css:

div .test
{
  width:90%; 
  z-index:1; 
  padding:27.5px; 
  border-top: thin solid #736F6E;
  border-bottom: thin solid #736F6E;
  color:#ffffff;
  margin:0 auto;
  white-space: pre;
  white-space: pre-wrap;
  white-space: pre-line;
  word-wrap: break-word;
}

EDIT:
Nothing is being rendered so far on the page:

System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                    div.Attributes["class"] = "test";
                    div.ID = "test";


                    // Deletebutton div with link
                    System.Web.UI.HtmlControls.HtmlGenericControl divClose = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                    divClose.Attributes["class"] = "deleteButton";
                    divClose.ID = "deleteButton";
                    div.Controls.Add(divClose);
                    System.Web.UI.HtmlControls.HtmlGenericControl link = new System.Web.UI.HtmlControls.HtmlGenericControl("a");
                    link.ID = "link";
                    divClose.Controls.Add(link);

                    Image img = new Image();
                    img.ImageUrl = String.Format("{0}", reader.GetString(1));
                    img.AlternateText = "Test image";

                    div.Controls.Add(img);
                    div.Controls.Add(ParseControl(String.Format("{0}", reader.GetString(0))));
                    div.Style["clear"] = "both";

                    test1.Controls.Add(div);

css:

div#test1 {
}
div .test {
  width:90%; 
  z-index:1; 
  padding:27.5px; 
  border-top: thin solid #736F6E;
  border-bottom: thin solid #736F6E;
  color:#ffffff;
  margin:0 auto;
  white-space: pre;
  white-space: pre-wrap;
  white-space: pre-line;
  word-wrap: break-word;
}
.deleteButton {
  width: 200px;
  height: 15px;
  border: 1px solid blue;
}

.deleteButton a{
  display:none;
}

.deleteButton:hover a{
  display:block;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:57:35+00:00Added an answer on May 20, 2026 at 9:57 pm

    In your HTML create the link. We will hide it using css, and display it when we hover the div.

    <div class="deleteButton">
      <asp:LinkButton runat="server" id="delButton" Text="Delete"/>
    </div>
    

    If you create the div in Code:

    System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
    div.Attributes["class"] = "test";
    div.ID = "test";
    
    
    // Deletebutton div with link
    System.Web.UI.HtmlControls.HtmlGenericControl divClose = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
    divClose.Attributes["class"] = "closeButton";
    divClose.ID = "closeButton";
    div.Controls.Add(divClose);
    System.Web.UI.HtmlControls.HtmlGenericControl link= new System.Web.UI.HtmlControls.HtmlGenericControl("a");
    link.ID = "link";
    divClose.Controls.Add(link);
    
    img = new Image();
    ImageUrl = String.Format("{0}", reader.GetString(1));
    img.AlternateText = "Test image";
    
    div.Controls.Add(img);
    div.Controls.Add(ParseControl(String.Format("{0}", reader.GetString(0))));
    div.Style["clear"] = "both";
    
    test1.Controls.Add(div);
    
    

    This is the CSS used to hide/display the link.

    <!-- CSS -->
    .deleteButton {
      width: 200px;
      height: 15px;
      border: 1px solid blue;
    }
    
    .deleteButton a{
      display:none;
    }
    
    .deleteButton:hover a{
      display:block;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there way that I can read the file from remote server using fopen
Is there any way we can fetch X509 Public Cetrificates using c# from AD
Is there any way can declare a bean in just like JSP UseBean in
Is there any way I can set a formatter on models that will convert
Is there a way I can use one category to stylize all of my
Is there a way I can detect an image URL, like: http://mysite.com/image.jpg but with
Is there a way I can change the icon of the expander to +/-
Is there a way I can add support for syncing my program's settings with
Is there any way I can use JPA or hibernate annotations to specify the
Is there a way i can write the following piece of code to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.