jQuery的对话和asp.net动态的LinkBut​​ton [英] jquery dialog and asp.net dynamic linkbutton

查看:117
本文介绍了jQuery的对话和asp.net动态的LinkBut​​ton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有有一个包含进行动态补充说LinkBut​​tons一排一个gridview。
被点击这些LinkBut​​tons当我需要显示确认对话框。
我想在这个帖子提出的工作:
<一href=\"http://stackoverflow.com/questions/1570329/jquery-dialog-and-asp-net-repeater/1579057#1579057\">JQuery对话和ASP.NET直放站
但它不工作,postBackReference不包含正确的ID(它忽略占位符)
这是我的code:

I Have a gridview which has a row that contains LinkButtons that were added dynamically. when these LinkButtons are clicked I need to show a confirmation dialog. I tried to work as suggested in this post: JQuery DIalog and ASP.NET Repeater but it doesn't work, the postBackReference doesn't contain the right ID (it ignores the placeholder) this is my code:

GridView1_RowCreated(Object sender, GridViewRowEventArgs e)
{
   //some code here

   LinkButton lb = new LinkButton();
   lb.Text = "something";
   lb.ID = "someId";
   string postBackReference = ClientScript.GetPostBackEventReference(lb, string.Empty);
   lb.OnClientClick = "javascript: showConf(function(){"+ postBackReference  +"});return false;";

   TableCell cell = new TableCell();
   cell.Controls.Add(lb);
   e.Row.Cells.Add(cell);
}

有没有人有一个想法?

Does anyone has an idea ?

推荐答案

所以这里是为我工作的解决方案:
基本上我根据这个职位的解决方案工作:
<一href=\"http://stackoverflow.com/questions/1570329/jquery-dialog-and-asp-net-repeater/1579057#1579057\">JQuery对话和ASP.NET直放站
唯一的区别是,我不得不使用RowCreated事件添加我的动态LinkBut​​tons和RowDataBound事件的正确注册我的客户端功能(否则原__doPostBack不会得到ID参数(就像它忽略了一个事实,这是一个占位))。
所以,我的code背后看起来像现在这样:

So here is a solution that worked for me: Basically I worked according to the solution in this post: JQuery DIalog and ASP.NET Repeater The only difference was that I had to use the RowCreated Event for adding my dynamic LinkButtons and RowDataBound Event for registering my client function (otherwise the original __doPostBack wouldn't get the ID param correctly (as if it ignores the fact that it is in a place holder)). So my code behind looks like this now:

GridView1_RowCreated(Object sender, GridViewRowEventArgs e)
{
   //some code here

   LinkButton lb = new LinkButton();
   lb.Text = "something";
   lb.ID = "someId";

   TableCell cell = new TableCell();
   cell.Controls.Add(lb);
   e.Row.Cells.Add(cell);
}

GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
{
   //some code here

   LinkButton lb = e.Row.FindControl("someId") as LinkButton;
   string postBackReference = ClientScript.GetPostBackEventReference(lb, string.Empty);
   lb.OnClientClick = "javascript: showConf(function(){"+ postBackReference  +"});return false;";

}

客户端功能 - showConf和标记,因为他们的风格。

client function- showConf and markup stay as they were.

这篇关于jQuery的对话和asp.net动态的LinkBut​​ton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆