如何在 ASP.net 中添加按钮并关联点击
我正在开发一个 ASP.NET 站点,在该站点中我向最终用户显示内部搜索引擎返回的结果。我正在解析结果,创建 HTML 字符串以显示这些结果,如下所示,
foreach (XmlNode result in results)
{
srHtml = "<li class=\"\" style=\"\">";
srHtml += "<a href=\"" + result.SelectSingleNode("./web:Url", nsmgr).InnerText + "\"> <span class=\"title\">" + result.SelectSingleNode("./web:Title", nsmgr).InnerText + "</span></a> <button>Short This URL</button>\n";
if (result.SelectSingleNode("./web:Description", nsmgr) != null)
srHtml += "<br />" + result.SelectSingleNode("./web:Description", nsmgr).InnerText + "<br />";
srHtml += "<span class=\"url\">" + result.SelectSingleNode("./web:Url", nsmgr).InnerText + "</span></li>\n";
phResults.Controls.Add(new System.Web.UI.LiteralControl(srHtml));
}
我可以在结果页面上看到该按钮。但我不知道在哪里可以放置用户单击此按钮时运行的代码。当用户单击该按钮时,我想使用缩短的 url 更改该按钮文本字段。
有人可以帮我吗?
问候, 苏米特隆卡
I am working on a ASP.NET site, in which i display results returned by internal search engine to the end user. I am parsing the result creating HTML string to display those results as following
foreach (XmlNode result in results)
{
srHtml = "<li class=\"\" style=\"\">";
srHtml += "<a href=\"" + result.SelectSingleNode("./web:Url", nsmgr).InnerText + "\"> <span class=\"title\">" + result.SelectSingleNode("./web:Title", nsmgr).InnerText + "</span></a> <button>Short This URL</button>\n";
if (result.SelectSingleNode("./web:Description", nsmgr) != null)
srHtml += "<br />" + result.SelectSingleNode("./web:Description", nsmgr).InnerText + "<br />";
srHtml += "<span class=\"url\">" + result.SelectSingleNode("./web:Url", nsmgr).InnerText + "</span></li>\n";
phResults.Controls.Add(new System.Web.UI.LiteralControl(srHtml));
}
I can see that button on result page. But I dont know where can I put the code that run when user clicks on this button. When User clicks on that button, I want to change that button textfield with shorten url.
Can anyone help me out here ?
Regards,
Sumit Lonkar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样做怎么样?:
你的事件处理程序:
What about doing it this way?:
And your event handdler: