troubleshooting Question

Javascript function undefined...but it is!

Avatar of Lisa412
Lisa412 asked on
JavaScriptASP.NETScripting LanguagesWeb ApplicationsAJAX
16 Comments2 Solutions5815 ViewsLast Modified:
I can't believe something this simple could be so difficult!

I have an asp page that I am using as a custom dialog box to request a password. Here is the HMTL:
    <form id="form2" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager2" runat="server">
            <asp:ScriptReference Assembly="Telerik.Web.UI" 
            <asp:ScriptReference Assembly="Telerik.Web.UI" 
            <asp:ScriptReference Assembly="Telerik.Web.UI" 

     <script language="javascript" type="text/javascript">
              function GetRadWindow() {
                  var oWindow = null;
                  if (window.radWindow)
                      oWindow = window.radWindow;
                  else if (window.frameElement.radWindow)
                      oWindow = window.frameElement.radWindow;
                  return oWindow;
              function cancelAndClose() {
                  var oWindow = GetRadWindow();
              function returnArg() {
                  var oWnd = GetRadWindow();
                  var txtInput = document.getElementById("<%=txtPW.ClientID %>");
        <asp:Label ID="Label1" runat="server" Text="Label"> </asp:Label>
        <telerik:RadTextBox ID="RadTextBox1" runat="server" TextMode="Password">  </telerik:RadTextBox>
        <telerik:RadButton ID="RadButton1" runat="server" Text="OK"  Width = "100px" > </telerik:RadButton>
        &nbsp &nbsp &nbsp
        <telerik:RadButton ID="RadButton2" runat="server" Text="Cancel"  Width = "100px" > </telerik:RadButton>


Since I could not get any response out of the OK or Cancel buttons when their HTML included an OnClientClicked tag,  I added the following to the code behind in the page load event.

        btnOK.Attributes.Add("language", "javascript")
        btnOK.Attributes.Add("OnClick", "returnArg();")

        btnCancel.Attributes.Add("language", "javascript")
        btnCancel.Attributes.Add("OnClick", "cancelAndClose();")

When I click either the OK or the Cancel buttons, I get an error that says the javascript function returnArg or closeAndCancel is undefined. And yet I've been staring at the definition for hours!

Can someone please tell me what is wrong?

At one point, it was responding to the OK button but then saying that txtInput was undefined in the third line of that function. Somehow in trying to fix that, I managed to break it completely.
Join our community to see this answer!
Unlock 2 Answers and 16 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros