• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 742
  • Last Modified:

Javascript pop up not working, added to master page

Hi all,
I had a calendar control working perfectly in a .aspx page. I wired the .aspx to Masterpage.Now the calendar control fails to recognise the form and the element( a textbox), it dumps the date into.
It gives me an : ct100_Maincontent_mytextbox is null or the object is not re..." error.
I have attched the code snippet below.
PLEASE HELP.
'This is how i call The popup calendar
<a href="javascript:calendar_window=window.open('Controls/Calendar.aspx?textbox=<% =txtMFgDate.ClientID %>','calendar_window','width=235,height=218 top=200 left=500','scrollbars=no,status=no,minimize=no,resizable=no');calendar_window.focus()"><img alt="PopUp Calendar" src="Images/popup-calendar.gif" /></a>
 
'this is the code behind in calendar control
   Protected Sub Change_Date(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim strjscript As String = "<script type=""text/javascript"">"
        strjscript &= "window.opener." & _
              HttpContext.Current.Request.QueryString("textbox") & ".value = '" & _
              myCalendar.SelectedDate & "';window.close();"
        strjscript = strjscript & "</script" & ">" 'Don't Ask, Tool Bug
 
        Literal1.Text = strjscript  'Set the literal control's text to the JScript code
 
    End Sub

Open in new window

0
SaraDob
Asked:
SaraDob
  • 5
  • 2
1 Solution
 
silemoneCommented:
the id's change on controls when inside of a masterpage...it add cl00...when you run code, look in the view source and retrieve ID from there...
0
 
SaraDobAuthor Commented:
Thanks for the quick response silemone.
I view in the source .i got "ctl00$MainContent$txtMFgDate" as my textbox name, when in masterpage content.
So should i change textbox id="ctl00$MainContent$txtMFgDate" that now instead of textbox="My original textbox name" ?
If so, then i have go change of all the textbox names throught out my site, that has calendar pops or any other kind od javapops's ?
0
 
SaraDobAuthor Commented:
I replaced  "ctl00$MainContent$txtMFgDate as my textbox name and run it..but still i get the same issue..
Please reply
 
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
silemoneCommented:
ok..I was looking at the wrong javascript....

you are using <%= control.ClientID %> so you shouldn't have to change id = ...

whenever you need to access that control, you would just use control.ClientID the way you did...

hmmm.....
0
 
SaraDobAuthor Commented:
I'm using this script, to put back the Selected date. This code is in Code behind of the calendar.Can you please look, and tell whats wrong here>
Thanks..Hope it will be solved soon

Protected Sub Change_Date(ByVal sender As System.Object, ByVal e As System.EventArgs) 
Dim strjscript As String = "<script type=""text/javascript"">" 
strjscript &= "window.opener." & _ 
HttpContext.Current.Request.QueryString("textbox") & ".value = '" & _ 
myCalendar.SelectedDate & "';window.close();" 
strjscript = strjscript & "</script" & ">" 'Don't Ask, Tool Bug 
Literal1.Text = strjscript 'Set the literal control's text to the JScript code 
End Sub 

Open in new window

0
 
SaraDobAuthor Commented:
Well, Itried it on my own.I cant possible hard code the Control iDs, as There will be other pop up request from other pages.
So this is what i used to send the textbox name to the calendar control, through the javascript function : <%=textbox1.ClientID%>
0
 
SaraDobAuthor Commented:
Finally i used In code behind of calendar control to put back the date, into the calling textbox:

Protected Sub Change_Date(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim strjscript As String = "<script language='javascript'>"
strjscript += "window.opener.document.forms[0].elements['"
strjscript += (HttpContext.Current.Request.QueryString("textbox") & "'].value= '") & myCalendar.SelectedDate & "';"
strjscript += "window.opener.document.forms[0].elements['"
strjscript += (HttpContext.Current.Request.QueryString("textbox") & "'].focus();")
strjscript += "window.close()"
strjscript += "</" & "script>"
LiteralCalendar.Text = strjscript
End Sub
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now