none
asp.net button 同時觸發 jquery function 和 C#onClick事件 RRS feed

  • 問題

  • HTML

    <asp:Button runat="server" ID="btnAddEvent" CssClass="btn btn-info" Text="送出" OnClick="btnAddEvent_Click" />

    C#

    protected void btnAddEvent_Click(object sender, EventArgs e) { Events newEvent = new Events(); newEvent.SocietyId = "A00"; newEvent.Id = newEvent.SocietyId + "EV" + EventService.getEventId(newEvent.SocietyId); newEvent.Title = this.Request.Form["eventTitle"]; newEvent.Content = this.Request.Form["eventContent"]; string eventTime = this.Request.Form["eventTime"]; if(eventTime.Length == 10) { newEvent.StartTime = Convert.ToDateTime(eventTime); newEvent.EndTime = Convert.ToDateTime(eventTime); } else { newEvent.StartTime = Convert.ToDateTime(eventTime.Substring(0,10)); newEvent.EndTime = Convert.ToDateTime(eventTime.Substring(13,10)); } newEvent.Location = this.Request.Form["eventLocation"]; EventService.AddEvent(newEvent); }


    jQuery

    $('#<%= btnAddEvent.ClientID %>').click(function (e) { addEvent(); }) function addEvent() { $("#createEventModal").modal('hide'); calendar.fullCalendar('renderEvent', { title: $('#eventTitle').val(), start: $('#eventTime').val(), allDay: true, editabele:true, }, true); $('#eventTitle').val(''); $('#eventContent').val(''); $('#eventTime').val(''); $('#eventLocation').val(''); }

    這是fullcalendar的範例,想在按鈕按下的時候,同時將資料存進資料庫,還有在fullcalendar上顯示event,可是按了前端會顯示,C#卻無法取的資料。

    2015年4月16日 下午 04:45

所有回覆