帮助 !!!关于事件 [英] help !!! about event

查看:81
本文介绍了帮助 !!!关于事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,有人可以帮助我吗?
我用c#制作了一个Web应用程序,但是我的问题是影响链接按钮的事件不在加载函数内
它不起作用

这是我的代码
控件是AN
函数是AN_Click

Hi every body, some one can help me??
I make a web application with c# but my problem is with affecting event to a Link Button not inside load function
it doesn''t work

this is my code
the control is AN
and the function is AN_Click

protected void NewTache_Click1(object sender, ImageClickEventArgs e)
    {
        Session["TableNonPrevu"] = Int32.Parse(Session["TableNonPrevu"].ToString()) + Int32.Parse(TextBox43.Text);
        for (Int32 i = 0; i < Int32.Parse(Session["TableNonPrevu"].ToString()); i++)
        {
            Int32 currentrow=i + Table2.Rows.Count;
            TableRow newrow = new TableRow();
            newrow.Cells.Add(new TableCell());
            newrow.Cells.Add(new TableCell());
            newrow.Cells.Add(new TableCell());
            newrow.Cells.Add(new TableCell());            
            TextBox tache = new TextBox();            
            TextBox charge = new TextBox();
            TextBox description = new TextBox();
            ListBox responsable = new ListBox();
            LinkButton AN = new LinkButton();
            UpdatePanel ANU = new UpdatePanel(); 
            tache.Width = 347;            
            responsable.Width = 74;
            responsable.Height = 26;            
            responsable.ID = "re" + currentrow;
            AN.ID = "AN" + currentrow;
            AN.Text = " +";
            AN.OnClientClick = "Ressource()";
            AN.Click += new EventHandler(AN_Click);
            ANU.ID = "AN"+ currentrow +"U";
            AN.CommandArgument = "2:" + currentrow + ":" + responsable.ID +":"+ ANU.ID;
            charge.Width = 75;
            description.Width = 347;
            ANU.ContentTemplateContainer.Controls.Add(responsable);
            ANU.ContentTemplateContainer.Controls.Add(AN);
            ANU.UpdateMode = UpdatePanelUpdateMode.Conditional;
            newrow.Cells[0].Controls.Add(tache);
            newrow.Cells[1].Controls.Add(ANU);
            newrow.Cells[1].HorizontalAlign = HorizontalAlign.Left ;
            newrow.Cells[2].Controls.Add(charge);
            newrow.Cells[3].Controls.Add(description);
            Table2.Rows.Add(newrow);
        }
        NonPrevue.Update();
    }


谢谢:sdoh:


thank''s :doh:

推荐答案

动态创建控件时,必须在回发期间重新创建控件,才能触发事件.
When controls are created dynamically they must be recreated during the postback in order for the event to be triggered.


If the linkbutton has PostBackUrl set then the Click event of that linkbutton will not fire.


这篇关于帮助 !!!关于事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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