Solved

Javascript function undefined...but it is!

Posted on 2013-12-12
17
4,074 Views
1 Endorsement
Last Modified: 2013-12-21
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:
<body>
    <form id="form2" runat="server">
   
    <telerik:RadScriptManager ID="RadScriptManager2" runat="server">
            <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" 
                Name="Telerik.Web.UI.Common.Core.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI" 
                Name="Telerik.Web.UI.Common.jQuery.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI" 
                Name="Telerik.Web.UI.Common.jQueryInclude.js">
            </asp:ScriptReference>
        </Scripts>
    </telerik:RadScriptManager>

     <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();
                  oWindow.close(null);
              }
              function returnArg() {
                  var oWnd = GetRadWindow();
                  var txtInput = document.getElementById("<%=txtPW.ClientID %>");
                  oWnd.close(txtinput.text);
              }
     </script>
   
        <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>

    </form>
</body>

Open in new window


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();")

Open in new window


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.
1
Comment
Question by:Lisa412
17 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39715406
Since your asp code runs on the server, then renders html to the client's browser and finally any js/jquery runs based on the rendered html/css.   Therefor, your asp code may affect the outcome if any html or js is created dynamically,but it is not really important for your question for now.  With that in mind, will you please render your html and post just the html as if you viewed the source in the browser and copied that code.  

If we find an error in the rendered html, then you can go back to the asp code and figure out where to change it.   For now, let's see your rendered html and js/jquery.
0
 

Author Comment

by:Lisa412
ID: 39718039
Hi - I hope this is what you're looking for. Thanks for your help.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title><link href="/WebResource.axd?d=Azr25rlxcj2oD8DG4LLTwatHTpAsPojhwLtPYXcU6i4mHdD74H8zIgLltDeX2TXT2bD35pIy9Iq0PTEXjkKv3EL2-o6jVRvklm8FjrXiho_3WUbdpyxShxxhA8suB5yQNTzYfxiU3ztflDGUf9tV0Q2&amp;t=635173546100000000" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=j1E0mRB4jBNXNuCEKsdtNcXpCqQROTHUJV7yhsntKkarCRiYgnMwZ8T1Uf15BZn26FX6znOsJ90n_V-zT62zeLEn6hCF3UnhcJce5-mdS5HoCs5P7HIBX0InEWmchhWMvq9zyUpAPubt8VyvES8YMheAaKL-e9hULh7g1cTDU9g1&amp;t=635173546100000000" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=7E6yD7MJcLYPnajMz3T6lwN5wLdWuSBRDCVWA-3ouS17Q3Y_R8JTSa8dF9RDt9i5apBj4EVqAkJfb-ytLe_0rNE6T5QHCxEPmsRbqSdEXaMyejiiow6WAkSrS_sPbApH51TRm5ljQ-ISv0eKQVbstQ2&amp;t=635173546100000000" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=9PGENFqWbEx-jn1IhpzbdjWPqCqDCKNYhkCXWot7E7n1djmnWuX_bfDr1Lpz8cc3_DX83IjqA78CD_jMgAP4ScE4zmgyFeZR3tdtv-sOtR6ypQqD15Q9D-7jCy3jCTzDIbVdGWi7YVqiGEzeMFvHkdjnRzTLUrTl-fxp2PD2-441&amp;t=635173546100000000" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /></head>
<body>
    <form method="post" action="dlgPassword.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="RadScriptManager1_TSM" id="RadScriptManager1_TSM" value="" />
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJOTA2NTEwNzA2D2QWAgIDD2QWCAIBDw8WAh4EVGV4dAXbAVRoaXMgYmxlbmQgY2FuIG5vdCBiZSByZWxlYXNlZCB3aXRob3V0IG1hbmFnZW1lbnQgYXBwcm92YWwgYmVjYXVzZSBub3QgYWxsIHZhbHVlcyBhcmUgd2l0aGluIHNwZWNpZmllZCBsaW1pdHMuDQpJZiB5b3UgYXJlIGEgbWFuYWdlciBhbmQgd2lzaCB0byBvdmVycmlkZSB0aGlzIHByb2hpYml0aW9uIGFuZCByZWxlYXNlIHRoZSBibGVuZCwgZW50ZXIgeW91ciBwYXNzd29yZCBoZXJlLmRkAgIPFCsACA8WBB4XRW5hYmxlQWpheFNraW5SZW5kZXJpbmdoHg1MYWJlbENzc0NsYXNzBQdyaUxhYmVsZBYIHgVXaWR0aBsAAAAAAABkQAEAAAAeClJlc2l6ZU1vZGULKXNUZWxlcmlrLldlYi5VSS5SZXNpemVNb2RlLCBUZWxlcmlrLldlYi5VSSwgVmVyc2lvbj0yMDEzLjMuMTAxNS40MCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj0xMjFmYWU3ODE2NWJhM2Q0AB4IQ3NzQ2xhc3MFEXJpVGV4dEJveCByaUhvdmVyHgRfIVNCAoICFggfAxsAAAAAAABkQAEAAAAfBAsrBAAfBQURcmlUZXh0Qm94IHJpRXJyb3IfBgKCAhYIHwMbAAAAAAAAZEABAAAAHwQLKwQAHwUFE3JpVGV4dEJveCByaUZvY3VzZWQfBgKCAhYIHwQLKwQAHwMbAAAAAAAAZEABAAAAHwUFE3JpVGV4dEJveCByaUVuYWJsZWQfBgKCAhYIHwMbAAAAAAAAZEABAAAAHwQLKwQAHwUFFHJpVGV4dEJveCByaURpc2FibGVkHwYCggIWCB8DGwAAAAAAAGRAAQAAAB8ECysEAB8FBRFyaVRleHRCb3ggcmlFbXB0eR8GAoICFggfAxsAAAAAAABkQAEAAAAfBAsrBAAfBQUQcmlUZXh0Qm94IHJpUmVhZB8GAoICZAIDDzwrAAQBAA8WAh8BaBYEHghsYW5ndWFnZQUKamF2YXNjcmlwdB4HT25DbGljawUMcmV0dXJuQXJnKCk7ZAIEDzwrAAQBAA8WAh8BaBYEHwcFCmphdmFzY3JpcHQfCAURY2FuY2VsQW5kQ2xvc2UoKTtkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYCBQVidG5PSwUJYnRuQ2FuY2VsmyQ+gFxa+JU6v7SZEtj27AEDxlTG0RX8gGo9kzi8m24=" />
</div>

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>


<script src="/WebResource.axd?d=pvqVPH_l3-wuvhSo7QBVaOeKKzvKeeHjG4_kjkNChtk4YPO_AKtbuTtovnx1sJnWF9HdrccMyzDDGON7gx8xgNZ9kY73m4z3kOphcOL5-6U1&amp;t=635194247536870992" type="text/javascript"></script>


<script src="/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&amp;compress=1&amp;_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3af01b1325-3d40-437a-8da2-df3d86714220%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3aac331549-681c-4402-9fb7-09ec3c579ee8%3a16e4e7cd%3af7645509%3a22a6274a%3ab7778d6c%3a24ee1bba%3a7165f74" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>

<div class="aspNetHidden">

	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWCALq8cCDDgK9+8qeDgLdkpmPAQLw/dj7DwLdkpmPAQKQ9M/rBQK9m46fCwKQ9M/rBTZZsNxpToeFAazy0EwZQhJA3hzaQawxVtwp7vETmktj" />
</div>
   
    <script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('RadScriptManager1', 'form1', [], [], [], 90, '');
//]]>
</script>



          <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();
                  oWindow.close(null);
              }
              function returnArg() {
                   var oWnd = GetRadWindow();
                   var txtInput = document.getElementById("txtPW");
                   oWnd.close(txtinput.text);
             }
        </script>



    



   
        <span id="lblPW">This blend can not be released without management approval because not all values are within specified limits.
If you are a manager and wish to override this prohibition and release the blend, enter your password here.</span>
        <br />
        <br />
        <!-- 2013.3.1015.40 --><span id="txtPW_wrapper" class="riSingle RadInput RadInput_WebBlue" style="width:160px;"><input id="txtPW" name="txtPW" size="20" class="riTextBox riEnabled" type="password" /><input id="txtPW_ClientState" name="txtPW_ClientState" type="hidden" /></span>
        <br />
        <br />


                <span id="btnOK" class="RadButton RadButton_WebBlue rbSkinnedButton" language="javascript" OnClick="returnArg();" style="display:inline-block;width:100px;"><input class="rbDecorated" type="submit" name="btnOK_input" id="btnOK_input" value="OK" style="width:100%;padding-left:0;padding-right:0;padding-left:4px;" /><input id="btnOK_ClientState" name="btnOK_ClientState" type="hidden" /></span>
        &nbsp &nbsp &nbsp
        <span id="btnCancel" class="RadButton RadButton_WebBlue rbSkinnedButton" language="javascript" OnClick="cancelAndClose();" style="display:inline-block;width:100px;"><input class="rbDecorated" type="submit" name="btnCancel_input" id="btnCancel_input" value="Cancel" style="width:100%;padding-left:0;padding-right:0;padding-left:4px;" /><input id="btnCancel_ClientState" name="btnCancel_ClientState" type="hidden" /></span>
    

<script type="text/javascript">
//<![CDATA[
Sys.Application.add_init(function() {
    $create(Telerik.Web.UI.RadTextBox, {"_focused":false,"_postBackEventReferenceScript":"setTimeout(\"__doPostBack(\\\u0027txtPW\\\u0027,\\\u0027\\\u0027)\", 0)","_skin":"WebBlue","clientStateFieldID":"txtPW_ClientState","enabled":true,"styles":{HoveredStyle: ["width:160px;", "riTextBox riHover"],InvalidStyle: ["width:160px;", "riTextBox riError"],DisabledStyle: ["width:160px;", "riTextBox riDisabled"],FocusedStyle: ["width:160px;", "riTextBox riFocused"],EmptyMessageStyle: ["width:160px;", "riTextBox riEmpty"],ReadOnlyStyle: ["width:160px;", "riTextBox riRead"],EnabledStyle: ["width:160px;", "riTextBox riEnabled"]}}, null, null, $get("txtPW"));
});
Sys.Application.add_init(function() {
    $create(Telerik.Web.UI.RadButton, {"_accessKey":"","_postBackReference":"","clientStateFieldID":"btnOK_ClientState","iconData":{},"imageData":{},"text":"OK","toggleStatesData":[],"uniqueGroupName":"","uniqueID":"btnOK","width":"100px"}, null, null, $get("btnOK"));
});
Sys.Application.add_init(function() {
    $create(Telerik.Web.UI.RadButton, {"_accessKey":"","_postBackReference":"","clientStateFieldID":"btnCancel_ClientState","iconData":{},"imageData":{},"text":"Cancel","toggleStatesData":[],"uniqueGroupName":"","uniqueID":"btnCancel","width":"100px"}, null, null, $get("btnCancel"));
});
//]]>
</script>
</form>
</body>
</html>

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 39718240
Does it work wit hthe following :

        btnOK.Attributes.Add("language", "javascript")
        btnOK.Attributes.Add("OnClick", "if(window.radWindow) oWnd=window.radWindow;else if(window.frameElement.radWindow) oWnd=window.frameElement.radWindow;else alert('null');var txtInput = document.getElementById('txtPW');oWnd.close(txtinput.text);")


        btnCancel.Attributes.Add("language", "javascript")
        btnCancel.Attributes.Add("OnClick", "if(window.radWindow) oWnd=window.radWindow;else if(window.frameElement.radWindow) oWnd=window.frameElement.radWindow;else alert('null');oWnd.close(null);")

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Lisa412
ID: 39720593
The suggested code is close. When run, it says that txtInput is not defined. So I modified your 2nd line to eliminate the var txtInput as follows:
        btnOK.Attributes.Add("OnClick", "if(window.radWindow) oWnd=window.radWindow;else if(window.frameElement.radWindow) oWnd=window.frameElement.radWindow;else alert('null');oWnd.close(document.getElementById('txtPW').text);")

This actually runs but it is not passing back the value in txtPW to the calling page. When I put a breakpoint in the callback function, it says the value is {object Object}. (which is where I was several iterations ago).

The HMTL on the page which opens this password window is:

    <script language="javascript" type="text/javascript">
              function dlgPWClose(sender, args)
        {
             document.getElementById("<%=HiddenReleasePassword.ClientID%>").value = args;
            <%=ClientScript.GetPostBackEventReference(new System.Web.UI.PostBackOptions(btnReleaseCallBack))%> ;
        }
    </script>

    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="WebBlue">
        <Windows>
            <telerik:RadWindow ID="rwPassword" runat="server" Modal="true" 
                NavigateUrl="~/UserPages/dlgPassword.aspx" Height = "200px" Width = "1200px" 
                Title="Blend Composition Outside of Limits" Behaviors="Close, Move" Behavior="Close, Move"
                onclientclose = "dlgPWClose">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>

Open in new window


As you can see, the onclientclose event for this window should be handled by the javascript function dlgPWClose.  It should put the returned value in the hidden field HiddenReleasePassword and then  essentially "click" the btnReleaseCallBack. This appears to be working because I put a breakpoint in the code behind for btnReleaseCallBack and it does hit it. However, the value it has for HiddenReleasePassword is {object Object}.
So how do I get the password return value back?

Thanks again for helping.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39720628
The HMTL on the page which opens this password window is

with your web browser, once you the page or popup window opened with this content, do a right click on the page and choose view source, try to locate this part and post it here
0
 
LVL 9

Expert Comment

by:Sar1973
ID: 39720987
Is the function radWindow defined or not...?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39721279
No, to have more chanceto locate it, put a div around with a specific ID attribute :


<div id="toLocate_RadWindow">

    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="WebBlue">
        <Windows>
            <telerik:RadWindow ID="rwPassword" runat="server" Modal="true" 
                NavigateUrl="~/UserPages/dlgPassword.aspx" Height = "200px" Width = "1200px" 
                Title="Blend Composition Outside of Limits" Behaviors="Close, Move" Behavior="Close, Move"
                onclientclose = "dlgPWClose">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>

</div>

Open in new window

0
 

Author Comment

by:Lisa412
ID: 39721406
Here is the relevant rendition, I hope. Please note there is another window on the page "rwAddSelect" which is not giving me any trouble so I did not include in prior code. But I didn't want to excise it out of this code because I was afraid I would make a mess of it.

    <div id="toLocate_RadWindow">

    <div id="ctl00_MainContent_RadWindowManager1" style="display:none;">
	<div id="ctl00_MainContent_rwAddSelect" style="display:none;">
		<div id="ctl00_MainContent_rwAddSelect_C" style="display:none;">

		</div><input id="ctl00_MainContent_rwAddSelect_ClientState" name="ctl00_MainContent_rwAddSelect_ClientState" type="hidden" />
	</div><div id="ctl00_MainContent_rwPassword" style="display:none;">
		<div id="ctl00_MainContent_rwPassword_C" style="display:none;">

		</div><input id="ctl00_MainContent_rwPassword_ClientState" name="ctl00_MainContent_rwPassword_ClientState" type="hidden" />
	</div><div id="ctl00_MainContent_RadWindowManager1_alerttemplate" style="display:none;">
		<div class="rwDialogPopup radalert">			
			<div class="rwDialogText">
			{1}				
			</div>
			
			<div>
				<a  onclick="$find('{0}').close(true);"
				class="rwPopupButton" href="javascript:void(0);">
					<span class="rwOuterSpan">
						<span class="rwInnerSpan">##LOC[OK]##</span>
					</span>
				</a>				
			</div>
		</div>
		</div><div id="ctl00_MainContent_RadWindowManager1_prompttemplate" style="display:none;">
		 <div class="rwDialogPopup radprompt">			
			    <div class="rwDialogText">
			    {1}				
			    </div>		
			    <div>
				    <script type="text/javascript">
				    function RadWindowprompt_detectenter(id, ev, input)
				    {							
					    if (!ev) ev = window.event;                
					    if (ev.keyCode == 13)
					    {															        
					        var but = input.parentNode.parentNode.getElementsByTagName("A")[0];					        
					        if (but)
						    {							
							    if (but.click) but.click();
							    else if (but.onclick)
							    {
							        but.focus(); var click = but.onclick; but.onclick = null; if (click) click.call(but);							 
							    }
						    }
					       return false;
					    } 
					    else return true;
				    }	 
				    </script>
				    <input title="Enter Value" onkeydown="return RadWindowprompt_detectenter('{0}', event, this);" type="text"  class="rwDialogInput" value="{2}" />
			    </div>
			    <div>
				    <a onclick="$find('{0}').close(this.parentNode.parentNode.getElementsByTagName('input')[0].value);"				
					    class="rwPopupButton" href="javascript:void(0);" ><span class="rwOuterSpan"><span class="rwInnerSpan">##LOC[OK]##</span></span></a>
				    <a onclick="$find('{0}').close(null);" class="rwPopupButton"  href="javascript:void(0);"><span class="rwOuterSpan"><span class="rwInnerSpan">##LOC[Cancel]##</span></span></a>
			    </div>
		    </div>				       
		</div><div id="ctl00_MainContent_RadWindowManager1_confirmtemplate" style="display:none;">
		<div class="rwDialogPopup radconfirm">			
			<div class="rwDialogText">
			{1}				
			</div>						
			<div>
				<a onclick="$find('{0}').close(true);"  class="rwPopupButton" href="javascript:void(0);" ><span class="rwOuterSpan"><span class="rwInnerSpan">##LOC[OK]##</span></span></a>
				<a onclick="$find('{0}').close(false);" class="rwPopupButton"  href="javascript:void(0);"><span class="rwOuterSpan"><span class="rwInnerSpan">##LOC[Cancel]##</span></span></a>
			</div>
		</div>		
		</div><input id="ctl00_MainContent_RadWindowManager1_ClientState" name="ctl00_MainContent_RadWindowManager1_ClientState" type="hidden" />
</div>


    </div>

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 39721550
There's no field with this ID : txtPW
This is the issue, where is this field ?
0
 

Author Comment

by:Lisa412
ID: 39721590
txtPW is defined on the dialog window. It's text value should be passed back to the calling page as an argument. I don't see any reference to txtPW in the prior code - where did you see its ID?
0
 

Author Comment

by:Lisa412
ID: 39721597
Even though everything I have googled suggests that I should be able to pass parameters to and from this custom dialog page, I am thinking perhaps I should just abandon this attempt and set the password as a Session variable on the dialog page, close that page, and then retrieve the password from the Session variable on the calling page.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39721600
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39721615
Passing data with hidden field is IMHO a bad practice, so yes, if it's possible use server side variable in your case session variable.
0
 

Assisted Solution

by:Lisa412
Lisa412 earned 0 total points
ID: 39722321
OK. I surrendered on the passing of parameters from dialog window to calling page. My project is now working. Thank you for your patience and your help leakim971.

If anyone else out there is interested, here is my solution:

Calling page .aspx
    <script language="javascript" type="text/javascript">
        function dlgPWClose(sender, args)
        {
             document.getElementById("<%=HiddenReleasePassword.ClientID%>").value = args;
            <%=ClientScript.GetPostBackEventReference(new System.Web.UI.PostBackOptions(btnReleaseCallBack))%> ;
        }
    </script>


    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="WebBlue">
        <Windows>
            <telerik:RadWindow ID="rwPassword" runat="server" Modal="true" 
                NavigateUrl="~/UserPages/dlgPassword.aspx" Height = "200px" Width = "1200px" 
                Title="Blend Composition Outside of Limits" Behaviors="Close, Move" Behavior="Close, Move"
                onclientclose = "dlgPWClose">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>

Open in new window


Calling page code behind on button click to open the dialog window "rwPassword":
                Session("PWOverride") = ""
                Session("Label") = "This blend can not be released without management approval because not all values are within specified limits." & vbCrLf & _
                                     "If you are a manager and wish to override this prohibition and release the blend, enter your password here."
                Dim script As String = "function f(){$find(""" + rwPassword.ClientID + """).show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, True)

Open in new window


Dialog page aspx:
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" 
                Name="Telerik.Web.UI.Common.Core.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI" 
                Name="Telerik.Web.UI.Common.jQuery.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI" 
                Name="Telerik.Web.UI.Common.jQueryInclude.js">
            </asp:ScriptReference>
        </Scripts>
    </telerik:RadScriptManager>

    <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;
              }
     </script>

        <asp:Label ID="lblPW" runat="server" Text="Label"> </asp:Label>
        <br />
        <telerik:RadTextBox ID="txtPW" runat="server" TextMode="Password">  </telerik:RadTextBox>
        <br />
        <telerik:RadButton ID="btnOK" runat="server" Text="OK"  Width = "100px" > </telerik:RadButton>
        &nbsp &nbsp &nbsp
        <telerik:RadButton ID="btnCancel" runat="server" Text="Cancel"  Width = "100px" > </telerik:RadButton>

Open in new window


Dialog page code behind:
    Private Sub btnOK_Click(sender As Object, e As System.EventArgs) Handles btnOK.Click
        Session("PWOverride") = NZ2(txtPW.Text, "")
        Dim script As String = "function f(){ var oWindow = GetRadWindow();  oWindow.close(null); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, True)
    End Sub

    Private Sub btnCancel_Click(sender As Object, e As System.EventArgs) Handles btnCancel.Click
        Session("PWOverride") = ""
        Dim script As String = "function f(){ var oWindow = GetRadWindow();  oWindow.close(null); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, True)
    End Sub

Open in new window

0
 

Author Comment

by:Lisa412
ID: 39722330
And the code behind on calling page on the hidden btnReleaseCallBack which is called when the dialog window closes is:
    Private Sub btnReleaseCallBack_Click(sender As Object, e As System.EventArgs) Handles btnReleaseCallBack.Click
        
	Dim strPWOverride As String = ""
        Try
            strPWOverride = Session("PWOverride")
        Catch
            strPWOverride = ""
        End Try


        If strPWOverride = "" Then
            Exit Sub
        End If

        Try
            'Validate password belongs to someone with Lab Manager privileges
            Dim blnValid As Boolean = IsLabManagerPassword(strPWOverride)
            If blnValid Then
                ReleaseBlend()
            Else
                RadWindowManager1.RadAlert("ERROR: Invalid password. \n Can not release out of spec blend.", 600, 200, "Invalid Password", "")
            End If
        Catch ex As Exception
            ShowAlert(Page, ex.InnerException.Message)
        End Try
        HiddenReleasePassword.Value = ""

    End Sub

Open in new window

0
 

Author Closing Comment

by:Lisa412
ID: 39733411
This is the final solution to my exact problem. The expert helped me find the way there.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question