Javascript label updates in RadWindow do not show in code behind

3 posts, 1 answers
  1. Blake
    Blake avatar
    6 posts
    Member since:
    Nov 2011

    Posted 29 Feb 2012 Link to this post

    I am using the RadWindow as a dialog for updating some user notes on my database.  I have the RadWindow defined on my main page.  When the user clicks a button, I open the RadWindow and set several field values on the window using Javascript.  The user then enters their data and clicks a "Submit" button.

    In the code behind, I am getting the data from the fields on the RadWindow and then calling my database update routine.  The issue I am having is this.  When I pop the window up using Javascript, I am modifying some label, RadTextbox, and Radbutton control text values.  In the code behind I need to use the values. The text values are fine but the labels that I change in the Javascript do not have the updated values in the code behind.  Does anybody know why?

    I am using the "OnClientShow" event to call the Javascript routine to modify the RadWindow fields.  Here is the routine:

    // This function moves the data from various fields in the carrierinformation page to the data
    // update request screen being opened. Some of the fields are actual data fields from the screen
    // while others are hidden fields.
    function SetDataUpdWindowFields() {
        // Get Carrier name and set.
        var CarrName = GetCarrierName();
        var DUCarrName = document.getElementById("<%= lblDataUpdCarrName.ClientID %>");
        DUCarrName.innerText = CarrName;
        // Get Email Address and Set.
        var EmailAddr = document.getElementById("<%= hfEmailAddr.ClientID %>");
        var DUEmailAddr = $find("<%= rtxtDataUpdEmailAdr.ClientID %>");
        // Set the user notify option to yes.
        $find("<%= roptDataUpdNotifyYes.ClientID %>").set_checked(true);
        $find("<%= roptDataUpdNotifyNo.ClientID %>").set_checked(false);
        // Get and set the location name.
        var rpageview = GetCurrPageView();
        if (rpageview) {
            var lblLocName = $telerik.$(".cdhdr-carrlocationheader", rpageview._element).html();
            if (lblLocName) {
                var DULocName = document.getElementById("<%= lblDataUpdLocName.ClientID %>");
                DULocName.innerText = lblLocName;

    It is specifically the DUCarrName and DULocName values on the RadWindow that show correctly on the actual window, but do not have the new values in the code behind.

    Any help would be greatly appreciated.

  2. Answer
    Marin Bratanov
    Marin Bratanov avatar
    5925 posts

    Posted 02 Mar 2012 Link to this post

    Hi Blake,

    A label renders as a span and does not retain its value across postbacks. This is just the way the control works. You can easily confirm it in the simple page I am attaching here. More information about this is also available in the net, e.g. this page. What I can suggest as a simple workaround is to use hidden fields and populate their values as well for use in the code-behind. You can also search the net for other ideas.

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Blake
    Blake avatar
    6 posts
    Member since:
    Nov 2011

    Posted 02 Mar 2012 Link to this post

    Thanks Marin.  I figured it was something like that.  I got around the problem by swapping out the labels for textboxes and setting them to read only with no border. 

    Thanks again.

Back to Top