This is a migrated thread and some comments may be shown as answers.

Passing parameter to radwindow from code behind

1 Answer 546 Views
Window
This is a migrated thread and some comments may be shown as answers.
Lisa
Top achievements
Rank 1
Lisa asked on 09 Dec 2013, 02:40 PM
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.

 

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Dec 2013, 10:30 AM
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.
Tags
Window
Asked by
Lisa
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or