gpt4 book ai didi

javascript - 在 vb.net 中获取确认值

转载 作者:行者123 更新时间:2023-11-30 05:53:41 26 4
gpt4 key购买 nike

我在 Repeater 中有一个隐藏的 asp 按钮。在后面的 VB.NET 代码中,我使用 Rerpeater_ItemCommand 获取 Repeater 中的点击事件。检查用户是否已经在录制项目。如果是,并且他想开始一个新的,应该会出现一个确认框,询问“你确定吗?”如何从确认访问点击值?

<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>

<div class="tile user_view user_<%# Eval("employeeName") %>">
<div class="tilesheight"></div>
<div class="element">

<asp:Button ID="Button1" CssClass="hiddenbutton" runat="server" />


Index:
<asp:Label ID="Label1" runat="server"
Text='<%# Eval("index") %>' /><br />
<hr class="hr" />

customer:
<asp:Label ID="CustomerLabel" runat="server"
Text='<%# Eval("customer") %>' /><br />
<hr class ="hr" />
order:
<asp:Label ID="OrderNoLabel" runat="server"
Text='<%# Eval("orderNo") %>' /><br />
<asp:Label ID="DescriptionLabel" runat="server"
Text='<%# Eval("description") %>' /><br />
<hr class="hr" />

</div>
</div>
</ItemTemplate>
</asp:Repeater>

代码隐藏:

If empRecs.Contains(projects.Item(index.Text).employeeID) Then

'Catch index of recording order
i = empRecs.IndexOf(projects.Item(index.Text).employeeID)


Page.ClientScript.RegisterStartupScript(Me.GetType, "confirm", "confirm('Order " & empRecs(i + 2) & " already recording. Would you like to start a new one?')",True)

'If users clicks ok insertData()

End If

其他解决方案使用点击事件和隐藏字段。但问题是,我不希望每次单击按钮时都出现确认框。仅当 empRecs 包含员工时。

感谢帮助

最佳答案

你可以试试把下面的

Proteted Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
''not sure where you get the empRecs and projects from
''but you can get the data item bound to this iteration of the repeater thus
''if you need it for the empRecs/projects bit
Dim data = DirectCast(e.Item.DataItem, TypeOfBoundData)
''grab the button like this
dim but as Button = e.Item.FindControl("Button1") ''cant remember if that will work, if not try the next line
''dim but = DirectCast(e.Item.Findcontrol("Button1"), Button)
''then do your bit
If empRecs.Contains(projects.Item(index.Text).employeeID) Then
AddHandler but.Click, AddressOf Button1_Click
but.OnClientClick = "return confirm('Order " & empRecs(i + 2) & " already recording. Would you like to start a new one?')"
End If
End If
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
insertData()
End Sub

第一个

关于javascript - 在 vb.net 中获取确认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13267598/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com