How to manipulate title="" by c#?

Asked

Viewed 100 times

3

It is possible to put the text of the title="" attribute by c#?

The title I intend to manipulate is:

<asp:HyperLink runat="server" ID="linkTitle" CssClass="link_title search-result-link-title tooltip-init" Target="_top"  data-toggle="tooltip" data-placement="top" title="título" data-original-title="título" />
  • You who change the text of title="title" or ID="linkTitle" ?

  • @Amanda-Vieira you need to be more explicit in your doubt. Want to manipulate before rendering the title or after the page has been loaded ? There are many different ways to solve, but doubt needs to be better addressed !

  • 1

    Hello @Mauríciojúnior sorry I didn’t ask correctly, but you understood perfectly. Your comment "Hyperlink1.Tooltip = "TEXT TO BE RENDERED IN ELEMENT TITLE A HREF!" worked and was exactly what I wanted! Thanks!

  • @Marconcíliosouza the title="". Mauriício’s answer has already helped me. Thanks.

  • Jóia @Amandavieira ... how nice that you got! Good job!

2 answers

4

Using Javascript, make an ajax request:

$.ajax({ 
          type: "POST",
          async: false,
          url: '@Url.Action("SetarTitulo", "Controller")',
          contentType: 'application/json',
          dataType: "json",
          data: JSON.stringify({ }),
          success: function (data) {
                   title = data.Retorno.Titulo;
                   $("#linkTitle title").html(title);
          }
      });

Controller:

    public JsonResult SetarTitulo(){

         var titulo = "Meu titulo";

         return Json(new RetornoAjax
         {
            Retorno = new
            {
                Titulo = titulo
            }
    });
}

3


Estate ToolTip !

<asp:HyperLink ToolTip="Aqui é renderizado o TITLE!">

I suggest you change the title of the question to ASP.NET, C# is the syntax used in ASP.NET!

Code Behind uses the same property !

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HyperLink1.ToolTip = "TEXTO A SER RENDERIZADO NO TITLE DO ELEMENTO A HREF!";
        }
    }
}

Exemplo Código

  • I didn’t understand anything, actually I said something?

  • @Marconcíliosouza I’m sorry, I thought you denied my answer!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.