RadToolTip show from code for each textbox

6 posts, 0 answers
  1. Fabio Cirillo
    Fabio Cirillo avatar
    180 posts
    Member since:
    Jan 2010

    Posted 21 Mar 2013 Link to this post

    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
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Mar 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Fabio Cirillo
    Fabio Cirillo avatar
    180 posts
    Member since:
    Jan 2010

    Posted 22 Mar 2013 Link to this post

    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
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Mar 2013 Link to this post

    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.
  6. Fabio Cirillo
    Fabio Cirillo avatar
    180 posts
    Member since:
    Jan 2010

    Posted 25 Mar 2013 Link to this post

    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?
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 Mar 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017