Click here to Skip to main content
16,005,552 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Is it possible to add virtual controls to the DOM tree? Pin
howardjr19-Dec-06 15:53
howardjr19-Dec-06 15:53 
Questionwebsite development in different language.... Pin
Nagraj Naik19-Dec-06 1:05
Nagraj Naik19-Dec-06 1:05 
AnswerRe: website development in different language.... Pin
Bradml19-Dec-06 1:17
Bradml19-Dec-06 1:17 
QuestionCrystal Reports XI Pin
jagmit2019-Dec-06 0:50
jagmit2019-Dec-06 0:50 
QuestionComboBox custom web/server-side control - where's the data? Pin
howardjr18-Dec-06 18:29
howardjr18-Dec-06 18:29 
AnswerRe: ComboBox custom web/server-side control - where's the data? Pin
howardjr19-Dec-06 15:52
howardjr19-Dec-06 15:52 
GeneralRe: ComboBox custom web/server-side control - where's the data? Pin
howardjr19-Dec-06 16:28
howardjr19-Dec-06 16:28 
GeneralRe: ComboBox custom web/server-side control - where's the data? Pin
howardjr20-Dec-06 10:16
howardjr20-Dec-06 10:16 
This is a work around that I used after I got some help from Sebastián Streiger after posting a similar question on his article's feedback:

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
    MyBase.OnInit(e)
    Try
        If Page.IsPostBack() Then
            ' The page can have many instances of this component, so don't want to push the
            ' cwcComboBoxInfo state class instance infomation through the ViewState, so put
            ' a reference to in a session variable, actually done at the end of the Render
            ' Sub.
            '
            ' When the page is posted back, the component state is restored by setting the
             cwcComboBoxInfo to the reference value saved in the  session variable.
            '
            If Not HttpContext.Current.Session(cwcComboBoxInfo.ID) Is Nothing Then
                cwcComboBoxInfo =
                   CType(HttpContext.Current.Session(cwcComboBoxInfo.ID),
                         cwcComboBoxInfoClass)
            End If

            ' Get the postback data.
            LoadPostData()  ' There is a bug in VS.NET 2003 that prevents the LoadPostData
                            ' function from overriding/shadowing the listbox base class's
                            ' IPostBackDataHandler.LoadPostData and RaisePostDataChangeEvent
                            ' implementation, so call the LoadPostData function directly to
                            ' get the posted data.
        End If
    Catch Ex As Exception
        Throw New cwcComboBoxException("OnLoad: Exception - Component " & Me.ID & ", " & _
                                       Ex.Message)
    End Try
End Sub

' -------------------------------------------------------------

' The following was a suggested fix to the IPostBackDataHandler implmentation problem, but
' it didn't seem to help.  Instead, Sebastián Streiger suggested that the Impments ...
' statement should be removed from the LoadPostData function and RaisePostDataChangeEvent Sub
' declarations.  However, while this allowed me to compile the code it doesn't seem to get
' called by the .NET Framework.  So I implmemented a override LoadPostData function with no
' parameters that I directly call from the OnLoad event sub above.

Public Shadows Interface IPostBackDataHandler
    Function LoadPostData(ByVal sPostData As String, _
                          ByVal oPostCollection As NameValueCollection) As Boolean
    Sub RaisePostDataChangedEvent()
End Interface

' -------------------------------------------------------------

Private Enum EventsType
    NoEvent
    TextBoxValueChanged
    SelectedListIndexChanged
End Enum

'
' This "global variable keeps track of the component's event that needs to be raised.
' Part of the IPostBackDataHandler workaround I'm using.
'
Private EventType As EventsType = EventsType.NoEvent

'
' Define a LoadPostData function that can be called from the OnLoad event
' just in case the IPostBackData Handler isn't called by the .NET Framework.
'
Private Function LoadPostData() As Boolean
    Return LoadPostData(cwcComboBoxInfo.ID, Me.Page.Request.Params)
End Function

'
' Should be called by the .NET Framework do allow handling of the PostBack Data for this
' component.  If that doesn't happen then the overload above can be called.
'
Public Overridable Function LoadPostData(ByVal Key As String, _
                                         ByVal PostedValues As NameValueCollection) _
                                         As Boolean
    '
    ' Implements System.Web.UI.IPostBackDataHandler.LoadPostData
    '
    Dim Values As String() = PostedValues.GetValues(cwcComboBoxInfo.ID)
    Dim OldValue, NewValue As String
    Dim Result As Boolean


    Select Case Values.Length
        Case 0
            ' Use the component's custom exception
            EventType = EventsType.NoEvent
            Throw New cwcComboBoxException("LoadPostData: Exception - " & _
                                           "No data found for the '" & _
                                           cwcComboBoxInfo.ID & "' component!")
        Case 1
            OldValue = [Text]
            NewValue = Values(0).Trim()
            If [IgnoreCase] Then
                Result = (OldValue.ToLower() = NewValue.ToLower())
            Else
                Result = (OldValue = NewValue)
            End If
            If Result Then
                [SelectedListIndex] = NOTHINGSELECTED
                [Text] = NewValue
                EventType = EventsType.TextBoxValueChanged
            End If
        Case 2
            [SelectedListIndex] = Val(Values(1))
            EventType = EventsType.SelectedListIndexChanged
        Case Else
            EventType = EventsType.NoEvent
            Throw New cwcComboBoxException("LoadPostData: Exception - Too much data " & _
                                           "posted for the '" & _
                                           cwcComboBoxInfo.ID & "' component, " & _
                                           Values.Length & " data items " & _
                                           "(" & Me.Page.Request.Params.Get( _
                                                     cwcComboBoxInfo.ID) & ")!")
    End Select
    Return (EventType <> EventsType.NoEvent)
End Function

' -------------------------------------------------------------

Public Event TextBoxValueChanged As EventHandler

Protected Overridable Sub OnTextBoxValueChanged(ByVal Ex As EventArgs)
    RaiseEvent TextBoxValueChanged(Me, Ex)
End Sub

' -------------------------------------------------------------

Public Event SelectListIndexChanged As EventHandler

Protected Overridable Sub OnSelectedListIndexChanged(ByVal Ex As EventArgs)
    RaiseEvent SelectListIndexChanged(Me, Ex)
End Sub

' -------------------------------------------------------------

Public Overridable Shadows Sub RaisePostDataChangedEvent()
    '
    ' Implements IPostBackDataHandler.RaisePostDataChangedEvent
    '
    ' Figures out which event handler to use.
    '
    Select Case EventType
        Case EventsType.NoEvent
            ' No Action - No event occurred.
        Case EventsType.TextBoxValueChanged
            OnTextBoxValueChanged(EventArgs.Empty)
        Case EventsType.SelectedListIndexChanged
            OnSelectedListIndexChanged(EventArgs.Empty)
    End Select
End Sub

QuestionHow do I left align text within a span tag Pin
howardjr18-Dec-06 10:53
howardjr18-Dec-06 10:53 
AnswerRe: How do I left align text within a span tag Pin
George L. Jackson18-Dec-06 12:38
George L. Jackson18-Dec-06 12:38 
GeneralRe: How do I left align text within a span tag Pin
howardjr18-Dec-06 13:56
howardjr18-Dec-06 13:56 
GeneralRe: How do I left align text within a span tag Pin
George L. Jackson18-Dec-06 14:04
George L. Jackson18-Dec-06 14:04 
GeneralRe: How do I left align text within a span tag Pin
howardjr18-Dec-06 18:16
howardjr18-Dec-06 18:16 
GeneralRe: How do I left align text within a span tag Pin
George L. Jackson19-Dec-06 1:54
George L. Jackson19-Dec-06 1:54 
GeneralRe: How do I left align text within a span tag Pin
howardjr19-Dec-06 5:54
howardjr19-Dec-06 5:54 
QuestionIE with JS Pin
militiaware16-Dec-06 22:47
militiaware16-Dec-06 22:47 
JokeRe: IE with JS Pin
Bradml16-Dec-06 23:30
Bradml16-Dec-06 23:30 
GeneralRe: IE with JS Pin
militiaware16-Dec-06 23:43
militiaware16-Dec-06 23:43 
GeneralRe: IE with JS Pin
Bradml17-Dec-06 0:06
Bradml17-Dec-06 0:06 
GeneralRe: IE with JS Pin
JimmyRopes17-Dec-06 17:42
professionalJimmyRopes17-Dec-06 17:42 
AnswerRe: IE with JS Pin
Guffa17-Dec-06 0:10
Guffa17-Dec-06 0:10 
GeneralRe: IE with JS Pin
militiaware17-Dec-06 0:14
militiaware17-Dec-06 0:14 
AnswerRe: IE with JS Pin
Guffa17-Dec-06 6:18
Guffa17-Dec-06 6:18 
AnswerRe: IE with JS Pin
militiaware17-Dec-06 4:12
militiaware17-Dec-06 4:12 
Questionxhtml and footers Pin
Jeremy Falcon16-Dec-06 4:26
professionalJeremy Falcon16-Dec-06 4:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.