Sunday, October 19, 2008

Capturing a Event in .NET

If there are more controls in our application. In some cases,in every postback all events raise at a time.
So,at that time capturing an event is necessary.I have faced this problem,and i came up with this solution.Hope it will help u.
IMP : Call this Function in Page_Init

IN VB.NET

Function Getfieldname(ByVal targPage As Page) As String
vfieldname = ""
If targPage.IsPostBack Then
Dim keyName As String
For Each keyName In targPage.Request.Form
If Not keyName Is Nothing Then
If keyName.Length >= 41 Then
If keyName.Substring(0, 41) = "ctl00$ContentPlaceHolder1$ImgbtnConfigure" Then
vfieldname = "ADD"
rowid = keyName.Substring(41, 1)
End If
End If
End If
Next
End If
End Function

2 comments:

Unknown said...

I came across this problem,and i got the solution by using this code.anyway thnks for ur code.

Anonymous said...

Good...
I got a solution from ur code.
Thanks..