本文介绍了我怎样才能click事件从code后面添加到我的div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何click事件从code添加到我的div后面?
How can I add a click event to my div from code behind?
进出口寻找后,点击div来一个消息框,您想在框中删除这一点,是或否打招呼?
Im looking upon clicking on the div to be greeted by a message box with would you like to delete this and a yes or no within the box?
所有来自code背后:
All from the code behind:
while (reader.Read())
{
System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
div.Attributes["class"] = "test";
//div.Style["float"] = "left";
div.ID = "test";
Image img = new Image();
img.ImageUrl = String.Format("{0}", reader.GetString(1));
// this line needs to be represented in sql syntax
//img.ImageUrl = "~/userdata/2/uploadedimage/batman-for-facebook.jpg";
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);
}
您可以点击事件,如果这样加重了怎么了?
can you add a click event to it if so how?
推荐答案
这个链接应该总结一下:
This link should sum it up:http://davidhayden.com/blog/dave/archive/2004/03/16/178.aspx
c#
_myButton.Attributes.Add("onclick", "return confirm_delete();");
javascript:
function confirm_delete()
{
if (confirm("Are you sure you want to delete the custom search?")==true)
return true;
else
return false;
}
这篇关于我怎样才能click事件从code后面添加到我的div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!