I feel like this is a very simple solution that I am overlooking somehow. Basically I have a web page (using asp.net webforms) with a datalist. Inside my datalist, and inside the datalist items I have a div that I want the user to be able to click to cause a page redirect. I would like to do this without use of an anchor or javascript if possible. My datalist:
<asp:DataList ID="DataList1" ..etc >
<HeaderTemplate>
..etc
</HeaderTemplate>
<ItemTemplate>
<table >
<tr >
<td>..etc</td>
<td>..etc</td>
<td ><div id="clr_div" runat = "server"></div></td> <-- this is the div to be clicked
</tr>
</table>
</ItemTemplate>
And then in my code behind
protected void on_item_databound(object sender, DataListItemEventArgs e)
{
System.Web.UI.HtmlControls.HtmlGenericControl div = (System.Web.UI.HtmlControls.HtmlGenericControl)e.Item.FindControl("clr_div");
div.Attributes.Add("onclick", "**What goes here??**");
}
I have tried to put in the 'what goes here' section:
window.location.href = \"default.aspx\" **doesn`t work, the quotes don`t render properly in html
window.location.href = default.aspx **doesn`t work
return Response.Redirect(default.aspx); **doesn`t work
Any help is welcome. Thanks