【发布时间】:2014-10-18 21:08:44
【问题描述】:
我知道创建的按钮都是提交类型。所以我使用按钮类的.CommandName 属性使其不是suggested here 的提交类型我制作按钮的方式是这样的
ePanel.Controls.Add(New Button With {.CssClass = "button enlargeMapButton",
.Text = "Enlarge Map", .CommandName = "Sort"})
在检查元素后,我在 DOM 中得到了这个
单击按钮实际上会尝试提交表单并重新加载表单部分。我在这里遗漏了什么吗?
编辑
全套代码。相关部分。
Private Shared Function AddPropertyMap(ByVal currentTable As Table, ByRef
propertyMapValue As Boolean) As Table
***Stuff createing other thing cells rows table etc***
Dim MapControl As New Panel() With {.ID = "MapControl", .Visible = True, .CssClass = "MapBlock"}
Dim ePanel As New Panel
ePanel.Controls.Add(New Button With {.CssClass = "button enlargeMapButton", .Text = "Enlarge Map", .CommandName = "Sort"})
MapControl.Controls.Add(ePanel)
**creating Other control/things to other cell**
Dim tCell3 As New TableCell()
tCell3.Controls.Add(MapControl)
Dim tRow As New TableRow()
tRow.Cells.Add(tCell1)
tRow.Cells.Add(tCell2)
tRow.Cells.Add(tCell3)
Dim newTable As New Table
newTable.Rows.Add(tRow)
Return newTable
【问题讨论】:
-
您能否提供在 aspx 文件中声明按钮的位置的完整代码?我认为这将有助于确定问题所在......
-
它实际上是在一个 Visual Basic 项目的 .vb 文件中制作的。这是我正在维护/用于“构建”表单的旧代码
-
这可能会有所帮助 - stackoverflow.com/questions/683746/… - 即将 OnClientClick 属性/属性设置为
"return false"。 -
我建议你使用asp.net标签。
-
您希望您的按钮仍然执行回发,但不作为表单提交按钮,还是希望它保持“仅限客户端”按钮?