Within a loop, I have created a div that is populated with labels/data from my database:
HtmlGenericControl availableTime =
new HtmlGenericControl("div");
availableTime.Attributes["id"] = "availableTime" + idCount.ToString();
availableTime.Attributes["runat"] = "server";
availableTime.Attributes["class"] = "availableTimeDiv";
availableTime.Attributes.Add("onclick", "divClick()");
Below is the function I am attempting to call:
protected void divClick(object sender, EventArgs e)
{
Response.Redirect("CreateMeeting.aspx");
}
Despite my efforts, the function remains uncalled and the div is not clickable.
Furthermore, I require the id of the div and other elements within it. Is calling a method in the code behind the most effective way to achieve this?