popup calendar when using Masterpage

G

Guest

i am using visual studio 2005 and I am trying to create a popup calender so
when a user click on a image on the main form, a calender will then popup,
the user will select a date and the date will then be passed back to the main
form and populate a textbox. it works fine. but when i used master page for
all my pages and i put the textbox inside the content , the calender pops up
but when i select the date nothing happens .. the textbox was not populated
with the selected date from the calender and the window was not closed.

here's code which popups the calendar:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentColumn"
Runat="server">
<div>

<A
onclick="window.open('Calendar.aspx?textbox=txtDate','cal','width=300,height=300,left=470,top=300')"
href="javascript:;"><asp:textbox id=txtDate runat="server"
ForeColor="Black" Width="88px"></asp:textbox>
<IMG src="images/SmallCalendar.gif" border="0"></A></div>
</asp:Content>

and here's the code for the calendar selection change:

Private Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Calendar1.SelectionChanged
Dim strjscript As String = "<script language=""javascript"">"
strjscript &= "window.opener." & _
HttpContext.Current.Request.QueryString("formname") & ".value
= '" & _
Calendar1.SelectedDate & "';window.close();"
strjscript = strjscript & "</scr" & "ipt>"
Literal1.Text = strjscript
End Sub
 
P

Peter Blum

I'm not sure this has anything to do with ASP.NET 2.0. You are saying that
the window containing the ASP.NET calendar does not post back or if it does,
whatever is passed back to that window isn't used by the browser. (The
browser doesn't know about ASP.NET. It just runs HTML and scripts.)
I recommend:
1. Using the debugger to confirm that your server side code is being
executed correctly.
2. Viewing the HTML output to that window. (Right click on the window and
select View Source) Determine what the HTML is and look for errors.

There are many third party date pickers available. Some are free. Some use a
popup that doesn't require a separate window which makes it faster than the
ASP.NET calendar (no post backs) and doesn't fail when there is a popup
blocker. It may be easier to use one. In fact, ASP.NET has a rich variety of
third party controls for most situations. You can find them at www.asp.net
Control Gallery, www.123aspx.com, and www.411asp.net. Mine is "Peter's Date
Package" (http://www.peterblum.com/datecontrols/home.aspx).

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
G

Guest

Hi Peter,
Nothing wrong in my server side code ... it works properly. I tried it
without using the master page .. and it worked fine. This problem just occurs
when i use master page. so any help or suggestion will be greatly appreciated
 
S

Shawn

Hello Ali,

I have notice when using master pages and other container controls that
the runtime engine seems to change the names of the controls and adds
the '$' Character to them. You might want to view the rendered HTML
source sent to the browser and see if this is the case. Unfortunately,
I am not sure if there is anything to be done about it.
 
G

Guest

Thanx Shawn. My hat's off for you. That was the reason of my problem. I did
the change and it worked. Thanx again
 

mos

Joined
Apr 21, 2007
Messages
1
Reaction score
0
solution to popupcalendar / masterpage problem

add the onclick attribute at code behind like this:

ImageButton1.Attributes.Add("onclick", "javascript:eek:penCalendar('" + textbox1.ClientID + "')");

and modify the js script to:

function openCalendar(textbox)
{
window.open('PopupCalendar.aspx?textbox='+textbox+'','cal','width=220,height=200,left=270,top=180')
}
 
Joined
May 28, 2007
Messages
1
Reaction score
0
hi all, i m trying the popoup calendar in master page , i tried the same as sugested by guys here but it does not work.. can any one send the entire code to helpme understand the concept.and syntax. i new to coding and already pondered for a week on this issue. its urgent..
plz help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top