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

RadConfirm Always returning False

2 Answers 93 Views
Window
This is a migrated thread and some comments may be shown as answers.
Rodney
Top achievements
Rank 2
Rodney asked on 22 Feb 2016, 02:57 PM

Hi,

 

I'm using RadConfirm and initiating it from a C# method. The confirm window pops up just fine, but in my JavaScript  is always returning false. Here is an example of what I have:

C#

protected void txtUserName_DupValidator_ServerValidate(object source, ServerValidateEventArgs args)
{
    if (hfUserName.Value != txtUserName.TextWithPromptAndLiterals)
    {
        if (!(Controller).IsUsernameUnique(txtUserName.TextWithPromptAndLiterals))
        {
            args.IsValid = false;
            rwmDialogs.RadConfirm("This is an existing user, do you want to edit the existing user or cancel?", "confirmCallBackFn", 300, 250, null, "Verify User");
        }
    }
}

JavaScript

function confirmCallBackFn(arg) {
    //radalert("<strong>radconfirm</strong> returned the following result: <h3 style='color: #ff0000;'>" + arg + "</h3>", 350, 250, "Result");
    if (arg = "false") {
        newWindow = openAdminPage("../../../Users");
        return false;
    }
    else {
        PageMethods.DisplayUser(document.getElementById("<%=txtUserName%>".value))
    }
}

 

Markup

<telerik:RadWindowManager ID="rwmDialogs" runat="server" RenderMode="Lightweight" EnableShadow="true"></telerik:RadWindowManager>

2 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 22 Feb 2016, 03:03 PM

Hello Rodney,

You should

  • use a comparison check operator (==) instead of an assignment operator (=) in the if-clause
  • compare the variable type and not a string comparison. RadConfirm returns a boolean true, boolean false, or the standard JavaScript null pointer

 

if (arg == false) {


Regards,

Marin Bratanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Rodney
Top achievements
Rank 2
answered on 22 Feb 2016, 03:04 PM

Thanks, so simple and I didn't catch it.

Sorry

Tags
Window
Asked by
Rodney
Top achievements
Rank 2
Answers by
Marin Bratanov
Telerik team
Rodney
Top achievements
Rank 2
Share this question
or