Passing parameter to radwindow from code behind

2 posts, 0 answers
  1. Lisa
    Lisa avatar
    16 posts
    Member since:
    Nov 2013

    Posted 09 Dec 2013 Link to this post

    I have a button. When the user clicks the button, the code behind should check on several things and if certain conditions exist, it should pop up a dialog box asking for a supervisor's password. If the password is valid, then the code behind should continue processing.

    I was able to successfully implement with a radprompt, however, when password input really needs to be masked as the user types it. So I think I need to create a separate form where I can control masking on the input textbox. I have tried what fills like a gazillion variations of javascript but can't get this to work.

    In my latest attempt, I followed the code described here: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx.   This got me as far as the dialog form actually opening but I can't get a parameter in and I can't get the password back out.

    Here is my window definition,  inside a radwindow manager:

    <telerik:RadWindow ID="rwPassword" runat="server" Modal="True" NavigateUrl="~/UserPages/dlgPassword.aspx" Height = "500px" Width = "400px" Title="Out of Spec" Behaviors="Close, Move" Behavior="Close, Move">

    </telerik:RadWindow

    >

    Here is the current codebehind which opens it:

    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)

    The current markup of my password window looks like this. The javascript there was from an earlier attempt but I don't see why it wouldn't work with this version. After the form opens, I have to close with the X. The OK and Cancel buttons do absolutely nothing.

    I have been stuck on this for days. If anyone could help, I would be so grateful.
    Thank you.

     

     

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 10 Dec 2013 Link to this post

    Hi Lisa,

    Please have a look into the sample code snippet which works fine at my end.

    MainPage ASPX:
    <telerik:RadButton ID="RadButton1" runat="server" Text="Open RadWindow" OnClick="RadButton1_Click">
    </telerik:RadButton>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableViewState="false"
        VisibleOnPageLoad="false">
        <Windows>
            <telerik:RadWindow ID="rwPassword" runat="server" Modal="True" NavigateUrl="password.aspx"
                Height="500px" Width="400px" Title="Out of Spec" Behaviors="Close, Move" Behavior="Close, Move">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
    <telerik:RadButton ID="RadButton2" runat="server" AutoPostBack="false" OnClientClicked="getdata"
        Text="GetData">
    </telerik:RadButton>

    Main Page C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        //opening the radwindow page
        string script = "function f(){$find(\"" + rwPassword.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
    }

    Main Page JavaScript:
    <script type="text/javascript">
        function loadPageVar(sVar) {
            return decodeURI(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURI(sVar).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
        }
        function getdata(sender, args) {
            //get the password from the radwindow
            var s = loadPageVar('text');
            alert(s);
        }
    </script>

    RadWindowPage ASPX:
    <telerik:RadTextBox ID="RadTextBox1" runat="server" TextMode="Password">
    </telerik:RadTextBox>
    <telerik:RadButton ID="RadButton1" runat="server" Text="Submit" AutoPostBack="false"
        OnClientClicked="changepage">
    </telerik:RadButton>

    RadWindowPage JavaScript:
    <script type="text/javascript">
        function changepage(sender, args) {
            //accessing the radtextboxvalue
            var text = $find("<%=RadTextBox1.ClientID %>").get_value();
            //rediecting to the previous page and passing argument
            window.top.location.href = "PassingParameter.aspx?&text=" + text;
        }
    </script>

    Let me know if you have any concern.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top