Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Events Events Events Please Help

Reply
Thread Tools

Events Events Events Please Help

 
 
Chris
Guest
Posts: n/a
 
      08-30-2005
Hello Everybody,
I would like to start off saying thank you for helping.

Ok the Issue. I can not get an event to fire from a programmelity added
button from a web control library
What I want to have happen
I need to have a web control library which inherits
system.web.ui.webcontrols.webcontrol
I Then need to create a datagrid from html code<-- No overhead of the
microsoft datagrid. about 2 times faster with displaying data.
I Then need to create a ASP:button inside that datagrid(from html code).

Getting everything to display is done in the code below. Getting the event
to fire on the <ASP: button I am pulling my hair out.
I have tryed the IPostBackEventdata,
raiseUPBubbleEvent,
I have tryed addhandler.
I have tryed to addhandler to the parent page with the addressof
webcontrolibrary.onclick event

I can not get anything to raise event on the webcontrol library.

So this is the code from the IPostBackEventData. The reason I am still using
this is because I have found a workaround for the time

So the code is as:

I have a web form.
Code:: You will see the HOKEY workaround that I did to get this to work
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
Try
Dim c As New System.Data.DataColumn
Dim str As New StringBuilder
Dim html As HtmlTextWriter
Dim i, i2 As Integer
Dim drholder() As DataRow
Dim dr As DataRow
html = output
MyBase.EnableViewState = True
Dim irow As Integer
Dim evt As String
Dim ssplit5 As Object
Dim ctl As String
Try
dt = DataSource
Catch ex As Exception
ErrorState = ErrorsAllowed.NoDataSource
End Try

Try
ssplit5 = Split(Page.Request.Params.Item("__EVENTTARGET"), ":")
evt = ssplit5(0)
Catch ex As Exception
ErrorState = ErrorsAllowed.NoEventControlCaptured
End Try
Try
ssplit5 = Split(Me.UniqueID, ":")
ctl = ssplit5(0)
Catch ex As Exception
ErrorState = ErrorsAllowed.UniqueIdNotFound
End Try


If (LCase(evt) = LCase(Left(Me.UniqueID, Len(evt)))) Then
irow = 0
Try
For Each dr In dt.Rows
If (Page.Request.Params.Item("__EVENTARGUMENT") = irow) Then
RaiseEvent RowClicked(dr)
Exit For
Else
irow = irow + 1
End If
Next
Catch ex As Exception

End Try

Try
For Each c In dt.Columns
If (Page.Request.Params.Item("__EVENTARGUMENT") =
c.ColumnName.ToString) Then
passin = c.ColumnName.ToString
Exit For
Else
passin = ""
End If
Next
Catch ex As Exception

End Try

End If
Dim wid As Integer
For Each c In dt.Columns
wid = wid + c.MaxLength
Next
str.Append("<script language=""javascript""> function rowSelect(row,col)
{ } function sort(cn) { } function EditThis(button,value) { }" & vbCrLf)
str.Append("</script>" & vbCrLf)
str.Append("<DIV id=""gridMain"" style="" HEIGHT: 300px"">" & vbCrLf)
str.Append("<Table width=""" & wid & """ border=""1"" cellpadding=""0""
cellspacing=""0"" ><tr>" & vbCrLf)
For Each c In dt.Columns
str.Append("<td align=""Left"" width=""" & c.MaxLength & """ ><a
href=""#"" onclick=""JavaScript:" & Page.GetPostBackEventReference(Me,
c.ColumnName.ToString) & ";"">" & vbCrLf)
str.Append(c.ColumnName.ToString & vbCrLf)
str.Append("</a></td>" & vbCrLf)
Next
str.Append("</tr></table>" & vbCrLf)
str.Append("<DIV id=""grid"" style=""OVERFLOW: auto; HEIGHT:
250px""><table border=""1"" width=""" & wid & """ cellpadding=""0""
cellspacing=""0"">" & vbCrLf)

irow = 0
Dim icol As Integer
icol = dt.Columns.Count
Try


If (Len(Trim(passin)) <> 0) Then
dt.DefaultView.Sort = passin & " DESC"
Else
dt.DefaultView.Sort = "Desc"
End If
Catch ex As Exception

End Try
For Each dr In dt.DefaultView.Table.Rows
str.Append("<tr>")
Dim ssplit As Object
i = 0
For Each c In dt.Columns
Try
ssplit = Split(dr.Item(i), "!")
str.Append("<td align=""Left"" onclick=""Javascript: rowSelect(" &
irow.ToString & "," & icol.ToString & ");"" id=""" & irow.ToString & "," &
icol.ToString & """ width=""" & c.MaxLength & """>" & vbCrLf)
If (UBound(ssplit) = 1) Then
If (ssplit(0) = "~BUTTON") Then
Dim ssplit2 As Object
ssplit2 = Split(dr.Item(6), "!")
btn.Attributes.Add("BtnValue", ssplit2(0))
Dim e As New System.EventArgs
b = New MyButton(ssplit2(0), irow)
MyBase.Parent.Controls.Add(b)
Dim sw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(sw)
b.RenderControl(hw)
str.Append(sw)
hw.Close()
hw = Nothing
sw.Close()
sw = Nothing
Else
str.Append(ssplit(0))
End If
str.Append("</td>" & vbCrLf)
End If
i = i + 1
Catch ex As Exception
End Try
Next
str.Append("</tr>" & vbCrLf)
irow = irow + 1
Next
str.Append("</table>" & vbCrLf)
output.Write(str.ToString)
output.Write("</div></div>" & vbCrLf)
Catch ex As Exception

End Try

End Sub





I have a web control library
My web control library inherits system.web.ui.webcontrols.webcontrol

Inside my webcontrol I have 2 classes
ofcourse I have my base class of the webcontrol
Then I have another class called MyButton
The Class of MyButton is as
Public Class MyButton
Inherits Control
Implements IPostBackDataHandler
Implements IPostBackEventHandler

Public Event Click As EventHandler
Protected Overridable Sub OnClick(ByVal e As EventArgs)
RaiseEvent Click(Me, e)
End Sub

Public Sub RaisePostBackEvent(ByVal eventArgument As String) Implements
IPostBackEventHandler.RaisePostBackEvent
OnClick(EventArgs.Empty)
End Sub

Dim buttonkeeper As String
Dim irow As String
Public Sub New(ByVal buttonValue As String, ByVal row As String)
buttonkeeper = buttonValue
irow = row
End Sub

Protected Overrides Sub Render(ByVal output As HtmlTextWriter)
output.Write("<INPUT TYPE=submit OnClick=""JavaScript:" &
Page.GetPostBackEventReference(Me, irow) & ";"" name=" & Me.UniqueID & "
row="" & irow & "" Value='Edit' />")

End Sub

Public Function LoadPostData(ByVal postDataKey As String, ByVal
postCollection As System.Collections.Specialized.NameValueCollection ) As
Boolean Implements System.Web.UI.IPostBackDataHandler.LoadPostData

End Function

Public Sub RaisePostDataChangedEvent() Implements
System.Web.UI.IPostBackDataHandler.RaisePostDataCh angedEvent

End Sub

End Class

As you can see from the class above it is just a class that inherits Control


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please please please help this guy with his open source java app casioculture@gmail.com Java 4 05-05-2005 08:24 AM
Console profile for Windows app in VC++ - PLEASE PLEASE PLEASE HELP! MuZZy C++ 7 01-07-2005 08:40 PM
Computer problems please please please help Nick Computer Support 0 06-04-2004 08:49 PM
HELP! HELP! PLEASE, PLEASE, PLEASE tpg comcntr Computer Support 11 02-15-2004 06:22 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57