R
Rob Meade
Hi all,
I have a bit of code that programmatically adds some table cells/rows to a
table.
The last cell adds a LinkButton control, I call it like this:
Cell.Controls.Add(deleteRecipientLink(objReader("NotificationID")))
I feed it with an ID from my database table.
The function 'deleteRecipientLink' is as follows:
Private Function deleteRecipientLink(ByVal recipientID As Integer) As
LinkButton
' declare variables
Dim link As LinkButton
' create new instance of linkbutton object
link = New LinkButton
' set link properties
link.ID = "deleteRecipient" & recipientID
link.CssClass = "normalText"
link.Text = "Delete"
link.ToolTip = "Delete"
link.CausesValidation = False
link.CommandArgument = recipientID
link.CommandName = "recipientID"
' add handler
AddHandler link.Click, AddressOf deleteRecipient
' return link object
Return (link)
End Function
The problem I'm having is that whilst the link button is not validating my
form (correct), it is obviously doing a post back, which in my case is now
adding more rows to my data (as if the form had been submitted correctly),
what I want to happen is run a different function when the link button is
clicked. I thought adding the AddHandler would have solved this problem but
having stuffed in some breakpoints it never gets to my deleteRecipient
function - it hits the PageIsPostback and then thats it.
What do I need to do? Change my code for the AddHandler some how, or change
my code in the if its a PostBack? if the latter, how do I determine that it
was the linkbutton that did the postback and not the submit button on my
form?
Thanks in advance for any help.
Regards
Rob
I have a bit of code that programmatically adds some table cells/rows to a
table.
The last cell adds a LinkButton control, I call it like this:
Cell.Controls.Add(deleteRecipientLink(objReader("NotificationID")))
I feed it with an ID from my database table.
The function 'deleteRecipientLink' is as follows:
Private Function deleteRecipientLink(ByVal recipientID As Integer) As
LinkButton
' declare variables
Dim link As LinkButton
' create new instance of linkbutton object
link = New LinkButton
' set link properties
link.ID = "deleteRecipient" & recipientID
link.CssClass = "normalText"
link.Text = "Delete"
link.ToolTip = "Delete"
link.CausesValidation = False
link.CommandArgument = recipientID
link.CommandName = "recipientID"
' add handler
AddHandler link.Click, AddressOf deleteRecipient
' return link object
Return (link)
End Function
The problem I'm having is that whilst the link button is not validating my
form (correct), it is obviously doing a post back, which in my case is now
adding more rows to my data (as if the form had been submitted correctly),
what I want to happen is run a different function when the link button is
clicked. I thought adding the AddHandler would have solved this problem but
having stuffed in some breakpoints it never gets to my deleteRecipient
function - it hits the PageIsPostback and then thats it.
What do I need to do? Change my code for the AddHandler some how, or change
my code in the if its a PostBack? if the latter, how do I determine that it
was the linkbutton that did the postback and not the submit button on my
form?
Thanks in advance for any help.
Regards
Rob