2012-08-24 2 views
1

동적으로 생성 된 체크리스트 항목이 있습니다. 사용자가 삭제하면 확인 상자가 나타납니다. 내가 어떻게 할 수 있니?체크리스트 항목을 삭제할 때 확인 요청 방법은 무엇입니까?

protected void btndelete_Click(object sender, EventArgs e) 
     { 
      try 
      { 
       string conn = ConfigurationManager.ConnectionStrings["sqlconn"].ConnectionString; 
       SqlConnection con = new SqlConnection(conn); 
       con.Open(); 
      check: 
       if (CheckBoxList1.SelectedItem != null) 
       { 
        foreach (ListItem l in CheckBoxList1.Items) 
        { 
         if (l.Selected) 
         { 
          SqlCommand cmd = new SqlCommand("Drop Table " + l, con); 
          cmd.ExecuteNonQuery(); 
          Label4.ForeColor = Color.Red; 
          Label4.Text = " PaperSet Deleted successfully"; 
          CheckBoxList1.Items.Remove(l); 
          papersetlist.Items.Remove(l); 
          Psetlist.Items.Remove(l); 
          goto check; 
         } 
        } 
       } 
       con.Close(); 

      } 
      catch (System.Exception ex) 
      { 
       MessageBox.Show(ex.Message); 
      } 
     } 

이것은 삭제 버튼 이벤트 코드입니다.

+3

가지고있는 것처럼 뭔가를 작성해야? 지금까지 가지고있는 샘플 코드를 게시 할 수 있습니까? – nemesv

+0

https://developer.mozilla.org/en-US/docs/DOM/window.confirm –

+0

'사용자가 삭제할 때'와 관련이 있지만 실제로는 JavaScript 솔루션 대신 실제 확인 페이지? 사용자의 클릭 수는 같지만 추가 보안 계층입니다. –

답변

2

당신은 당신의 모습을 볼 수 않습니다이

<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
CommandName="Delete" Text="Delete" 
OnClientClick="return confirm('Are you certain you want to delete this item?');"> 
</asp:LinkButton> 
+0

ye - 1? ... –

+0

제 질문에 투표 해주세요 -2 점이 더 많은 질문을하지 못하도록 막고 있습니다 ... –

+0

@rickevans -이 작업을 완료하려면 OnClientClick = "return confirm ('이 항목을 삭제 하시겠습니까?'); " 당신이 내 링크 버튼에했던 것처럼 버튼을 삭제 –

관련 문제