While working on various aspects of designing of the website, we may have to deal with a scenario where we have to make part of page , DIV tag, entirely clickable. Lets see how we can work on this.
The best way is to enclose entire div tag in an anchor tag as follows. This way we can mention the link, if any, where page should redirect after clicking div tag.
We can have any content in div tag like image, a long description, etc.
Sometimes, instead of redirect we may have to write some code. So replace anchor tag with LinkButton control as follows
Code Snippet for OnClick event is as follows -
So working on existing controls as you require, is the best way to achieve what you need.
- Happy Coding -
The best way is to enclose entire div tag in an anchor tag as follows. This way we can mention the link, if any, where page should redirect after clicking div tag.
<a runat="server" href="http://www.kpbdotnet.blogspot.com/">
<div class="jumbotron">
this is my DIV tag and we are making this complete div tag clickable
<p>
We are contents of div tag
</p>
</div>
</a>We can have any content in div tag like image, a long description, etc.
Sometimes, instead of redirect we may have to write some code. So replace anchor tag with LinkButton control as follows
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">
<div class="jumbotron">
test div tag
<asp:Label ID="lbl" runat="server" Text="click"></asp:Label>
</div>
</asp:LinkButton>Code Snippet for OnClick event is as follows -
protected void LinkButton1_Click(object sender, EventArgs e)
{
lbl.Text = "You click div tag.";
}So working on existing controls as you require, is the best way to achieve what you need.
- Happy Coding -
No comments:
Post a Comment