问题描述
问候。希望有人能够解开这个Gordian结我已经发现自己被绑定了。
我试图动态地向PlaceHolder添加一个提交按钮。这个
按钮将帮助更新数据库中的特定条目。
按钮被添加为:
Sub LoadIntro()
...动态加载的其他内容:预览
的DB内容后跟一个预填充的表单DB ...
Dim提交为Button = New Button()
AddHandler submit.Click,AddressOf UpdateIntro
submit.id ="提交
submit.Text ="更新简介
content.Controls.Add(提交)
End Sub
并且事件处理程序设置如下:
Sub UpdateIntro(发送者作为对象,e作为EventArgs)
Dim myConn as new
OleDbConnection(ConfigurationSettings.AppSettings(" strConn"))
Dim myCmd as new OleDbCommand(" UPDATE tblIntro SET
[评论] = @ Comment",myConn)
myConn.Open()
myCmd.CommandType = CommandType。文字
myCmd.Parameters.Add(" @ Comment",OleDbType.LongVarWChar).Value =
RepChar(Request.Form(" IntroComment"))
myCmd.ExecuteNonQuery()
myConn.Close()
LoadIntro()
结束子
问题是这不起作用! UpdateIntro sub只是
不会被解雇!!
我把头发拉到这里,因为我还删除了AddHandler
试试这个:
Private Sub UpdateIntro(ByVal sender As Object,ByVal e As EventArgs)
句柄submit.Click
但它也会抛出错误!我知道添加
submit.onClick =" UpdateIntro"也会抛出一个错误,但我只是
不知道还能做什么或尝试什么!
TIA
...... Geshel
-
**************************** ********************** *********************
*我的回复是一个自动监控的垃圾邮件蜜罐。除非你想被SpamCop列入黑名单,否则不要使用*
*它。请以我的姓氏dot org回复我的*
*名字。 *
***************************************** ********* *********************
* a ??我认为我们都是无神论者。我只相信比你少一个* b / b $ b *上帝。当你明白为什么你解雇所有其他*
*可能的神灵时,你就会理解为什么我会解雇你的。 *
* - Stephen F. Roberts *
************************** ************************ *********************
* a ??任何相信智能设计(一个创造主义?)的人只是*
*作为一个无知,非理性和不受过良好教育的人如果相信*
*世界是一个平盘,太阳圈绕地球或*
*那里真的有一个牙仙。达尔文主义拥有压倒性的*
*证据基础,可以进行测试和复制。 *
* *
* a ??智能设计,另一方面,根本没有证据;不是*
*一个单一切碎的可测试证明。因此,智能设计是*
*宗教神话,并且没有任何权利在我们的*
*科学课堂.a ?? - 99.99 +%的科学家*
********************************* *************** *********************
Mignon McLaughlin曾经说过a ??一个女性[女人]是一个女人,因为男人痴迷于性生活。不幸的是,既然如此真实,那么这对于女性来说是非常罕见的,这就意味着需要一个非凡的女人跟上一个普通男人。
* ************************************************* ********************
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. *
************************************************** *********************
* a??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.a?? *
* - Stephen F. Roberts *
************************************************** *********************
* a??Anyone who believes in Intelligent Design (a??creationisma??) 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. *
* *
* a??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.a?? - 99.99+% of Scientists *
************************************************** *********************
Mignon McLaughlin once said that a??A nymphomaniac is a woman [who is] as
obsessed with sex as the average man.a?? Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
************************************************** *********************
推荐答案
为自己节省一大堆心痛,甚至不尝试添加按钮
动态
- 根据需要将其Visible属性设置为true或false ...
Save yourself a whole load of heartache and don''t even try to add the button
dynamically - just set its Visible property to true or false as required...
这篇关于以编程方式添加按钮 - 非功能性!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!