TOP

[ASP.NET, jQuery] ASP.Net使用jQuery日歷選擇器

<head>
  <script>
      $(function() {          
        $("input[id*=tbStartTime]").datepicker({ showOn: "both", buttonImage: "../images/gesplus/calendar.gif", buttonImageOnly: true, dateFormat: "yy/mm/dd" });
      });
  </script>

  <style>
//調整圖片位置
    .ui-datepicker-trigger { margin-left:5px; margin-top: 5px; margin-bottom: -6px; }
  </style>
</head>


<asp:TextBox ID="tbStartTime" runat="server" Columns="10"></asp:TextBox>

參考資料:
http://blog.xuite.net/tolarku/blog/213867131-%5BAsp.net%5D+%E9%81%B8%E6%93%87%E6%97%A5%E6%9C%9F+Calendar+%E4%BD%BF%E7%94%A8+jQueryUI+%E7%9A%84+DatePicker

http://www.fbloggs.com/2009/04/16/how-to-style-the-button-image-in-jquery-datehandler-ui/

http://jqueryui.com/datepicker/#localization

http://blog.wu-boy.com/2008/04/jquery%E7%AD%86%E8%A8%98-%E5%A5%BD%E7%94%A8%E7%9A%84%E6%97%A5%E6%9C%9F%E5%87%BD%E5%BC%8F/


script取得ID的方式
一、 
$(".date-picker").datepicker()

二、

$("#<%= txtEventDate.ClientID %>").datepicker()

三、
$("input[id*=txtEventDate]").datepicker()

參考資料:
http://stackoverflow.com/questions/5115067/jquery-datepicker-not-working-in-asp-net-page

TOP

[ASP.NET]Repeater使用CheckBox的OnCheckedChanged

使用者需求:在Repeater內使用CheckBox並且勾選時立即變更資料庫狀態。
<table>
     <asp:repeater id="ContentRepeater" runat="server">
           <ItemTemplate>
                   <tr>
                        <td>
                               <asp:Literal ID="ltContentId" runat="server"
                               Text='<%# DataBinder.Eval(Container, "DataItem.ContentId") %>'>
                               </asp:Literal>
                        </td>
                       <TD>
                              <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true"                                                  OnCheckedChanged='cbCoaching_OnCheckedChanged'/>
                       </td>
                   </tr>
           </ItemTemplate>
      </asp:repeater>
</table>


    Protected Sub cbCoaching_OnCheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
         '取得在repeater內的那一欄資料。
        Dim chk As CheckBox = DirectCast(sender, CheckBox)
        Dim item As RepeaterItem = DirectCast(chk.NamingContainer, RepeaterItem)
        Dim ltContentId As Literal = DirectCast(item.FindControl("ltContentId"), Literal)
         response.write ("ltContentId =" &ltContentId  & "<BR>")
    End Sub

參考資料:
http://stackoverflow.com/questions/6997948/handling-the-checkedchanged-event-of-inner-repeater-checkbox-control-in-asp-net
http://stackoverflow.com/questions/25308247/how-to-get-the-repeater-item-in-a-checkbox-checkedchanged-event