Calender Pop Up and master Page Problem
-
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 is my code Default Page/Parent Window/ function GetDate(CtrlName) { ChildWindow = window.open('Calendar.aspx?FormName=' + document.forms[0].name + '&CtrlName=' + CtrlName, "PopUpCalendar", "width=270,height=300,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no"); } [Start Date](javascript:GetDate('txtStartDate'))
Code for the Calendar Page/Child Page/ function ReturnDate() { window.opener.document.forms["<%= strFormName %>"].elements["<%=strCtrlName %>"].value = "<%= strSelectedDate %>"; window.close(); } function Close() { window.close(); } Public strFormName As String Public strCtrlName As String Public strSelectedDate As String Sub Page_Load(Sender As Object, E As EventArgs) If Not IsPostBack Then myCalendar.SelectedDate = System.DateTime.Now() End If strSelectedDate = myCalendar.SelectedDate.ToString("dd/MM/yyyy") strFormName = Request.QueryString("FormName") strCtrlName = Request.QueryString("CtrlName") End Sub Sub myCalendar_SelectionChanged(sender As Object, e As EventArgs) strSelectedDate = myCalendar.SelectedDate.ToString("dd/MM/yyyy") End Sub -
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 is my code Default Page/Parent Window/ function GetDate(CtrlName) { ChildWindow = window.open('Calendar.aspx?FormName=' + document.forms[0].name + '&CtrlName=' + CtrlName, "PopUpCalendar", "width=270,height=300,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no"); } [Start Date](javascript:GetDate('txtStartDate'))
Code for the Calendar Page/Child Page/ function ReturnDate() { window.opener.document.forms["<%= strFormName %>"].elements["<%=strCtrlName %>"].value = "<%= strSelectedDate %>"; window.close(); } function Close() { window.close(); } Public strFormName As String Public strCtrlName As String Public strSelectedDate As String Sub Page_Load(Sender As Object, E As EventArgs) If Not IsPostBack Then myCalendar.SelectedDate = System.DateTime.Now() End If strSelectedDate = myCalendar.SelectedDate.ToString("dd/MM/yyyy") strFormName = Request.QueryString("FormName") strCtrlName = Request.QueryString("CtrlName") End Sub Sub myCalendar_SelectionChanged(sender As Object, e As EventArgs) strSelectedDate = myCalendar.SelectedDate.ToString("dd/MM/yyyy") End SubHi, I am also suffered with that problem. The problem is when you put the controls inside master page: 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 change your code according to those control name changes in masterpage. Hope this helps.
-
Hi, I am also suffered with that problem. The problem is when you put the controls inside master page: 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 change your code according to those control name changes in masterpage. Hope this helps.
-
I add to the name of the controls $ but there is no difference.Make it clear pls help kidus
-
Hi, In master page you can find the content place holder window.open('popup.aspx?textbox=ctl00_Body_Wizard1_txtBoxElectionDate1' here ctl00_Body_txtBoxElectionDate1 is the my text box name which i got be seeing the view source. use that name here. And In popup.aspx I used like this: String strScript = "window.opener.document.forms['aspnetForm']." + control.Value + ".value = '"; strScript += calDate.SelectedDate.ToString("MM/dd/yyyy"); strScript += "';self.close()"; strScript += "</" + "script>"; RegisterClientScriptBlock("anything", strScript); aspnetForm is the the form name which contain the textbox to put the selected date. Check your code. Hope this helps. </x-turndown>
-
Hi, In master page you can find the content place holder window.open('popup.aspx?textbox=ctl00_Body_Wizard1_txtBoxElectionDate1' here ctl00_Body_txtBoxElectionDate1 is the my text box name which i got be seeing the view source. use that name here. And In popup.aspx I used like this: String strScript = "window.opener.document.forms['aspnetForm']." + control.Value + ".value = '"; strScript += calDate.SelectedDate.ToString("MM/dd/yyyy"); strScript += "';self.close()"; strScript += "</" + "script>"; RegisterClientScriptBlock("anything", strScript); aspnetForm is the the form name which contain the textbox to put the selected date. Check your code. Hope this helps. </x-turndown>
hi Thank you for your fast response in the code String strScript = "window.opener.document.forms['aspnetForm']." + control.Value + ".value = '"; the form name 'aspnetForm'.There is only one form in the master page.No other forms in the other pages.My text box is in the other pages. Any help kidus</x-turndown>
-
hi Thank you for your fast response in the code String strScript = "window.opener.document.forms['aspnetForm']." + control.Value + ".value = '"; the form name 'aspnetForm'.There is only one form in the master page.No other forms in the other pages.My text box is in the other pages. Any help kidus</x-turndown>
you have to modifiy like this onclick ="javascript:GetDate('ctl00$ContentPlaceHolder1$"Text box name here"')"