[問題] asp.net的onclientclick是否可以取得js …

看板Web_Design作者 (Lucifer)時間14年前 (2010/04/08 21:51), 編輯推噓1(104)
留言5則, 4人參與, 最新討論串1/2 (看更多)
as title, 我有個asp.net的button, 請問有辦法在*.aspx.cs裡取得confrim的return嗎? thanks a lot. 貼錯code(遮臉) *.aspx端 <script type="text/javascript"> function val() { if(confirm("are you sure")) { return true; }else { return false; } } </script> <asp:Button ID="ok" runat="server" Text="ok" OnClientClick="return val()" /> 我想問的是如何在觸發val()後在*.aspx.cs端取值? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.118.33.103

04/08 22:29, , 1F
印象中在OnClientClick寫return confirm(...就行了
04/08 22:29, 1F
※ 編輯: zeat 來自: 122.118.33.103 (04/08 22:41)

04/08 22:41, , 2F
確定→server,取消→停在client!但button沒有server事件
04/08 22:41, 2F
那請問一下, 因為我是希望在delete資料之前跳出confirm提醒user, 依照您的講法 是不是確定才會繼續執行server端(*.aspx.cs)的程式刪除資料, 也就是將code簡寫成 <asp:Button ID="del" runat="server" Text="delete" OnClientClick="return confirm("are you sure delete the data?")" /> 也可以達到我要的目的嗎? ※ 編輯: zeat 來自: 122.118.33.103 (04/08 23:09)

04/09 00:20, , 3F
可以
04/09 00:20, 3F

04/09 07:19, , 4F
thanks a lot.
04/09 07:19, 4F

04/13 21:37, , 5F
提供另個地方的解決方案http://tinyurl.com/y72fhar
04/13 21:37, 5F
文章代碼(AID): #1BlTz-dR (Web_Design)
文章代碼(AID): #1BlTz-dR (Web_Design)