Q: Why this not work ?

Discussion in 'ASP General' started by Harold, Sep 28, 2003.

  1. Harold

    Harold Guest

    This is just me testing, however the two top sub's are
    never called........why ?.

    Where is the error of my ways?

    Sub ProcessLogo(ByVal sender As Object, ByVal e As
    CommandEventArgs)
    Dim Test As Object = e.CommandArgument
    End Sub

    Sub ProcessLogo_Click(ByVal sender As Object, ByVal e As
    System.EventArgs)
    Dim Test As Object = CType(sender,
    Button).CommandName
    End Sub

    Function BuildLogoTable()
    '// Get logo definitions and put them in the table
    Dim ThisPage As String = "AddCompany"
    Dim Language As String = Session.Contents("LLC")
    Try
    Dim PreviewFilePointer As String = ""
    Dim BuildLogoCommand As SqlCommand
    Dim BuildLogoReader As SqlDataReader
    Dim BuildLogoConnection As SqlConnection =
    New SqlConnection(ConfigurationSettings.AppSettings
    ("Publimation_Authorisation"))
    BuildLogoCommand = New SqlCommand
    ("GetImageDataByCatagory", BuildLogoConnection)
    BuildLogoCommand.CommandType =
    CommandType.StoredProcedure
    BuildLogoCommand.Parameters.Add("@projectid",
    SqlDbType.Int, 4).Value = Session.Contents("PID")
    BuildLogoCommand.Parameters.Add
    ("@imagecatagory", SqlDbType.Int, 4).Value = 1
    BuildLogoConnection.Open()
    BuildLogoReader =
    BuildLogoCommand.ExecuteReader
    Dim LogoRow As New TableRow()
    Dim LogoSelectRow As New TableRow()
    While BuildLogoReader.Read
    Dim LogoID As Integer =
    BuildLogoReader.GetInt32(0)
    Dim LogoImage As String =
    BuildLogoReader.GetString(8) & BuildLogoReader.GetString
    (4) & "." & BuildLogoReader.GetString(7)
    Dim LogoLocation As String =
    ConfigurationSettings.AppSettings("ProjectVirtualRoot")
    & "/domains/" & Session.Contents("PSN") & Trim(Replace
    (LogoImage, "\", "/"))
    Dim LogoCell As New TableCell()
    Dim LogoSelectCell As New TableCell()
    Dim SelectButton As New LinkButton()
    SelectButton.Text =
    GetLanguageArray.GetText(ThisPage, Language,
    LanguageArray, "Select")
    SelectButton.CommandArgument = LogoID
    AddHandler SelectButton.Command,
    AddressOf ProcessLogo
    AddHandler SelectButton.Click, AddressOf
    ProcessLogo_Click
    LogoCell.Text = "<img src=""" &
    LogoLocation & """>"
    LogoSelectCell.Controls.Add(SelectButton)
    LogoRow.Cells.Add(LogoCell)
    LogoSelectRow.Cells.Add(LogoSelectCell)
    End While
    TableLogo.Rows.Add(LogoRow)
    TableLogo.Rows.Add(LogoSelectRow)
    BuildLogoReader.Close()
    BuildLogoConnection.Close()
    Catch x As Exception
    ErrorLogger.ErrorManager
    ("BuildCompanyLogoTableError", x)
    End Try
    End Function
     
    Harold, Sep 28, 2003
    #1
    1. Advertising

  2. Harold

    Ken Schaefer Guest

    Re: Why this not work ?

    How are you "calling them", and how do you know they are now being called?

    Cheers
    Ken


    "Harold" <> wrote in message
    news:12e501c385b2$92b51640$...
    : This is just me testing, however the two top sub's are
    : never called........why ?.
    :
    : Where is the error of my ways?
    :
    : Sub ProcessLogo(ByVal sender As Object, ByVal e As
    : CommandEventArgs)
    : Dim Test As Object = e.CommandArgument
    : End Sub
    :
    : Sub ProcessLogo_Click(ByVal sender As Object, ByVal e As
    : System.EventArgs)
    : Dim Test As Object = CType(sender,
    : Button).CommandName
    : End Sub
    :
    : Function BuildLogoTable()
    : '// Get logo definitions and put them in the table
    : Dim ThisPage As String = "AddCompany"
    : Dim Language As String = Session.Contents("LLC")
    : Try
    : Dim PreviewFilePointer As String = ""
    : Dim BuildLogoCommand As SqlCommand
    : Dim BuildLogoReader As SqlDataReader
    : Dim BuildLogoConnection As SqlConnection =
    : New SqlConnection(ConfigurationSettings.AppSettings
    : ("Publimation_Authorisation"))
    : BuildLogoCommand = New SqlCommand
    : ("GetImageDataByCatagory", BuildLogoConnection)
    : BuildLogoCommand.CommandType =
    : CommandType.StoredProcedure
    : BuildLogoCommand.Parameters.Add("@projectid",
    : SqlDbType.Int, 4).Value = Session.Contents("PID")
    : BuildLogoCommand.Parameters.Add
    : ("@imagecatagory", SqlDbType.Int, 4).Value = 1
    : BuildLogoConnection.Open()
    : BuildLogoReader =
    : BuildLogoCommand.ExecuteReader
    : Dim LogoRow As New TableRow()
    : Dim LogoSelectRow As New TableRow()
    : While BuildLogoReader.Read
    : Dim LogoID As Integer =
    : BuildLogoReader.GetInt32(0)
    : Dim LogoImage As String =
    : BuildLogoReader.GetString(8) & BuildLogoReader.GetString
    : (4) & "." & BuildLogoReader.GetString(7)
    : Dim LogoLocation As String =
    : ConfigurationSettings.AppSettings("ProjectVirtualRoot")
    : & "/domains/" & Session.Contents("PSN") & Trim(Replace
    : (LogoImage, "\", "/"))
    : Dim LogoCell As New TableCell()
    : Dim LogoSelectCell As New TableCell()
    : Dim SelectButton As New LinkButton()
    : SelectButton.Text =
    : GetLanguageArray.GetText(ThisPage, Language,
    : LanguageArray, "Select")
    : SelectButton.CommandArgument = LogoID
    : AddHandler SelectButton.Command,
    : AddressOf ProcessLogo
    : AddHandler SelectButton.Click, AddressOf
    : ProcessLogo_Click
    : LogoCell.Text = "<img src=""" &
    : LogoLocation & """>"
    : LogoSelectCell.Controls.Add(SelectButton)
    : LogoRow.Cells.Add(LogoCell)
    : LogoSelectRow.Cells.Add(LogoSelectCell)
    : End While
    : TableLogo.Rows.Add(LogoRow)
    : TableLogo.Rows.Add(LogoSelectRow)
    : BuildLogoReader.Close()
    : BuildLogoConnection.Close()
    : Catch x As Exception
    : ErrorLogger.ErrorManager
    : ("BuildCompanyLogoTableError", x)
    : End Try
    : End Function
     
    Ken Schaefer, Sep 28, 2003
    #2
    1. Advertising

  3. Harold

    Harold Guest

    Re: Why this not work ?

    Hi there, and thanks for the interest,

    Firstly by adding a "dymanic" eventhander as needed
    (depending on the amount of items returned)

    "AddHandler SelectButton.Command, AddressOf ProcessLogo"
    (see in code)


    Here it should link the button action to the
    subroutine "ProcessLogo". So if the button has a command
    (event) it should be handled by the subroutine.

    But it isn't. It's pretty to check, just put the routine
    in debug mode and put a break on the first best code line
    in the subroutine, then you will see the routine is never
    called. It is as if the handler is ignored.

    Any Ideas ?

    Thanks in advance.
    Harold.
    >-----Original Message-----
    >How are you "calling them", and how do you know they are

    now being called?
    >
    >Cheers
    >Ken
    >
    >
    >"Harold" <> wrote in message
    >news:12e501c385b2$92b51640$...
    >: This is just me testing, however the two top sub's are
    >: never called........why ?.
    >:
    >: Where is the error of my ways?
    >:
    >: Sub ProcessLogo(ByVal sender As Object, ByVal e As
    >: CommandEventArgs)
    >: Dim Test As Object = e.CommandArgument
    >: End Sub
    >:
    >: Sub ProcessLogo_Click(ByVal sender As Object, ByVal e

    As
    >: System.EventArgs)
    >: Dim Test As Object = CType(sender,
    >: Button).CommandName
    >: End Sub
    >:
    >: Function BuildLogoTable()
    >: '// Get logo definitions and put them in the

    table
    >: Dim ThisPage As String = "AddCompany"
    >: Dim Language As String = Session.Contents

    ("LLC")
    >: Try
    >: Dim PreviewFilePointer As String = ""
    >: Dim BuildLogoCommand As SqlCommand
    >: Dim BuildLogoReader As SqlDataReader
    >: Dim BuildLogoConnection As SqlConnection =
    >: New SqlConnection(ConfigurationSettings.AppSettings
    >: ("Publimation_Authorisation"))
    >: BuildLogoCommand = New SqlCommand
    >: ("GetImageDataByCatagory", BuildLogoConnection)
    >: BuildLogoCommand.CommandType =
    >: CommandType.StoredProcedure
    >: BuildLogoCommand.Parameters.Add

    ("@projectid",
    >: SqlDbType.Int, 4).Value = Session.Contents("PID")
    >: BuildLogoCommand.Parameters.Add
    >: ("@imagecatagory", SqlDbType.Int, 4).Value = 1
    >: BuildLogoConnection.Open()
    >: BuildLogoReader =
    >: BuildLogoCommand.ExecuteReader
    >: Dim LogoRow As New TableRow()
    >: Dim LogoSelectRow As New TableRow()
    >: While BuildLogoReader.Read
    >: Dim LogoID As Integer =
    >: BuildLogoReader.GetInt32(0)
    >: Dim LogoImage As String =
    >: BuildLogoReader.GetString(8) &

    BuildLogoReader.GetString
    >: (4) & "." & BuildLogoReader.GetString(7)
    >: Dim LogoLocation As String =
    >: ConfigurationSettings.AppSettings("ProjectVirtualRoot")
    >: & "/domains/" & Session.Contents("PSN") & Trim(Replace
    >: (LogoImage, "\", "/"))
    >: Dim LogoCell As New TableCell()
    >: Dim LogoSelectCell As New TableCell()
    >: Dim SelectButton As New LinkButton()
    >: SelectButton.Text =
    >: GetLanguageArray.GetText(ThisPage, Language,
    >: LanguageArray, "Select")
    >: SelectButton.CommandArgument = LogoID
    >: AddHandler SelectButton.Command,
    >: AddressOf ProcessLogo
    >: AddHandler SelectButton.Click,

    AddressOf
    >: ProcessLogo_Click
    >: LogoCell.Text = "<img src=""" &
    >: LogoLocation & """>"
    >: LogoSelectCell.Controls.Add

    (SelectButton)
    >: LogoRow.Cells.Add(LogoCell)
    >: LogoSelectRow.Cells.Add(LogoSelectCell)
    >: End While
    >: TableLogo.Rows.Add(LogoRow)
    >: TableLogo.Rows.Add(LogoSelectRow)
    >: BuildLogoReader.Close()
    >: BuildLogoConnection.Close()
    >: Catch x As Exception
    >: ErrorLogger.ErrorManager
    >: ("BuildCompanyLogoTableError", x)
    >: End Try
    >: End Function
    >
    >
    >.
    >
     
    Harold, Sep 28, 2003
    #3
  4. Harold

    Ken Schaefer Guest

    Re: Why this not work ?

    Sorry - what I meant was - are you actually pressing the button?

    Also, I suggest you post the follow up to one of the ASP.Net newsgroups,
    since there are more ASP.Net people there...

    Cheers
    Ken


    "Harold" <> wrote in message
    news:152301c385ba$e3433670$...
    : Hi there, and thanks for the interest,
    :
    : Firstly by adding a "dymanic" eventhander as needed
    : (depending on the amount of items returned)
    :
    : "AddHandler SelectButton.Command, AddressOf ProcessLogo"
    : (see in code)
    :
    :
    : Here it should link the button action to the
    : subroutine "ProcessLogo". So if the button has a command
    : (event) it should be handled by the subroutine.
    :
    : But it isn't. It's pretty to check, just put the routine
    : in debug mode and put a break on the first best code line
    : in the subroutine, then you will see the routine is never
    : called. It is as if the handler is ignored.
    :
    : Any Ideas ?
    :
    : Thanks in advance.
    : Harold.
    : >-----Original Message-----
    : >How are you "calling them", and how do you know they are
    : now being called?
    : >
    : >Cheers
    : >Ken
    : >
    : >
    : >"Harold" <> wrote in message
    : >news:12e501c385b2$92b51640$...
    : >: This is just me testing, however the two top sub's are
    : >: never called........why ?.
    : >:
    : >: Where is the error of my ways?
    : >:
    : >: Sub ProcessLogo(ByVal sender As Object, ByVal e As
    : >: CommandEventArgs)
    : >: Dim Test As Object = e.CommandArgument
    : >: End Sub
    : >:
    : >: Sub ProcessLogo_Click(ByVal sender As Object, ByVal e
    : As
    : >: System.EventArgs)
    : >: Dim Test As Object = CType(sender,
    : >: Button).CommandName
    : >: End Sub
    : >:
    : >: Function BuildLogoTable()
    : >: '// Get logo definitions and put them in the
    : table
    : >: Dim ThisPage As String = "AddCompany"
    : >: Dim Language As String = Session.Contents
    : ("LLC")
    : >: Try
    : >: Dim PreviewFilePointer As String = ""
    : >: Dim BuildLogoCommand As SqlCommand
    : >: Dim BuildLogoReader As SqlDataReader
    : >: Dim BuildLogoConnection As SqlConnection =
    : >: New SqlConnection(ConfigurationSettings.AppSettings
    : >: ("Publimation_Authorisation"))
    : >: BuildLogoCommand = New SqlCommand
    : >: ("GetImageDataByCatagory", BuildLogoConnection)
    : >: BuildLogoCommand.CommandType =
    : >: CommandType.StoredProcedure
    : >: BuildLogoCommand.Parameters.Add
    : ("@projectid",
    : >: SqlDbType.Int, 4).Value = Session.Contents("PID")
    : >: BuildLogoCommand.Parameters.Add
    : >: ("@imagecatagory", SqlDbType.Int, 4).Value = 1
    : >: BuildLogoConnection.Open()
    : >: BuildLogoReader =
    : >: BuildLogoCommand.ExecuteReader
    : >: Dim LogoRow As New TableRow()
    : >: Dim LogoSelectRow As New TableRow()
    : >: While BuildLogoReader.Read
    : >: Dim LogoID As Integer =
    : >: BuildLogoReader.GetInt32(0)
    : >: Dim LogoImage As String =
    : >: BuildLogoReader.GetString(8) &
    : BuildLogoReader.GetString
    : >: (4) & "." & BuildLogoReader.GetString(7)
    : >: Dim LogoLocation As String =
    : >: ConfigurationSettings.AppSettings("ProjectVirtualRoot")
    : >: & "/domains/" & Session.Contents("PSN") & Trim(Replace
    : >: (LogoImage, "\", "/"))
    : >: Dim LogoCell As New TableCell()
    : >: Dim LogoSelectCell As New TableCell()
    : >: Dim SelectButton As New LinkButton()
    : >: SelectButton.Text =
    : >: GetLanguageArray.GetText(ThisPage, Language,
    : >: LanguageArray, "Select")
    : >: SelectButton.CommandArgument = LogoID
    : >: AddHandler SelectButton.Command,
    : >: AddressOf ProcessLogo
    : >: AddHandler SelectButton.Click,
    : AddressOf
    : >: ProcessLogo_Click
    : >: LogoCell.Text = "<img src=""" &
    : >: LogoLocation & """>"
    : >: LogoSelectCell.Controls.Add
    : (SelectButton)
    : >: LogoRow.Cells.Add(LogoCell)
    : >: LogoSelectRow.Cells.Add(LogoSelectCell)
    : >: End While
    : >: TableLogo.Rows.Add(LogoRow)
    : >: TableLogo.Rows.Add(LogoSelectRow)
    : >: BuildLogoReader.Close()
    : >: BuildLogoConnection.Close()
    : >: Catch x As Exception
    : >: ErrorLogger.ErrorManager
    : >: ("BuildCompanyLogoTableError", x)
    : >: End Try
    : >: End Function
    : >
    : >
    : >.
    : >
     
    Ken Schaefer, Sep 28, 2003
    #4
  5. Harold

    Harold Guest

    Re: Why this not work ?

    of course I (click with the mouse) Press the button, and
    page is indeed posted back to the server, but as
    mentioned, no further activity.

    PS: thanks for the tip.

    Harold
    >-----Original Message-----
    >Sorry - what I meant was - are you actually pressing the

    button?
    >
    >Also, I suggest you post the follow up to one of the

    ASP.Net newsgroups,
    >since there are more ASP.Net people there...
    >
    >Cheers
    >Ken
    >
    >
    >"Harold" <> wrote in message
    >news:152301c385ba$e3433670$...
    >: Hi there, and thanks for the interest,
    >:
    >: Firstly by adding a "dymanic" eventhander as needed
    >: (depending on the amount of items returned)
    >:
    >: "AddHandler SelectButton.Command, AddressOf

    ProcessLogo"
    >: (see in code)
    >:
    >:
    >: Here it should link the button action to the
    >: subroutine "ProcessLogo". So if the button has a

    command
    >: (event) it should be handled by the subroutine.
    >:
    >: But it isn't. It's pretty to check, just put the

    routine
    >: in debug mode and put a break on the first best code

    line
    >: in the subroutine, then you will see the routine is

    never
    >: called. It is as if the handler is ignored.
    >:
    >: Any Ideas ?
    >:
    >: Thanks in advance.
    >: Harold.
    >: >-----Original Message-----
    >: >How are you "calling them", and how do you know they

    are
    >: now being called?
    >: >
    >: >Cheers
    >: >Ken
    >: >
    >: >
    >: >"Harold" <> wrote in message
    >: >news:12e501c385b2$92b51640$...
    >: >: This is just me testing, however the two top sub's

    are
    >: >: never called........why ?.
    >: >:
    >: >: Where is the error of my ways?
    >: >:
    >: >: Sub ProcessLogo(ByVal sender As Object, ByVal e As
    >: >: CommandEventArgs)
    >: >: Dim Test As Object = e.CommandArgument
    >: >: End Sub
    >: >:
    >: >: Sub ProcessLogo_Click(ByVal sender As Object, ByVal

    e
    >: As
    >: >: System.EventArgs)
    >: >: Dim Test As Object = CType(sender,
    >: >: Button).CommandName
    >: >: End Sub
    >: >:
    >: >: Function BuildLogoTable()
    >: >: '// Get logo definitions and put them in the
    >: table
    >: >: Dim ThisPage As String = "AddCompany"
    >: >: Dim Language As String = Session.Contents
    >: ("LLC")
    >: >: Try
    >: >: Dim PreviewFilePointer As String = ""
    >: >: Dim BuildLogoCommand As SqlCommand
    >: >: Dim BuildLogoReader As SqlDataReader
    >: >: Dim BuildLogoConnection As

    SqlConnection =
    >: >: New SqlConnection(ConfigurationSettings.AppSettings
    >: >: ("Publimation_Authorisation"))
    >: >: BuildLogoCommand = New SqlCommand
    >: >: ("GetImageDataByCatagory", BuildLogoConnection)
    >: >: BuildLogoCommand.CommandType =
    >: >: CommandType.StoredProcedure
    >: >: BuildLogoCommand.Parameters.Add
    >: ("@projectid",
    >: >: SqlDbType.Int, 4).Value = Session.Contents("PID")
    >: >: BuildLogoCommand.Parameters.Add
    >: >: ("@imagecatagory", SqlDbType.Int, 4).Value = 1
    >: >: BuildLogoConnection.Open()
    >: >: BuildLogoReader =
    >: >: BuildLogoCommand.ExecuteReader
    >: >: Dim LogoRow As New TableRow()
    >: >: Dim LogoSelectRow As New TableRow()
    >: >: While BuildLogoReader.Read
    >: >: Dim LogoID As Integer =
    >: >: BuildLogoReader.GetInt32(0)
    >: >: Dim LogoImage As String =
    >: >: BuildLogoReader.GetString(8) &
    >: BuildLogoReader.GetString
    >: >: (4) & "." & BuildLogoReader.GetString(7)
    >: >: Dim LogoLocation As String =
    >: >: ConfigurationSettings.AppSettings

    ("ProjectVirtualRoot")
    >: >: & "/domains/" & Session.Contents("PSN") & Trim

    (Replace
    >: >: (LogoImage, "\", "/"))
    >: >: Dim LogoCell As New TableCell()
    >: >: Dim LogoSelectCell As New TableCell

    ()
    >: >: Dim SelectButton As New LinkButton()
    >: >: SelectButton.Text =
    >: >: GetLanguageArray.GetText(ThisPage, Language,
    >: >: LanguageArray, "Select")
    >: >: SelectButton.CommandArgument =

    LogoID
    >: >: AddHandler SelectButton.Command,
    >: >: AddressOf ProcessLogo
    >: >: AddHandler SelectButton.Click,
    >: AddressOf
    >: >: ProcessLogo_Click
    >: >: LogoCell.Text = "<img src=""" &
    >: >: LogoLocation & """>"
    >: >: LogoSelectCell.Controls.Add
    >: (SelectButton)
    >: >: LogoRow.Cells.Add(LogoCell)
    >: >: LogoSelectRow.Cells.Add

    (LogoSelectCell)
    >: >: End While
    >: >: TableLogo.Rows.Add(LogoRow)
    >: >: TableLogo.Rows.Add(LogoSelectRow)
    >: >: BuildLogoReader.Close()
    >: >: BuildLogoConnection.Close()
    >: >: Catch x As Exception
    >: >: ErrorLogger.ErrorManager
    >: >: ("BuildCompanyLogoTableError", x)
    >: >: End Try
    >: >: End Function
    >: >
    >: >
    >: >.
    >: >
    >
    >
    >.
    >
     
    Harold, Sep 28, 2003
    #5
  6. Harold

    MSFT Guest

    Hi Harold,

    Did you call the BuildLogoTable() in form_load? If not, there will be such
    a problem.

    Luke
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    MSFT, Sep 29, 2003
    #6
  7. Harold

    MSFT Guest

    Hi Harold,

    Did you also declare the LinkButton as pubic variant out of the method?
    Following are the code I used to test, and they seems to work well:

    Dim lb As New LinkButton
    Dim bb As New Button

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here


    lb.Text = "dddd"

    Table1.Rows(0).Cells(1).Controls.Add(lb)


    AddHandler lb.Click, AddressOf ProcessLogo_Click



    End Sub


    Public Sub ProcessLogo_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs)

    Response.Write("dddddd")
    End Sub


    Luke
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    MSFT, Sep 30, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Francis Ardi
    Replies:
    3
    Views:
    440
    Sudsy
    Jul 10, 2003
  2. Horace Nunley

    why why why does function not work

    Horace Nunley, Sep 27, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    461
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Sep 27, 2006
  3. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    909
    Mark Rae
    Dec 21, 2006
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,992
    Smokey Grindel
    Dec 2, 2006
  5. Skybuck Flying
    Replies:
    16
    Views:
    679
    tragomaskhalos
    Aug 25, 2007
Loading...

Share This Page