programmatically show calendarextender

Last post 10-06-2009 7:32 AM by lord_dante_iii. 11 replies.

Sort Posts:

  • programmatically show calendarextender

    10-31-2008, 11:03 AM
    • Participant
      770 point Participant
    • Pak514
    • Member since 12-01-2007, 1:56 AM
    • Posts 300

    I have a dynamic calendar extender & dynamic textbox being generated and an image button to show the calendar extender. I've extended the textbox to add an OnClick event, but I wanted to know how I could show a calendar extender on the server side if possible. Thanks.

  • Re: programmatically show calendarextender

    10-31-2008, 11:35 AM
    • All-Star
      21,117 point All-Star
    • bullpit
    • Member since 06-29-2006, 3:59 PM
    • Posts 4,665

    What I get from your post is that you want to add a  CalendarExtended to a dynamic textbox.  

    TextBox txtDateWorkedOn = new TextBox();
    txtDateWorkedOn.Text = DateTime.Now.ToShortDateString();
    txtDateWorkedOn.ID = "txtDateWorkedOn_" + idNumber.ToString();
    ImageButton calendarImage = new ImageButton();
    calendarImage.CssClass = "imagebutton";
    calendarImage.ImageUrl = "images/icon-calendar.gif";
    calendarImage.ID = "calendarImage_" + idNumber.ToString();
    AjaxControlToolkit.CalendarExtender calendarExtender = new AjaxControlToolkit.CalendarExtender();
    calendarExtender.TargetControlID = txtDateWorkedOn.ID;
    calendarExtender.PopupButtonID = calendarImage.ID;
     
  • Re: programmatically show calendarextender

    10-31-2008, 11:53 AM
    • Participant
      770 point Participant
    • Pak514
    • Member since 12-01-2007, 1:56 AM
    • Posts 300
    I want to know if its possible to show the calendar extender on the server side.
  • Re: programmatically show calendarextender

    10-31-2008, 11:56 AM
    • All-Star
      21,117 point All-Star
    • bullpit
    • Member since 06-29-2006, 3:59 PM
    • Posts 4,665

    What are you exactly trying to do? CalendarExtended will be displayed wherever the application is viewed in browser, even on the server.

  • Re: programmatically show calendarextender

    10-31-2008, 11:59 AM
    • Participant
      770 point Participant
    • Pak514
    • Member since 12-01-2007, 1:56 AM
    • Posts 300

    I already have it setup to display the control on image click via popupbuttonid. The question is I have setup a textbox with a server side OnClick event and how would I display or render the calendar control onclick?

  • Re: programmatically show calendarextender

    10-31-2008, 12:06 PM
    • All-Star
      21,117 point All-Star
    • bullpit
    • Member since 06-29-2006, 3:59 PM
    • Posts 4,665

    Do you really need an OnClick event to do that?

  • Re: programmatically show calendarextender

    10-31-2008, 12:27 PM
    • Participant
      770 point Participant
    • Pak514
    • Member since 12-01-2007, 1:56 AM
    • Posts 300

    Whether or not I need an onclick event or not is irrelevant.... I'm asking a simple question that needs a simple answer. 

    Is this possible either client or server side. IE: on server side calextender.show() or textbox.attributes.add("onclick","showcalendar()")

  • Re: programmatically show calendarextender

    10-31-2008, 2:08 PM
    Answer
    • All-Star
      21,117 point All-Star
    • bullpit
    • Member since 06-29-2006, 3:59 PM
    • Posts 4,665

    Heres a simple answer. Yes you can. 

    function ShowCalendar() {
        $find('<%=CalendarExtender1.ClientID %>').show();
    }
      
    TextBox1.Attributes.Add("onclick", "javascript:return ShowCalendar();");
     
  • Re: programmatically show calendarextender

    10-31-2008, 2:53 PM
    • Participant
      770 point Participant
    • Pak514
    • Member since 12-01-2007, 1:56 AM
    • Posts 300

    Thanks, that helps. Now I could probably pass the id to the func and it'll work more dynamically.

  • Re: programmatically show calendarextender

    02-12-2009, 2:29 PM
    • Member
      24 point Member
    • dtabraha
    • Member since 01-26-2006, 6:19 PM
    • Posts 7

    For some reason the TargetControlID property doesn't come up for me when I declare the calendar extender.

    Checking the object browser it shows the property buried underneath "Base Types\Extender Control Base" but I can't just use it like you did above:

    calendarExtender.TargetControlID = txtDateWorkedOn.ID;

    Any ideas??

  • Re: programmatically show calendarextender

    02-13-2009, 9:15 AM
    • Participant
      770 point Participant
    • Pak514
    • Member since 12-01-2007, 1:56 AM
    • Posts 300
    You mean in the IDE the intellisense doesn't show it or do I not understand the question?
  • Re: programmatically show calendarextender

    10-06-2009, 7:32 AM

    dtabraha:

    For some reason the TargetControlID property doesn't come up for me when I declare the calendar extender.

    Checking the object browser it shows the property buried underneath "Base Types\Extender Control Base" but I can't just use it like you did above:

    calendarExtender.TargetControlID = txtDateWorkedOn.ID;

    Any ideas??

    Just add reference to System.Web.Extensions and everything will be fine.

Page 1 of 1 (12 items)