Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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...:-\

Posted

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!

  • 4 weeks later...
Posted

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 ?

Posted (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 by Commodus2

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...