开发者

To disable autopostback for Calender Control in ASP.net

Iam trying to use System.Web.UI.WebControls.Calender.

But when I select any date , It post backs automatically. Is there any way to avoid this behavior.

(I dont see the usual property AutoPostback which I set to False to avo开发者_如何学Goid this behavior)

I need the selected date only once user submits the form.

Note- I am using VS2008


I generally avoid avoid the MS calender control because I find it so hard to work with and style. Have you considered something like the jQuery UI date picker, works as you need and far easier to style after too.

http://jqueryui.com/demos/datepicker/#inline


It posts back to set the selected form on the UI. what you can do is use a client side calendar (like jquery ui) or use ajax calendar extender so it will not postback the whole page.


It is possible with MS Calendar. You can customize content of each cell in DayRender event:

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        e.Cell.Text = e.Day.DayNumberText;
    }

You can set e.Cell.Text to be div or span with text and javascript onclick event or link. You can put any HTML there.


  • You cannot disable "Autopostback" of the Standard Calendar control
  • I think you can use CalendarExtender from AjaxToolkit

<asp:TextBox ID="txtCalendarExtender" runat="server"></asp:TextBox> 
<cc3:CalendarExtender ID="Calendar1" PopupButtonID="imgPopup" runat="server" TargetControlID="txtCalendarExtender" Format="dd/MM/yyyy"> 
</cc3:CalendarExtender> 

Remember to add this code at the top of your page:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc3" %>

Remember, there is a forum about this topic where PLBlum says:

The Calendar control included with ASP.NET uses postbacks only. If you added Microsoft ASP.NET AJAX to the page and put the calendar into an UpdatePanel, it can reduce the appearance of postbacks by using callbacks. But it still makes a trip to the server for each click on a date or month.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜