Question

codebehind

Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        Dim ResourceObject As Object


        Dim js As [String] = (vbCr & vbLf & " if(confirm('Esta Seguro de eliminar de la lista')==true)" & vbCr & vbLf & " document.getElementById('" & txtRespuesta.ClientID & "').value='true';" & vbCr & vbLf & " else" & vbCr & vbLf & "  document.getElementById('") + txtRespuesta.ClientID & "').value='false';" & vbCr & vbLf & " "
        ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "Key", js, True)

  If txtRespuesta.Text = "true" Then
         -Action 1
  Else
             -Action 2
  End If

   End Sub

Designer

 <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>

<tr >
        <td  align="center" colspan="2">
          <asp:TextBox ID="txtRespuesta" runat="server" Width="174px" Height="21px"  
                MaxLength="20" style="font-weight: 700"  Font-Names="Verdana" TabIndex="2"></asp:TextBox>   
        </td>
    </tr> 
 <asp:Button ID="btnUpdate" runat="server"   Height="28px" 
                style="font-weight: 700" Text="変更" Width="68px" TabIndex="3" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:Button ID="btnDelete" runat="server" 
  </script>
        </ContentTemplate>
    </asp:UpdatePanel>

S'il vous plaît aider. ScriptManager.RegisterStartupScript ne fait rien.

Était-ce utile?

La solution

Êtes-vous une confirmation-attendent pop-up immédiat si votre ligne suivante (Si txtRespuesta.Text = False Then) peut réagir?

Cela ne se produira pas! Seulement lorsque le traitement du code-behind est terminée, puis quelque chose est envoyé au navigateur. Alors, alors seulement peut confirmer une pop-up. Et la prochaine postback pourrait réagir à la valeur modifiée.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top