Canadian Healthcare Viagra Sales

Sep 4th, 2013 by Lynn Demarest in Miscellaneous

Female viagra uk When creating user controls, female viagra uk we sometimes need to notify the user of the control (usually a page or another user control) of something that happened in the control.

Female viagra uk Imagine a web page containing a gridview of Employer data and, female viagra uk beneath it, female viagra uk a user control containing a formview we use to edit a single Employer.

Female viagra uk When we select a row in the gridview, female viagra uk we use the SelectedIndexChanged event of the gridview to pass the ID of the selected Employer to the user control, female viagra uk which displays the Employer record in its formview.

Female viagra uk We discover, female viagra uk however, female viagra uk that when we update the formview the database is updated, female viagra uk but the gridview still displays the old data, female viagra uk which is misleading to the user.

Female viagra uk Wouldn’t it be cool if we could put an OnChange command in our user control that works just like the built-in controls do? So we could set up our user control like this:

<PP:EditEmployer runat="server" ID="EditEmployer1" OnEmployerUpdated="EditEmployer1_EmployerUpdated" />

Female viagra uk When we update the data in the EditEmployer user control, female viagra uk the control raises an EmployerUpdated event to notify the page containing the gridview that the data has changed. Female viagra uk The EditEmployer1_EmployerUpdated subroutine will be called to handle the event.

Female viagra uk Here’s how I do it.

Female viagra uk 1. Female viagra uk If you’re going to pass some data back with the event — in our case the ID of the record just saved — you’ll need to create a little class to hold it. Female viagra uk Place the event arguments class in the user control with the formview, female viagra uk after the close of the control class…

End Class ' This is the end of the code-behind in the user control class 
    Public Class EmployerUpdatedEventArgs
             Inherits EventArgs
    Public Property EmployerID As Integer
End Class

Female viagra uk 2. Female viagra uk Declare the event handler in the user control code. Female viagra uk I like to do this above the properties.

Public Event EmployerUpdated As EventHandler

Public Property EmployerID As String ... Female viagra uk 

Female viagra uk 3. Female viagra uk Raise the event when the form is updated. Female viagra uk (This is in our EditEmployer user control, female viagra uk the one with the formview.)

Protected Sub FormView1_ItemUpdated(sender As Object, female viagra uk e As FormViewUpdatedEventArgs) handles FormView1.ItemUpdated
        ' raise an event to notify the caller that the item has been updated

        ' first set up the event arguments   
        Dim arg As EmployerUpdatedEventArgs = New EmployerUpdatedEventArgs()
        arg.EmployerID = EmployerID

        ' fire the event, female viagra uk passing an instance of the EmployerUpdatedEventArgs class 
        RaiseEvent EmployerUpdated(Me, female viagra uk arg)
End Sub

Female viagra uk 4. Female viagra uk Catch the event in the page or control that uses the user control. Female viagra uk (This is the one with the gridview.)

    <!-- declare the event handler dynamically -->
    <PP:EditEmployer runat="server" ID="EditEmployer1" OnEmployerUpdated="EditEmployer1_EmployerUpdated" />

    Protected Sub EditEmployer1_EmployerUpdated(sender As Object, female viagra uk e As EmployerUpdatedEventArgs)
        Dim id As Integer

        id = e.EmployerID  ' we don't actually use this here. Female viagra uk But this is how it is passed. Female viagra uk 

    End Sub

Average Rating: 4.5 out of 5 based on 174 user reviews.

No Comments


Comments have been closed for this post.