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

LVL 1
SaraDobAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.