This is a migrated thread and some comments may be shown as answers.

Display popup from code behind

2 Answers 117 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Holly
Top achievements
Rank 1
Holly asked on 01 Jul 2009, 12:57 PM
Hi,
Is it possible to trigger the popup of date or time selectors to pop-up from the codebehind?
Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 01 Jul 2009, 01:51 PM
Hi Holly,

I tried following approach for showing popup from code behind. Give a try with this.

ASPX:
 
<telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server"
</telerik:RadDateTimePicker> 

C#:
 
protected void Button1_Click(object sender, EventArgs e) 
    String script = "<script language='javascript' type='text/javascript'>Sys.Application.add_load(ShowPopup);</script>"
    ClientScript.RegisterStartupScript(this.GetType(), "ShowPopup", script);   

JavaScript:
 
<script type="text/javascript"
function ShowPopup() 
    var datetimepicker = $find("<%= RadDateTimePicker1.ClientID %>"); 
    datetimepicker.showPopup();  // Show Calendar popup 
    //datetimepicker.showTimePopup(); // Show time popup 
</script> 

Thanks,
Shinu
0
Holly
Top achievements
Rank 1
answered on 02 Jul 2009, 09:22 AM
Hi Shinu,
Thanks for your help.
It now sort of works, except that when the javascript is displayed the popup is displayed, then instantly hidden again. I presume this is something to do with the postbacks resetting the control but I'm unsure how to fix it.
Tags
Calendar
Asked by
Holly
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Holly
Top achievements
Rank 1
Share this question
or