views:

533

answers:

1

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>

Please help. ScriptManager.RegisterStartupScript does nothing.

+1  A: 

Are you expecting an immediate confirm-popup so your next line (If txtRespuesta.Text = False Then) can react to it?

That will not happen! Only when the processing of the code-behind is completed, then something is sent to the browser. So only then can a confirm pop up. And the next postback could react to the changed value.

Hans Kesting
Thank you for answering.Is there any other way to capture txtRespuesta.text immediately.
rockrule