我需要有关获取用户cotrol火事件的帮助 [英] i need help about get user cotrol fire event
本文介绍了我需要有关获取用户cotrol火事件的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
几周前,我发现文章使用的是Visual Basic语言,以及有关创建和删除动态webusercontrol的信息,我在此发送此信息是因为我的问题是关于C#语法的,而不仅仅是asp.net问题
few weekd ago i find article was in visual basic language and its about create and delete dynamic webusercontrol , i sent this post here because my problem is about C# syntax , not just asp.net problem
检查VB代码的这一部分
check this part of VB code
Sub HandleRemoveUserControl(ByVal sender As Object, ByVal e As EventArgs)
'This handles delete event fired from the user control
'Get the user control that fired this event, and remove it
Dim DynamicUserControl As WebUserControl = sender.parent
ph1.Controls.Remove(sender.parent)
'Keep a pipe delimited list of which user controls
'were removed. This will increase the
'viewstate size if the user keeps removing
'dynamic controls, but under normal use
'this is such a small increase in size that it shouldn't be an issue.
ltlRemoved.Text &= DynamicUserControl.ID & "|"
'Also, now that we've removed a user control decrement
'the count of total user controls on the page
ltlCount.Text = Convert.ToInt16(ltlCount.Text) - 1
End Sub
推荐答案
这不是C#问题.有几种可能的原因:
This isn't a C# problem. There are a few possible causes:
- 有时会在没有发送方的情况下调用此事件(即sender == null)
- ph1为null(什么样的对象是ph1,它在哪里声明的?)
- sender是像窗体一样的父级控件,它本身没有父级(sender.parent == null)
- This event is sometimes called without a sender (i.e. sender == null)
- ph1 is null (what kind of object is ph1, and where is it declared?)
- sender is a parent-level control like a form, which doesn't have a parent itself (sender.parent == null)
这篇关于我需要有关获取用户cotrol火事件的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文