[英]Retrieve value from window.confirm, in code-behind. [VB.net]
我正在做一个项目,在其中创建了一个添加产品的按钮。
当用户单击此按钮时,它将调用一个添加产品的函数,然后浏览我的数据库(CheckProdRef函数),以查看该产品是否具有某些“后续产品”。
如果是这种情况,我希望我的订阅者在弹出框中显示“此产品有后续产品,您想添加吗?”。
然后,根据用户的回答,我应该添加产品还是不添加产品。
但是我有一个亲爱的问题,我似乎无法真正从window.confirm中检索任何有意义的值。
我的代码是这样的:
Protected Sub BTN_EM_TILFØJ_Click(sender As Object, e As EventArgs) Handles BTN_EM_TILFØJ.Click
Dim Lbl As New System.Web.UI.WebControls.Label
Call AddRowTbl(GV_EM, "MAT")
If CheckProdRef(TB_PROD_NR.Text) <> vbNullString Then
Lbl.Text = "<script language='javascript'>" & Environment.NewLine _
& "window.confirm(" & "'" & "There is a followup product, do you wish to add it?" & "'" & ")</script>"
Page.Controls.Add(Lbl)
以下是我不顾一切的检查,看是否是true / false值,不是
If Lbl.Text = "True" Then`
Labtest.Text = "Du trykkede ok"
Else
Labtest.Text = "du trykkede cancel"
End If
and then it goes onxxxxxxxxxxxxx
如果用户单击“是”或“否”,我需要一种注册方法。 我不知道怎样才能将功能添加到按钮,只显示如果有后续产品(OBV)此弹出。
假设您正在使用ajaxcontroltoolkit,则可以执行以下操作:
在您的aspx上添加引用“ popup”的代码块,该代码块将向用户显示消息
<AjaxToolKit:ModalPopupExtender ID="mpeDiscrepancias" <-- ID to be used on code behind runat="server" TargetControlID="NuevaDiscrepanciaBtn" <-- button that will be popping out the message
PopupControlID="DiscrepanciaPanel" <-- control that will be displayed BackgroundCssClass="modalBackground" <-- css class for the modal CancelControlID="CerrarDiscrepanciaBtn"<-- button that will be closing the modal
Enabled="True">
</AjaxToolKit:ModalPopupExtender>
<div id="DiscrepanciaPanel" style="background-color: gray; display: none; max-height: 600px; overflow: auto;max-width:95%">
<table style="text-align:left">
<tr>
<td colspan="2" class="MainTitle">
YOUR MESSAGE
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<br />
<asp:Button ID="GuardarDiscrepanciaBtn" <-- save button runat="server" Text="Guardar" CausesValidation="true" ValidationGroup="Discrepancias" OnClick="GuardarDiscrepanciaBtn_Click" <--on click action />
<asp:Button ID="CerrarDiscrepanciaBtn"<-- close modal button runat="server" Text="Cerrar" CausesValidation="False" />
</td>
</tr>
</table>
</div>
如您所见,这很简单,只需记住它们需要存在的TargetControlID,popupControlID和CancelControlID,才能正常工作,如果要通过操作显示模态,只需添加一个虚拟对象作为targetControlId,我就使用了hiddenfield
<asp:HiddenField ID="NuevaDiscrepanciaBtn" runat="server" />
然后在您的代码后面就很简单了
if(conditions that makes your item has more items)
YourPopUpExtenderId.show()
那么您可以将保存按钮作为常规按钮进行处理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.