*Newbie Alert*
I am trying to create dynamic image buttons that when clicked will redirect to anothr page as well as add a new item to a SharePoint list. My Image buttons create sucessfully but the click event is not loaded. I have added a break point visual studio and can see that the function is never loaded.
My Image button creation code (within Page_load) is:
ImageButton lnk = new ImageButton();
lnk.ID = WPtitle;
lnk.CommandName = WPtitle;
lnk.CommandArgument = WPtitle;
lnk.PostBackUrl = WPUrl;
lnk.Visible = true;
lnk.ImageUrl = WPImgUrl;
tc.Controls.Add(lnk);
lnk.Click += new System.Web.UI.ImageClickEventHandler(this.send_Click);and then my event is:
public void send_Click(object sender, ImageClickEventArgs e)
{
SPWeb site = SPContext.Current.Web;
var clicklist = site.Lists["listname"];
string WPTitle = ((ImageButton)sender).CommandArgument.ToString();
SPListItem additem = clicklist.AddItem();
additem["Title"] = "text";
additem["Clicked"] = "1";
additem.Update();Any help as to why this is not loading would be greatly appreciated.
Thanks