N
Neo Geshel
Greetings. Hopefully someone will be able to untie this Gordian Knot I
have found myself bound up in.
I am trying to add a submit button dynamically to a PlaceHolder. This
button will help update a particular entry in a database.
The button is added as thus:
Sub LoadIntro()
...additional content that is dynamically loaded as well: a preview
of the DB contents followed by a form that is pre-filled from the DB...
Dim submit as Button = New Button()
AddHandler submit.Click, AddressOf UpdateIntro
submit.id = "submit"
submit.Text = "Update Intro"
content.Controls.Add(submit)
End Sub
And the event handler is set up like this:
Sub UpdateIntro(sender As Object, e As EventArgs)
Dim myConn as New
OleDbConnection(ConfigurationSettings.AppSettings("strConn"))
Dim myCmd as New OleDbCommand("UPDATE tblIntro SET
[Comment]=@Comment", myConn)
myConn.Open()
myCmd.CommandType = CommandType.Text
myCmd.Parameters.Add("@Comment", OleDbType.LongVarWChar).Value =
RepChar(Request.Form("IntroComment"))
myCmd.ExecuteNonQuery()
myConn.Close()
LoadIntro()
End Sub
The problem is that this doesn't work!!! The UpdateIntro sub simply
doesn't get fired!!
I'm pulling my hair out here, as I have also removed the AddHandler to
try this:
Private Sub UpdateIntro(ByVal sender As Object, ByVal e As EventArgs)
Handles submit.Click
But it also throws an error! I know that adding
submit.onClick="UpdateIntro" will also throw an error, but I simply
don't know what else to do or try!
TIA
...Geshel
--
***********************************************************************
* My reply-to is an automatically monitored spam honeypot. Do not use *
* it unless you want to be blacklisted by SpamCop. Please reply to my *
* first name at my last name dot org. *
***********************************************************************
* “I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours.†*
* - Stephen F. Roberts *
***********************************************************************
* “Anyone who believes in Intelligent Design (“creationismâ€) is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* “Intelligent Design, on the other hand, has no evidence at all;not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms.†- 99.99+% of Scientists *
***********************************************************************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is] as
obsessed with sex as the average man.†Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
***********************************************************************
have found myself bound up in.
I am trying to add a submit button dynamically to a PlaceHolder. This
button will help update a particular entry in a database.
The button is added as thus:
Sub LoadIntro()
...additional content that is dynamically loaded as well: a preview
of the DB contents followed by a form that is pre-filled from the DB...
Dim submit as Button = New Button()
AddHandler submit.Click, AddressOf UpdateIntro
submit.id = "submit"
submit.Text = "Update Intro"
content.Controls.Add(submit)
End Sub
And the event handler is set up like this:
Sub UpdateIntro(sender As Object, e As EventArgs)
Dim myConn as New
OleDbConnection(ConfigurationSettings.AppSettings("strConn"))
Dim myCmd as New OleDbCommand("UPDATE tblIntro SET
[Comment]=@Comment", myConn)
myConn.Open()
myCmd.CommandType = CommandType.Text
myCmd.Parameters.Add("@Comment", OleDbType.LongVarWChar).Value =
RepChar(Request.Form("IntroComment"))
myCmd.ExecuteNonQuery()
myConn.Close()
LoadIntro()
End Sub
The problem is that this doesn't work!!! The UpdateIntro sub simply
doesn't get fired!!
I'm pulling my hair out here, as I have also removed the AddHandler to
try this:
Private Sub UpdateIntro(ByVal sender As Object, ByVal e As EventArgs)
Handles submit.Click
But it also throws an error! I know that adding
submit.onClick="UpdateIntro" will also throw an error, but I simply
don't know what else to do or try!
TIA
...Geshel
--
***********************************************************************
* My reply-to is an automatically monitored spam honeypot. Do not use *
* it unless you want to be blacklisted by SpamCop. Please reply to my *
* first name at my last name dot org. *
***********************************************************************
* “I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours.†*
* - Stephen F. Roberts *
***********************************************************************
* “Anyone who believes in Intelligent Design (“creationismâ€) is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* “Intelligent Design, on the other hand, has no evidence at all;not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms.†- 99.99+% of Scientists *
***********************************************************************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is] as
obsessed with sex as the average man.†Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
***********************************************************************