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

RadToolTip show from code for each textbox

5 Answers 279 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Fabio Cirillo
Top achievements
Rank 1
Fabio Cirillo asked on 21 Mar 2013, 06:35 PM
Hi,
can i use RadToolTip for to see the message for each radtextbox is empty? And how can do it?

I would that if one textbox is empty, the radtooltip appear next to the item. All from code behind as if it were a message infomation.

Bye

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Mar 2013, 10:20 AM
Hi Fabio,

Please have a look into the following sample code snippet to dynamically display a tool tip if the RadTextBox is empty. In the following code, on RadButton server side click, I checked if the text box is empty and if the text box is empty, tool tip is displayed.

ASPX:
<telerik:RadTextBox ID="RadTextBox1" runat="server" Label="Name :">
</telerik:RadTextBox>
<telerik:RadButton runat="server" ID="Button1" Text="button" OnClick="RadButton1_Click">
</telerik:RadButton>

C#:
protected void RadButton1_Click(object sender, EventArgs e)
{
    RadToolTip tip = new RadToolTip();
    this.form1.Controls.Add(tip);
    RadToolTip RadToolTip1 = new RadToolTip();
    if (String.IsNullOrWhiteSpace(RadTextBox1.Text))
    {
        tip.Text = "TextBox is empty";
        tip.TargetControlID = "RadTextBox1";
        tip.Width = Unit.Pixel(200);
        tip.Height = Unit.Pixel(50);
        tip.Position = ToolTipPosition.BottomRight;
        tip.HideEvent = ToolTipHideEvent.ManualClose;
        tip.Show();
    }
}

Thanks,
Princy.
0
Fabio Cirillo
Top achievements
Rank 1
answered on 22 Mar 2013, 12:12 PM
Hi,

i wrote this code vb net:


Imports System
Imports System.Data
Imports System.Web
Imports Telerik.Web.UI
 
Public Class InsertCategory
    Inherits RadAjaxPage
 
    Protected Sub Imgbtnsave_Click(sender As Object, e As EventArgs)
        Dim tip As RadToolTip = New RadToolTip
        form1.Controls.Add(tip)
        Dim RadToolTip1 As RadToolTip = New RadToolTip
        tip.Text = "Campo obbligatorio"
        tip.TargetControlID = "Txtcategory"
        tip.Width = Unit.Pixel(200)
        tip.Height = Unit.Pixel(50)
        tip.Position = ToolTipPosition.MiddleRight
        tip.HideEvent = ToolTipHideEvent.ManualClose
        tip.Show()
    End Sub
End Class

and this is aspx code:

<form id="form1" runat="server">
 <div>
     <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
     </telerik:RadScriptManager>
         <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" height="230px"
             width="350px">
             <div style="padding-top:60px;">
                 <table style="width:100%;">
                     <tr>
                         <td>
                             <asp:Label ID="Label1" runat="server" Text="Inserire la nuova categoria"></asp:Label>
                         </td>
                     </tr>
                     <tr>
                         <td>
                             <telerik:RadTextBox ID="Txtcategory" Runat="server"
                                 LabelWidth="132px" Skin="Sunset"
                                 Width="181px" Height="21px">
                             </telerik:RadTextBox>
                         </td>
                     </tr>
                     <tr>
                         <td style="text-align:center;">
                             <asp:ImageButton ID="Imgbtnsave" runat="server"
                                 ImageUrl="~/Image/conferma.png" OnClick="Imgbtnsave_Click" />
                         </td>
                     </tr>
                 </table>
             </div>
         </telerik:RadAjaxPanel>  
 </div>
 </form>


but the tooltip does not appear you can not see, where am I wrong?

I noticed that if I remove the radajaxpanel everything works, except that I in my aspx pages the radjajxpanel there ... I tried to inserie an updatepanel but nothing you only see the tooltip without radajaxpaenl or updatepanel ... but as I said the radajaxpanel there must be
0
Princy
Top achievements
Rank 2
answered on 25 Mar 2013, 05:42 AM
Hi Fabio,

The tooltip is not displayed when you are using RadAjaxPanel or UpdatePanel because you might not have added the RadToolTip to the RadAjaxPanel in code behind. Please check the following code I tried.

ASPX:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
    <telerik:RadTextBox ID="RadTextBox1" runat="server" Label="Name :">
    </telerik:RadTextBox>
    <telerik:RadButton runat="server" ID="Button1" Text="button" OnClick="RadButton1_Click">
    </telerik:RadButton>
</telerik:RadAjaxPanel>

C#:
protected void RadButton1_Click(object sender, EventArgs e)
{
    RadToolTip tip = new RadToolTip();
    tip.ID = "RadTooltip1";
    RadAjaxPanel1.Controls.Add(tip); // Adding ToolTip to RadAjaxPanel to update.
    if (String.IsNullOrWhiteSpace(RadTextBox1.Text))
    {
        tip.Text = "TextBox is empty";
        tip.TargetControlID = "RadTextBox1";
        tip.Width = Unit.Pixel(200);
        tip.Height = Unit.Pixel(50);
        tip.Position = ToolTipPosition.BottomRight;
        tip.HideEvent = ToolTipHideEvent.ManualClose;
        tip.Show();
    }
}

Thanks,
Princy.
0
Fabio Cirillo
Top achievements
Rank 1
answered on 25 Mar 2013, 09:45 AM
There is a problem, first of all on the main page the tooltips can not be seen even with your new code but I have better control. I wrote your code in a new page with ajaxpanel and it works but when I click the button repeatedly, the tooltip appears next to the textbox once again looks away .. see the two pictures I posted. Why?
0
Princy
Top achievements
Rank 2
answered on 26 Mar 2013, 09:50 AM
Hi Fabio,

Unfortunately, I couldn't replicate the issue you are facing. Its working fine at my end. Could you please provide the entire code so that I can replicate?

Thanks,
Princy.
Tags
ToolTip
Asked by
Fabio Cirillo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Fabio Cirillo
Top achievements
Rank 1
Share this question
or