Q: Why this not work ?

H

Harold

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
 
K

Ken Schaefer

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

Cheers
Ken


: 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
 
H

Harold

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.
 
K

Ken Schaefer

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


: 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
: >
: >
: >: >: 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
: >
: >
: >.
: >
 
H

Harold

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
 
M

MSFT

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.)
 
M

MSFT

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.)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top