作者 主題: c#.net FormView InsertItemTemplate Button disabled  (閱讀 8979 次)

0 會員 與 1 訪客 正在閱讀本文。

mbrod

  • 憂鬱的高中生
  • ***
  • 文章數: 174
    • 檢視個人資料
各位先進您好:

           請問在c#.net環境中
   
           在FormView InsertItemTemplate 新增Button

          當button submit後要如何才能讓button disabled反白以防止連續按?

            謝謝


洋蔥叔叔

  • 區域板主
  • 鑽研的研究生
  • *****
  • 文章數: 830
    • 檢視個人資料
    • 洋蔥叔叔的隨意漫談電腦、網路、.NET、軟體本地化、雜七雜八
Re: c#.net FormView InsertItemTemplate Button disabled
« 回覆 #1 於: 2011-06-30 12:55 »
應該是要在 javascript 做,e.g:

代碼: [選擇]
    <script language="javascript">
        function disableButton(btn) {
            btn.disabled = true;
        }
    </script>

<asp:Button ID="Button1" runat="server" CommandName="Insert" Text="Button" OnClientClick="disableButton(this)" />


mbrod

  • 憂鬱的高中生
  • ***
  • 文章數: 174
    • 檢視個人資料
Re: c#.net FormView InsertItemTemplate Button disabled
« 回覆 #2 於: 2011-06-30 15:17 »
應該是要在 javascript 做,e.g:

代碼: [選擇]
    <script language="javascript">
        function disableButton(btn) {
            btn.disabled = true;
        }
    </script>

<asp:Button ID="Button1" runat="server" CommandName="Insert" Text="Button" OnClientClick="disableButton(this)" />


我用了 FormView1.FindControl("Button1").Visible=false;
會將整個button隱藏
若只是要反白呢?

洋蔥叔叔

  • 區域板主
  • 鑽研的研究生
  • *****
  • 文章數: 830
    • 檢視個人資料
    • 洋蔥叔叔的隨意漫談電腦、網路、.NET、軟體本地化、雜七雜八
Re: c#.net FormView InsertItemTemplate Button disabled
« 回覆 #3 於: 2011-06-30 15:51 »
你要 Sever Side 做的話可以用 Enabled=false
代碼: [選擇]
FormView1.FindControl("Button1").Enabled=false;

mbrod

  • 憂鬱的高中生
  • ***
  • 文章數: 174
    • 檢視個人資料
Re: c#.net FormView InsertItemTemplate Button disabled
« 回覆 #4 於: 2011-06-30 17:35 »
你要 Sever Side 做的話可以用 Enabled=false
代碼: [選擇]
FormView1.FindControl("Button1").Enabled=false;

您好:
還是您的方法比較好用
   <script language="javascript">
        function disableButton(btn) {
            btn.disabled = true;
        }
    </script>

<asp:Button ID="Button1" runat="server" CommandName="Insert" Text="Button" OnClientClick="disableButton(this

謝謝