Commodus2 Posted March 5, 2003 Posted March 5, 2003 Hi. I want to use a calendar in a popup window. showModalDialog with javascript does niot work because you cannot use links in a showModalDialog. i cannot manipulate the field that must contain a date from within the popup because i wat to use this popup several times on several different places. how can i do this? I have Visual Studio .net and i am fairly new to it. thanks Quote
ucelik Posted March 5, 2003 Posted March 5, 2003 U want to put this code on a some kind of event to popup the page that contains the calendar control. in this code my form name = Calendar.aspx =========================================== javascript:calendar_window=window.open('Calendar.aspx?formName=formName.NameofTheControlOnTheForm','calendar_window','width=290,height=200');calendar_window.focus() ========================================== above code will enable you to open the form that contains the calendar control as a popup form. then include this code to in the calendar's event to populate the field ============================================ private void cldrInventory_SelectionChanged(object sender, System.EventArgs e) { StringBuilder strBlJscript = new StringBuilder(); strBlJscript.Append("<script language=\"javascript\">"); strBlJscript.Append("window.opener."); strBlJscript.Append(HttpContext.Current.Request.QueryString.Get("formname")); strBlJscript.Append(".value = '"); strBlJscript.Append(cldrInventory.SelectedDate.ToShortDateString()); strBlJscript.Append("';window.close();"); strBlJscript.Append("</script>"); //strBlJscript.Append(">"); //this done b/c of a Tool bug Literal1.Text = strBlJscript.ToString(); } ============================================ this might seem little bit confusing but it is easy actually. Hope this helps... u have to include <asp:literal id="Literal1" runat="server"></asp:literal> in the calendar.aspx page too. Sorry...:-\ Quote
Commodus2 Posted March 6, 2003 Author Posted March 6, 2003 Ok thanks! I was thinking of doing something like that... but didn't figure it out just yet. thanks for that! it works. although I'm still messing with the literal. I replaced this with a Page.RegisterStartupScript("start",strBlJscript.ToString()); it works also :) in this way you don't need a literal. at least.... i think i have this right thanks again for you advice! Quote
rvermeulen Posted April 3, 2003 Posted April 3, 2003 I've created a popup control using the sample given. I'm able to open the popup window with the javascript and I'm able to set the Literal string once the Calendar is selected a day. I've programmed the SelectionChanged to do this. However, once that event is triggered and the javascript created for the literal string, the calendar popup does not close and the parent form is not being populated. Here is my parent form call: <td><input id="button1" type="button" value="calendar" onclick="javascript:calendar_window=window.open('test.aspx?formname=form1&textname=txt1','calendar_window','width=260,height=220');calendar_window.focus()"> And this is the event I have programmed in the Popup Calendar: Private Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged Dim strjscript As String = "<script language=""javascript"">" strjscript = strjscript & "window.opener." & HttpContext.Current.Request.QueryString("formname") & ".elements[" & HttpContext.Current.Request.QueryString("textname") & "].value = '" & Calendar1.SelectedDate & "';window.close();" strjscript = strjscript & "</script>" & ">" Literal1.Text = strjscript End Sub Am I doing something wrong that I don't see ? Quote
Commodus2 Posted April 4, 2003 Author Posted April 4, 2003 (edited) The script is placed at the same level when the page is rendering. So it is seen as text and not executed. The thing I did, was to put in a js function in the SelectionChanged and then call it onClick of the button // This is the ok button. put it in the form and this code in the event function btnOk.Attributes.Add("onClick","doIt()"); hope this solves anything Edited April 4, 2003 by Commodus2 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.