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

Need to execute RadConfirm from codebehind

8 Answers 176 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 2
Bill asked on 20 Aug 2010, 06:21 PM
I have a situation where I have a TreeNode that the user is associating data (via the OnNodeClick event) with other controls on the page. Meaning, if the user clicks on node1 and fills in data (to the right of the treeview), but doesn't save the data, then tries to click on node2, before they get to that node, I want to prompt them to Save their data first for node1 before moving to node2.

If the user responds No, I want the rest of the code in this event to not execute (which basically gets the info for the node2 they clicked) and stay at node1, instead of node2. If they respond Yes, I would like the rest of the code to execute and proceed to node2.

I can't get the radconfirm to work. I have the following code in the OnNodeClick event of the treeview.

RadAjaxManager1.ResponseScripts.Add("radconfirm('Are you sure you want to navigate to a different node without saving your data?', confirmCallBackFn);");

I have a RadAjaxManager in my markup and a javascript function as follows:

function

 

confirmCallBackFn(arg) {

 

 

if (arg == false) {

return

}

}


The RadConfirm box doesn't come up at all and proceeds with executing the code within the event....

How can I accomplish this with the Radconfirm? Please don't refer me to another post since I have scoured the internet & this website and am unable to find a concise way on how to do this relatively simple task. A simple code example would be great...

8 Answers, 1 is accepted

Sort by
0
Bill
Top achievements
Rank 2
answered on 20 Aug 2010, 10:30 PM
I tried this, but it's not working....

I have the following js:

        function CheckForDataSaving() {
            var result = window.confirm("'Are you sure you want to navigate away from this tree node or page without saving your data?'");
            if (!result) {
                return (false);
            }
        }

 

I have the following in my code-behind:

ScriptManager.RegisterStartupScript(this, this.GetType(), "confirm", "CheckForDataSaving();", true);

 

When executing the above code-behind (note that the page is in an AJAX script manager), the confirm dialog doesn't even show up.

Either or both responses would be appreciated. The first one is for the RadConfirm. The second reply is for a js Confirm.

0
Bill
Top achievements
Rank 2
answered on 21 Aug 2010, 02:56 AM
OK, I know I have a valid solution, but the js is telling me that the value in the hdnRecordSaved variable has no value!
Even when I specify in my function the following, it still tells me it has no value:
var myTextField = document.getElementById('hdnRecordSaved');
            alert(myTextField);

When I put the full value of the variable in (ctl00_ctl00_cphTopCenter_cphCenter_hdnRecordSaved.value), I get the correct contents back ("1"), which I set in my code behind. However, I would prefer to just put the short name in since the masterpages may change, etc. Unfortunately, I know I can get around this with VS2010, but we are using VS2008.

What am I doing wrong with the js naming conventions that can't give me the contents? Here is my below js.

<

 

asp:Panel ID="pnlMapFields" runat="server" ScrollBars="Both" Height="430px">

 

 

<telerik:RadTreeView ID="RadTreeView1" runat="server" DataTextField="Description"

 

 

DataFieldParentID="MapFieldparentID" DataFieldID="MapFieldID" DataValueField="MapFieldID"

 

 

OnClientNodeClicking="onNodeClicking" CausesValidation="false" OnNodeClick="RadTreeView1_OnNodeClick">

 

 

</telerik:RadTreeView>

 

 

</asp:Panel>

 


<table id="Table6" width="100%" runat="server" cellpadding="1" cellspacing="1" border="0">
                                    <tr>
                                        <td class="td_AEVNoBold" align="center">
                                            <asp:HiddenField ID="hdnRecordSaved" runat="server" />
                                        </td>
                                    </tr>
                                </table>

Note that the below bolded html has no trouble with the fieldnames which is in the same function.
<table id="Table7" width="100%" runat="server" cellpadding="1" cellspacing="1">
                                                <tr valign="top">
                                                    <td class="td_AEVNoBold" width="15%">
                                                        Mapping Field Name:
                                                    </td>
                                                    <td class="td_AEVNoBold">
                                                        <asp:Label ID="MappingField" runat="server" Font-Bold="true"></asp:Label>&nbsp (
                                                        <asp:Label ID="mapValue" runat="server" Font-Bold="true" ForeColor="blue"></asp:Label>
                                                        &nbsp;)
                                                    </td>
                                                </tr>
                                                </table>

<asp:Label ID="FieldName" runat="server" Font-Bold="true" ForeColor="Blue"></asp:Label>

var

 

MappingField = document.getElementById("<%= MappingField.ClientID%>");

 

 

var FieldName = document.getElementById("<%= FieldName.ClientID%>");

 

 

var hdnRecordSaved = document.getElementById("<%= hdnRecordSaved.ClientID%>");

 

function onNodeClicking(sender, args) {
            MappingField.innerText = args.get_node().get_text();
            FieldName.innerText = args.get_node().get_parent().get_text().toUpperCase() + " ==> " + args.get_node().get_text();

            alert(ctl00_ctl00_cphTopCenter_cphCenter_hdnRecordSaved.value); // gives correct value
            //alert(hdnRecordSaved.innerText); only valid if I make this a label, but its visiibility would be invisisble.
            //alert(hdnRecordSaved.value); gives no value
            if (hdnRecordSaved.value == "0") {
                alert(1);
                if ((startPosition.value != "") || (endPosition.value != "")) {
                    alert(2);
                    if (confirm("Are you sure you want to navigate away from this tree node or submit functionality without saving your data?")) {
                        alert(3);
                        return (true);
                    }
                    else {
                        alert(4);
                        return (false);
                    }
                }
            }
        }

0
Bill
Top achievements
Rank 2
answered on 21 Aug 2010, 07:08 PM

I have this in my js on the page:

var hdnRecordSaved = document.getElementById("<%= hdnRecordSaved.ClientID%>");

I don't know why I can't access the value of the variable like the other 2 variables I have in the page if I have this set up the same way as follows:

var hdnRecordSaved = document.getElementById("<%= hdnRecordSaved.ClientID%>");

When I have it like the above (which is declared just once in a script file at the bottom of the page - see original post), the variable has no value...

I am accessing it within the aspx page itself and not an external js file.

When I include the following into the code, I get a js error.

var myTextField = document.getElementById('hdnRecordSaved').value;
            alert(myTextField);

 

OR when I include this, I get an error:

var myTextField = document.getElementById('hdnRecordSaved').value;
            alert(myTextField.value);

BUT when I include the fully qualified name, everything is fine:

alert(ctl00_ctl00_cphTopCenter_cphCenter_hdnRecordSaved.value);

For whatever reason, I can't understand why I can't get a reference to it using the shorter name when declaring it (seemingly properly) in my code (see original post)????

0
Bill
Top achievements
Rank 2
answered on 22 Aug 2010, 07:47 PM

Here is the "view source" of the html when the page is running. The alert box doesn't pop up and my page doesn't go into my codebehind treenode click event:

<td align="center">
                                            <div id="ctl00_ctl00_cphTopCenter_cphCenter_ctl00_ctl00_cphTopCenter_cphCenter_hdnRecordSavedPanel">
    <input name="ctl00$ctl00$cphTopCenter$cphCenter$hdnRecordSaved" type="hidden" id="ctl00_ctl00_cphTopCenter_cphCenter_hdnRecordSaved" />
   </div>
                                        </td>

 

Here is the js function that executes when the node is clicked:

function onNodeClicking(sender, args) {
            MappingField.innerText = args.get_node().get_text();
            FieldName.innerText = args.get_node().get_parent().get_text().toUpperCase() + " ==> " + args.get_node().get_text();

            //alert(ctl00_ctl00_cphTopCenter_cphCenter_hdnRecordSaved.value);
            var myTextField = document.getElementById('hdnRecordSaved').value;
            alert(myTextField);
            //alert(ctl00_ctl00_cphTopCenter_cphCenter_hdnRecordSaved.value);
            if (hdnRecordSaved.value == "0") {
                alert(1);
                if ((startPosition.value != "") || (endPosition.value != "")) {
                    alert(2);
                    if (confirm("Are you sure you want to navigate away from this tree node or submit functionality without saving your data?")) {
                        alert(3);
                        return (true);
                    }
                    else {
                        alert(4);
                        return (false);
                    }
                }
            }
        } 

When I change the variable inside the fucntion name to the fully qualified name, it works fine:

function onNodeClicking(sender, args) {
            MappingField.innerText = args.get_node().get_text();
            FieldName.innerText = args.get_node().get_parent().get_text().toUpperCase() + " ==> " + args.get_node().get_text();

            //alert(ctl00_ctl00_cphTopCenter_cphCenter_hdnRecordSaved.value);
            //var myTextField = document.getElementById('hdnRecordSaved').value;
            //alert(myTextField);
            alert(ctl00_ctl00_cphTopCenter_cphCenter_hdnRecordSaved.value);
            if (hdnRecordSaved.value == "0") {
                alert(1);
                if ((startPosition.value != "") || (endPosition.value != "")) {
                    alert(2);
                    if (confirm("Are you sure you want to navigate away from this tree node or submit functionality without saving your data?")) {
                        alert(3);
                        return (true);
                    }
                    else {
                        alert(4);
                        return (false);
                    }
                }
            }
        }

Here is my entire html markup source. If you just look at the boldfaced lines below, you can see plainly where it is in the source code. I tried moving it out of the "td" and just an input tag right below the <form> tag, but the Telerik AjaxManager didn't like that even when I removed it from the UpdatedControls list under the Treeview:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mapping.aspx.cs" Inherits="DataNet.mapping"
    MasterPageFile="~/commonSecurity/MasterPages/TopBottomWithControls.Master" %>

<%@ Register Src="../Controls/mapHeader.ascx" TagName="mapHeader" TagPrefix="uc1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphCenter" runat="Server">

    <script language="JavaScript" type="text/javascript">
        function lstData_onClick() {
            txtRec.value = lstData.options[lstData.options.selectedIndex].text;
        }

        function mouseUP() {
            var text = "";
            var startPos = 0;

            text = (document.all) ? document.selection.createRange().text : document.getSelection();
            //alert(text);

            if (typeof txtRec.selectionStart != "undefined")
                starPos = txtRec.selectionStart;
            else if (document.selection)
                startPos = Math.abs(document.selection.createRange().moveStart("character", -1000000));

            mapValue.innerText = text;

            var radSP = $find(startPosition.id);
            radSP.set_value(startPos + 1);

            var radEP = $find(endPosition.id);
            radEP.set_value(startPos + text.length);
        }

        function onNodeClicking(sender, args) {
            MappingField.innerText = args.get_node().get_text();
            FieldName.innerText = args.get_node().get_parent().get_text().toUpperCase() + " ==> " + args.get_node().get_text();

            //alert(ctl00_ctl00_cphTopCenter_cphCenter_hdnRecordSaved.value);
            //var myTextField = document.getElementById('hdnRecordSaved').value;
            //alert(myTextField);
            alert(ctl00_ctl00_cphTopCenter_cphCenter_hdnRecordSaved.value);
            if (hdnRecordSaved.value == "0") {
                alert(1);
                if ((startPosition.value != "") || (endPosition.value != "")) {
                    alert(2);
                    if (confirm("Are you sure you want to navigate away from this tree node or submit functionality without saving your data?")) {
                        alert(3);
                        return (true);
                    }
                    else {
                        alert(4);
                        return (false);
                    }
                }
            }
        }

        function AfterClickHandler(node) {
            MappingField.innerText = node.Text;
        }
//       
//        function confirmCallBackFn(arg) {
//            if (arg == false) {
//                return
//            }
//        }

//        function ConfirmBeforeUnload() {
//            var result = window.confirm("'Are you sure you want to navigate away from this tree node or page without saving your data?'");
//            if (!result) {
//                return (false);
//            }
//        }

//        function CheckForDataSavingABCX() {
//            var result = window.confirm("'Are you sure you want to navigate away from this tree node or page without saving your data?'");
//            if (!result) {
//                return (false);
//            }
//        }

        function CheckForDataSaving() {
            alert(0);
            if (hdnRecordSaved.value == "0") {
                alert(1);
                if ((startPosition.value != "") || (endPosition.value != "")) {
                    alert(2);
                    if (confirm("Are you sure you want to navigate away from this tree node or submit functionality without saving your data?")) {
                        alert(3);
                        return (true);
                    }
                    else {
                        alert(4);
                        return (false);
                    }
                }
            }
        }

        window.onunload = unloadPage;

        function unloadPage() {
            alert(0);
            if (hdnRecordSaved.value == "0") {
                alert(1);
                if ((startPosition.value != "") || (endPosition.value != "")) {
                    alert(2);
                    if (confirm("Are you sure you want to navigate away from this page without saving your data?")) {
                        alert(3);
                        return (true);
                    }
                    else {
                        alert(4);
                        return (false);
                    }
                }
            }
        }

    </script>

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadTreeView1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadTreeView1" />
                    <telerik:AjaxUpdatedControl ControlID="recordIndicator" />
                    <telerik:AjaxUpdatedControl ControlID="startPosition" />
                    <telerik:AjaxUpdatedControl ControlID="endPosition" />
                    <telerik:AjaxUpdatedControl ControlID="ddlDataFmt" />
                    <telerik:AjaxUpdatedControl ControlID="chkCompositeField" />
                    <telerik:AjaxUpdatedControl ControlID="txtSeparator" />
                    <telerik:AjaxUpdatedControl ControlID="txtMapSeq" />
                    <telerik:AjaxUpdatedControl ControlID="txtSpecialCharRemoval" />
                    <telerik:AjaxUpdatedControl ControlID="whenStartPosition" />
                    <telerik:AjaxUpdatedControl ControlID="whenEndPosition" />
                    <telerik:AjaxUpdatedControl ControlID="whenRecordIndicator" />
                    <telerik:AjaxUpdatedControl ControlID="drpCompare" />
                    <telerik:AjaxUpdatedControl ControlID="hdnRecordSaved" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="chkCompositeField">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="chkCompositeField" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="whenStartPosition">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="whenStartPosition" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="whenEndPosition">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="whenEndPosition" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="whenRecordIndicator">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="whenRecordIndicator" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="value">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="value" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="hdnRecordSaved">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="hdnRecordSaved" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    </telerik:RadWindowManager>
    <body>
        <center>
            <form name="theform">
            <div>
                <table id="Table5" width="100%" cellpadding="1" cellspacing="1" border="0">
                    <tr valign="top">
                        <td width="90%">
                            <uc1:mapHeader ID="mapHeader1" runat="server" />
                            <br />
                        </td>
                        <td>
                            <fieldset>
                                <legend>Action</legend>
                                <table id="Table6" width="100%" runat="server" cellpadding="1" cellspacing="1" border="0">
                                    <tr>
                                        <td align="center">
                                            <asp:Button ID="btnValidation" runat="server" Text="Validate Map" Width="100px" Height="29px"
                                                OnClick="btnValidation_Click" OnClientClick="CheckForDataSaving();" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center">
                                            <asp:Button ID="btnExecMap" runat="server" Text="Run Map" Width="100px" Height="29px"
                                                Enabled="false" OnClick="btnExecMap_Click" OnClientClick="CheckForDataSaving();" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center">
                                            <input id="hdnRecordSaved" type="hidden" runat="server" />
                                        </td>
                                    </tr>
                                </table>
                            </fieldset>
                        </td>
                    </tr>
                </table>
                <table width="100%" cellpadding="1" cellspacing="1" border="1">
                    <tr valign="top">
                        <td width="15%">
                            <asp:Panel ID="pnlMapFields" runat="server" ScrollBars="Both" Height="430px">
                                <telerik:RadTreeView ID="RadTreeView1" runat="server" DataTextField="Description"
                                    DataFieldParentID="MapFieldparentID" DataFieldID="MapFieldID" DataValueField="MapFieldID"
                                    OnClientNodeClicking="onNodeClicking" CausesValidation="false" OnNodeClick="RadTreeView1_OnNodeClick">
                                </telerik:RadTreeView>
                            </asp:Panel>
                        </td>
                        <td>
                            <fieldset>
                                <legend>
                                    <asp:Label ID="FieldName" runat="server" Font-Bold="true" ForeColor="Blue"></asp:Label></legend>
                                <br />
                                <table id="Table1" width="100%" runat="server" cellpadding="1" cellspacing="1">
                                    <tr valign="top">
                                        <td colspan="2">
                                            <table id="Table7" width="100%" runat="server" cellpadding="1" cellspacing="1">
                                                <tr valign="top">
                                                    <td width="15%">
                                                        Mapping Field Name:
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="MappingField" runat="server" Font-Bold="true"></asp:Label>&nbsp (
                                                        <asp:Label ID="mapValue" runat="server" Font-Bold="true" ForeColor="blue"></asp:Label>
                                                        &nbsp;)
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                        <asp:TextBox ID="txtRec" runat="server" Width="100%" onMouseUp="mouseUP();"></asp:TextBox>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr valign="top">
                                        <td width="50%">
                                            <table id="Table3" width="100%" runat="server" cellpadding="1" cellspacing="1">
                                                <tr valign="top">
                                                    <td>
                                                        Record Indicator:
                                                    </td>
                                                    <td>
                                                        <asp:TextBox ID="recordIndicator" runat="server" Width="50px" Enabled="false"></asp:TextBox>
                                                    </td>
                                                    <td>
                                                        <asp:RequiredFieldValidator ID="rfvRecdIndicator" runat="server" ErrorMessage="Record Indicator required ONLY for Multiple records!"
                                                            ControlToValidate="recordIndicator" Font-Bold="true" Enabled="false"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr valign="top">
                                                    <td width="31%">
                                                        Start Position:
                                                    </td>
                                                    <td>
                                                        <telerik:RadNumericTextBox ID="startPosition" runat="server" Type="Number" Width="50px">
                                                            <NumberFormat DecimalDigits="0" />
                                                        </telerik:RadNumericTextBox>
                                                    </td>
                                                    <td>
                                                        <asp:RequiredFieldValidator ID="rfvStartPos" runat="server" ErrorMessage="Start Position required!"
                                                            ControlToValidate="startPosition" Font-Bold="true" Enabled="false"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr valign="top">
                                                    <td>
                                                        End Position:
                                                    </td>
                                                    <td>
                                                        <telerik:RadNumericTextBox ID="endPosition" runat="server" Type="Number" Width="50px">
                                                            <NumberFormat DecimalDigits="0" />
                                                        </telerik:RadNumericTextBox>
                                                    </td>
                                                    <td>
                                                        <asp:RequiredFieldValidator ID="rfvEndPos" runat="server" ErrorMessage="End Position required!"
                                                            ControlToValidate="endPosition" Font-Bold="true" Enabled="false"></asp:RequiredFieldValidator>
                                                    </td>
                                                    <td>
                                                        <asp:CompareValidator ID="cvStartEndPos" runat="server" ErrorMessage="End Position cannot be less than Start Position!"
                                                            ControlToValidate="startPosition" ControlToCompare="endPosition" Operator="LessThanEqual"
                                                            Type="Integer" Font-Bold="true"></asp:CompareValidator>
                                                    </td>
                                                </tr>
                                                <tr valign="top">
                                                    <td>
                                                        Data Format:
                                                    </td>
                                                    <td>
                                                        <asp:DropDownList ID="ddlDataFmt" runat="server" DataSourceID="LinqFieldTypeID" DataTextField="FieldTypeDesc"
                                                            DataValueField="FieldTypeID" AppendDataBoundItems="true">
                                                            <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                                                        </asp:DropDownList>
                                                        <asp:LinqDataSource ID="LinqFieldTypeID" runat="server" ContextTypeName="DataNet.Data.dataNetDataContext"
                                                            Select="new (FieldTypeDesc,FieldTypeID)" TableName="FieldTypes">
                                                        </asp:LinqDataSource>
                                                    </td>
                                                    <td>
                                                        <asp:RequiredFieldValidator ID="rfvDataFmt" runat="server" ErrorMessage="Data Format required!"
                                                            ControlToValidate="ddlDataFmt" Font-Bold="true"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                        <td width="50%">
                                            <table id="Table4" width="100%" runat="server" cellpadding="1" cellspacing="1">
                                                <tr valign="top">
                                                    <td width="30%">
                                                        Is a Composite Field:
                                                    </td>
                                                    <td>
                                                        <asp:CheckBox ID="chkCompositeField" runat="server" AutoPostBack="true" OnCheckedChanged="chkCompositeField_OnCheckedChanged" />
                                                    </td>
                                                </tr>
                                                <tr valign="top">
                                                    <td>
                                                        Separator:
                                                    </td>
                                                    <td>
                                                        <asp:TextBox ID="txtSeparator" runat="server" Width="50px"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="rfvSeparator" runat="server" ErrorMessage="Separator required when Composite selected!"
                                                            ControlToValidate="txtSeparator" Font-Bold="true" Enabled="false"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr valign="top">
                                                    <td width="15%">
                                                        Map Sequence:
                                                    </td>
                                                    <td>
                                                        <telerik:RadNumericTextBox ID="txtMapSeq" runat="server" Width="50px">
                                                            <NumberFormat DecimalDigits="0" />
                                                        </telerik:RadNumericTextBox>
                                                        <asp:RequiredFieldValidator ID="rfvMapSeq" runat="server" ErrorMessage="Map Sequence required when Composite selected!"
                                                            ControlToValidate="txtMapSeq" Font-Bold="true" Enabled="false"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                                <tr valign="top">
                                                    <td width="15%">
                                                        Special Characters Removal:
                                                    </td>
                                                    <td>
                                                        <asp:TextBox ID="txtSpecialCharRemoval" runat="server"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="rfvSpecialCharRemoval" runat="server" ErrorMessage="Special Characters Removal required when Composite selected!"
                                                            ControlToValidate="txtSpecialCharRemoval" Font-Bold="true" Enabled="false"></asp:RequiredFieldValidator>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr valign="top">
                                        <td colspan="2">
                                            <fieldset>
                                                <legend><b>ONLY WHEN</b></asp:Label></legend>
                                                <table id="Table2" width="100%" runat="server" cellpadding="1" cellspacing="1">
                                                    <tr valign="top">
                                                        <td width="15%">
                                                            Start Position:
                                                        </td>
                                                        <td>
                                                            <telerik:RadNumericTextBox ID="whenStartPosition" runat="server" OnTextChanged="whenStartPosition_OnTextChanged"
                                                                AutoPostBack="true">
                                                                <NumberFormat DecimalDigits="0" />
                                                            </telerik:RadNumericTextBox>
                                                        </td>
                                                        <td>
                                                            <asp:RequiredFieldValidator ID="rfvWhenStartPos" runat="server" ErrorMessage="*When* Start Position required if filling in 1 or more items in this section!"
                                                                ControlToValidate="whenStartPosition" Font-Bold="true" Enabled="false"></asp:RequiredFieldValidator>
                                                        </td>
                                                    </tr>
                                                    <tr valign="top">
                                                        <td width="15%">
                                                            End Position:
                                                        </td>
                                                        <td>
                                                            <telerik:RadNumericTextBox ID="whenEndPosition" runat="server" OnTextChanged="whenEndPosition_OnTextChanged"
                                                                AutoPostBack="true">
                                                                <NumberFormat DecimalDigits="0" />
                                                            </telerik:RadNumericTextBox>
                                                        </td>
                                                        <td>
                                                            <asp:RequiredFieldValidator ID="rfvWhenEndPos" runat="server" ErrorMessage="*When* End Position required if filling in 1 or more items in this section!"
                                                                ControlToValidate="whenEndPosition" Font-Bold="true" Enabled="false"></asp:RequiredFieldValidator>
                                                        </td>
                                                        <td>
                                                            <asp:CompareValidator ID="cvWhenStartEndPos" runat="server" ErrorMessage="*When* End Position cannot be less than *When* Start Position!"
                                                                ControlToValidate="whenStartPosition" ControlToCompare="whenEndPosition" Operator="LessThanEqual"
                                                                Enabled="false" Type="Integer" Font-Bold="true"></asp:CompareValidator>
                                                        </td>
                                                    </tr>
                                                    <tr valign="top">
                                                        <td width="15%">
                                                            Record Indicator:
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="whenRecordIndicator" runat="server" OnTextChanged="whenRecordIndicator_OnTextChanged"
                                                                AutoPostBack="true"></asp:TextBox>
                                                        </td>
                                                        <td>
                                                            <asp:RequiredFieldValidator ID="rfvWhenRecdInd" runat="server" ErrorMessage="*When* Record Indicator required ONLY for Multiple records if filling in 1 or more items in this section!"
                                                                ControlToValidate="whenRecordIndicator" Font-Bold="true" Enabled="false"></asp:RequiredFieldValidator>
                                                        </td>
                                                    </tr>
                                                    <tr valign="top">
                                                        <td width="15%">
                                                            Compare:
                                                        </td>
                                                        <td>
                                                            <asp:DropDownList ID="drpCompare" runat="server" Enabled="false">
                                                                <asp:ListItem Value="0" Text="Equal To" Selected="True"></asp:ListItem>
                                                                <asp:ListItem Value="1" Text="Not Equal To"></asp:ListItem>
                                                                <asp:ListItem Value="2" Text="Greater Than"></asp:ListItem>
                                                                <asp:ListItem Value="3" Text="Greater Than and Equal To"></asp:ListItem>
                                                                <asp:ListItem Value="4" Text="Less Than"></asp:ListItem>
                                                                <asp:ListItem Value="5" Text="Less Than and Equal To"></asp:ListItem>
                                                            </asp:DropDownList>
                                                        </td>
                                                        <td>
                                                            <asp:RequiredFieldValidator ID="rfvCompare" runat="server" ErrorMessage="*When* Compare required ONLY for Multiple records if filling in 1 or more items in this section!"
                                                                ControlToValidate="drpCompare" Font-Bold="true" Enabled="false"></asp:RequiredFieldValidator>
                                                        </td>
                                                    </tr>
                                                    <tr valign="top">
                                                        <td width="15%">
                                                            Value:
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="value" runat="server" OnTextChanged="whenvalue_OnTextChanged" AutoPostBack="true"></asp:TextBox>
                                                        </td>
                                                        <td>
                                                            <asp:RequiredFieldValidator ID="rfvValue" runat="server" ErrorMessage="*When* Value required ONLY for Multiple records if filling in 1 or more items in this section!"
                                                                ControlToValidate="value" Font-Bold="true" Enabled="false"></asp:RequiredFieldValidator>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </fieldset>
                                        </td>
                                    </tr>
                                    <tr valign="top">
                                        <td width="15%">
                                            &nbsp;
                                        </td>
                                        <td>
                                            <asp:Button ID="Save" runat="server" Text="Save" Width="150" OnClick="Save_Click" OnClientClick="CheckForDataSaving();" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <asp:Panel ID="Data" runat="server" GroupingText="Data" Width="100%">
                                                <asp:ListBox ID="lstData" runat="server" Width="100%" Font-Size="XX-Small" onchange="lstData_onClick();" >
                                                </asp:ListBox>
                                            </asp:Panel>
                                        </td>
                                    </tr>
                                </table>
                            </fieldset>
                        </td>
                    </tr>
                </table>
            </div>
            </form>
        </center>
    </body>

    <script type="text/javascript">
        var lstData = document.getElementById("<%= lstData.ClientID%>");
        var txtRec = document.getElementById("<%= txtRec.ClientID%>");
        var startPosition = document.getElementById("<%= startPosition.ClientID%>");
        var endPosition = document.getElementById("<%= endPosition.ClientID%>");
        var mapValue = document.getElementById("<%= mapValue.ClientID%>");
        var MappingField = document.getElementById("<%= MappingField.ClientID%>");
        var FieldName = document.getElementById("<%= FieldName.ClientID%>");
        var hdnRecordSaved = document.getElementById("<%= hdnRecordSaved.ClientID%>");
    </script>

</asp:Content>

0
Simon
Telerik team
answered on 23 Aug 2010, 11:17 AM
Hi William Yeager,

The client ID of the hidden input is more complex that the one set in the server-side ID property. You can get the correct client ID by using serer-side expressions in your JS code in this way:
var hdnRecordSaved = document.getElementById("<%= hdnRecordSaved.ClientID %>");

Have you tried this approach?

Regards,
Simon
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Bill
Top achievements
Rank 2
answered on 23 Aug 2010, 03:06 PM
Simon, what I needed to do was the following... Setting up the variable on a one time basis at the bottom of the page wasn't enough for some reason. I had to get them again as follows. I handled the hdnRecordResponse variable in the code behind whether or not to process the next node that was clicked or to stay at the current node.

        function onNodeClicking(sender, args) {
            MappingField.innerText = args.get_node().get_text();
            FieldName.innerText = args.get_node().get_parent().get_text().toUpperCase() + " ==> " + args.get_node().get_text();

            var hdnRecordSaved = document.getElementById("<%= hdnRecordSaved.ClientID %>");
            var startPosition = document.getElementById("<%= startPosition.ClientID%>");
            var endPosition = document.getElementById("<%= endPosition.ClientID%>");

            if (hdnRecordSaved.value == "0") {
                if ((startPosition.value != "") || (endPosition.value != "")) {
                    var hdnRecordResponse = document.getElementById("<%= hdnRecordResponse.ClientID %>");
                    if (confirm("Are you sure you want to navigate away from this tree node or submit functionality without saving your data?")) {
                        hdnRecordResponse.value = "1";
                        return (true);
                    }
                    else {
                        hdnRecordResponse.value = "0";
                        return (false);
                    }
                }
            }
        }

0
Simon
Telerik team
answered on 26 Aug 2010, 11:02 AM
Hi William Yeager,

So what happens when you use the <%=%> expressions and you run this code? Do you receive any JavaScript errors?

All the best,
Simon
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Bill
Top achievements
Rank 2
answered on 26 Aug 2010, 03:18 PM
Simon, this has been resolved....

There were some js errors on the page which was indirectly causing the issue.
Tags
TreeView
Asked by
Bill
Top achievements
Rank 2
Answers by
Bill
Top achievements
Rank 2
Simon
Telerik team
Share this question
or