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

Tooltip empty after postback when dynamically added in a custom webcontrol.

3 Answers 190 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Alain Nagels
Top achievements
Rank 1
Alain Nagels asked on 06 Aug 2010, 09:24 AM
Hello

We've build a custom web control (not a user control) which adds a RadToolTip dynamically.
The tooltip is created and added to the Controls-collection of the webcontrol in the OnLoad-event.
The text of the tooltip is set in the RenderContents-event of the webcontrol.

This control is used in rows of a RadGrid and it works fine when the page is requested but after a postback the tooltip still appears but the text is empty.

The difference seems to be that on a page request the telerik tooltip somehow adds statements like :

Sys.Application.add_init(function() {
    $create(Telerik.Web.UI.RadToolTip, {"_cssClass":"","_manualCloseButtonText":"Close","clientStateFieldID":"ctl00_ctl00_ContentPlaceholder1_MiddleColumn_ctl00_CandidateListGrid_ctl00_ctl04_MessageUSGToolTip_ctl00_ClientState","formID":"aspnetForm","relativeTo":1,"skin":"USGFOEXTelerik","targetControlID":"ctl00_ctl00_ContentPlaceholder1_MiddleColumn_ctl00_CandidateListGrid_ctl00_ctl04_MessageImage","text":"Dit is een bericht verkregen uit hercules:\u003cbr /\u003ede status is ToValidate"}, null, null, $get("ctl00_ctl00_ContentPlaceholder1_MiddleColumn_ctl00_CandidateListGrid_ctl00_ctl04_MessageUSGToolTip_ctl00"));
});

When a postback is done these statements are missing.

Why are these statements missing after a postback? 



3 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 11 Aug 2010, 03:50 PM
Hello Alain Nagels,

 The mentioned code is the creating of the client object of teh tooltip. However, I cannot say what is teh problem in your case based only on the provided information. What I can assume is that you have some incorrect AJAX settings or you are dynamically creating controls either at not suitable point of teh page lifecycle or you have not recreated them on next postbacks.

If the provided assumptions do not help and you need further assistance, please prepare a sample fully runnable reproduction demo (use a fake programmatic datasource if needed), open a new support ticket and send it to us along with step by step instructions and explanations and we will debug it and do our best to help.

Greetings,
Svetlina
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
Thilo
Top achievements
Rank 1
answered on 08 Dec 2011, 03:32 PM
Hy Svetlina

I have the same issue.
I do the following:

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                License = new clLicense();
 
                RadTabStrip1.SelectedIndex = 0;
                licenseFormPage.Selected = true;
            }
 
            PlaceHolder1.Controls.Clear();
            PlaceHolder1.Controls.Add(generateLicenseForm());
        }

And in the method generateLicenseForm(); I do the following:

Panel container = new Panel();
            Panel p;
            Table table;
            TableRow row;
            TableCell cell;
            CustomTextBox textBox;
            RadToolTip toolTip;
            RadToolTip toolTip2;
            CustomSaveButton btnSave;
            Label lbl;
            clLicenseGroup group;
            clLicenseProperty prop;
            short tabIndex = 1;
 
            //Ãœber alle Gruppen iterieren
            for (int i = 0; i < License.LicenseGroups.Count; i++)
            {
                group = (clLicenseGroup)License.LicenseGroups[i];
 
                p = new Panel();
                table = new Table();
                p.GroupingText = group.Name;
                p.CssClass = "keyValuePair";
 
                for (int j = 0; j < group.LicenseProperties.Count; j++)
                {
                    prop = (clLicenseProperty)group.LicenseProperties[j];
                     row = new TableRow();
  
                    //Label erstellen
                    cell = new TableCell();
                    cell.CssClass = "labelCell";
                    lbl = new Label();
                    lbl.Text = prop.TemplateName + ": ";
                    cell.Controls.Add(lbl);
                    row.Controls.Add(cell);
 
                    //Textbox erstellen
                    cell = new TableCell();
                    cell.CssClass = "textBoxCell";
 
                    textBox = new CustomTextBox();                
                    textBox.ID = "txt" + prop.Name;
                    textBox.GroupName = group.Name;
                    textBox.PropertyName = prop.Name;
                    textBox.ToolTip = prop.Description;
 
                    textBox.CssClass = "valueBox";
                    textBox.EnableViewState = true;
                    textBox.Width = new Unit(400, UnitType.Pixel);
                    textBox.TabIndex = tabIndex;
 
                    toolTip = new RadToolTip();
                    toolTip.TargetControlID = textBox.ID;
                    toolTip.Text = prop.Description;
 
                    cell.Controls.Add(textBox);
                    cell.Controls.Add(toolTip);
                    row.Controls.Add(cell);
 
                    //Speichernbutton der Eigenschaft erstellen
                    cell = new TableCell();
                    btnSave = new CustomSaveButton();
                    btnSave.CssClass = "btnBox";
                    btnSave.Text = "...";
                    btnSave.ID = "btnSave" + prop.Name;
                    btnSave.GroupName = group.Name;
                    btnSave.PropertyName = prop.Name;
                    //btnSave.Enabled = false;
                    btnSave.Click += new EventHandler(btnSave_Click);
 
                    toolTip2 = new RadToolTip();
                    toolTip2.TargetControlID = btnSave.ID;
                    toolTip2.Text = "Neue Eigenschaft im LifeCycleManagement speichern";
 
                    cell.Controls.Add(btnSave);
                    cell.Controls.Add(toolTip2);
 
                    row.Controls.Add(cell);
                    table.Rows.Add(row);
                    tabIndex++;
                }
 
                //Property Control hinzufügen
                p.Controls.Add(table);
                container.Controls.Add(p);
            }
 
            return container;
        }

After a Postback on my Site the tooltips from the textboxes are gone away. The strange thing is, that the tooltip from the buttons (toolTip2 in the code) are still there and visible.

Can you please have a look what is wrong there ?

Thanks and kind regards

Chris
0
Marin Bratanov
Telerik team
answered on 09 Dec 2011, 05:19 PM
Hello Christian,

This logic seems to work fine on my end: http://screencast.com/t/DUnHZv61. I am also attaching my test page here so you can compare it with yours, as I had to comment out some of your custom functionality.

Currently what I suspect might be happening is that when recreating the controls the IDs you supply after a postback are not the same as the original ones and there is a mismatch. Please debug your code and see if the controls are properly recreated.

I can also suggest that you create these dynamic controls earlier - in the page_init event, as explained in the following article I recommend you examine carefully: http://couldbedone.blogspot.com/2007/06/dynamically-created-controls-in-aspnet.html.


Kind regards,
Marin
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
Tags
ToolTip
Asked by
Alain Nagels
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Thilo
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or