Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Q: Why this not work ?

Reply
Thread Tools

Q: Why this not work ?

 
 
Harold
Guest
Posts: n/a
 
      09-28-2003
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( & BuildLogoReader.GetString
(4) & "." & BuildLogoReader.GetString(7)
Dim LogoLocation As String =
ConfigurationSettings.AppSettings("ProjectVirtualR oot")
& "/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
 
Reply With Quote
 
 
 
 
Ken Schaefer
Guest
Posts: n/a
 
      09-28-2003
How are you "calling them", and how do you know they are now being called?

Cheers
Ken


"Harold" <(E-Mail Removed)> wrote in message
news:12e501c385b2$92b51640$(E-Mail Removed)...
: 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( & BuildLogoReader.GetString
: (4) & "." & BuildLogoReader.GetString(7)
: Dim LogoLocation As String =
: ConfigurationSettings.AppSettings("ProjectVirtualR oot")
: & "/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


 
Reply With Quote
 
 
 
 
Harold
Guest
Posts: n/a
 
      09-28-2003
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" <(E-Mail Removed)> wrote in message
>news:12e501c385b2$92b51640$(E-Mail Removed)...
>: 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( &

BuildLogoReader.GetString
>: (4) & "." & BuildLogoReader.GetString(7)
>: Dim LogoLocation As String =
>: ConfigurationSettings.AppSettings("ProjectVirtualR oot")
>: & "/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
>
>
>.
>

 
Reply With Quote
 
Ken Schaefer
Guest
Posts: n/a
 
      09-28-2003
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" <(E-Mail Removed)> wrote in message
news:152301c385ba$e3433670$(E-Mail Removed)...
: 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" <(E-Mail Removed)> wrote in message
: >news:12e501c385b2$92b51640$(E-Mail Removed)...
: >: 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( &
: BuildLogoReader.GetString
: >: (4) & "." & BuildLogoReader.GetString(7)
: >: Dim LogoLocation As String =
: >: ConfigurationSettings.AppSettings("ProjectVirtualR oot")
: >: & "/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
: >
: >
: >.
: >


 
Reply With Quote
 
Harold
Guest
Posts: n/a
 
      09-28-2003
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" <(E-Mail Removed)> wrote in message
>news:152301c385ba$e3433670$(E-Mail Removed)...
>: 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" <(E-Mail Removed)> wrote in message
>: >news:12e501c385b2$92b51640$(E-Mail Removed)...
>: >: 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( &
>: 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
>: >
>: >
>: >.
>: >
>
>
>.
>

 
Reply With Quote
 
MSFT
Guest
Posts: n/a
 
      09-29-2003
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.)

 
Reply With Quote
 
MSFT
Guest
Posts: n/a
 
      09-30-2003
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.)

 
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
Why :: ? Why not : ? Why not . ? <- less clutter ?!? Skybuck Flying C++ 16 08-25-2007 09:48 PM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
why why why does function not work Horace Nunley ASP .Net 1 09-27-2006 09:52 PM
Point and Click Weather Forecasts does not work on all browsers. Why not? Francis Ardi Java 3 07-10-2003 05:26 PM



Advertisments