I have an UserControl, it is a ToolTip.
.ascx :
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucTooltip.ascx.cs" Inherits="Portail.formulaires.ucTooltip" debug="true"%>
<div id="dhtmltooltip" style="z-index:9999999999; display:inline-block;">
<div id="dhtmltooltip_title">
</div>
<div id="dhtmltooltip_content">
</div>
</div>
.cs :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Portail.formulaires
{
public partial class ucTooltip : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterClientScriptInclude("Hint", Page.ResolveUrl("~/Scripts/hint.js"));
}
}
}
This control is really simple, I simply add a reference and the control to the page I want to use it :
<%@ Register src="Controles/ucTooltip.ascx" tagname="ucTooltip" tagprefix="ucTT" %>
...
<ucTT:ucTooltip ID="tooltip" runat="server" />
...
So, the control is loaded and the script is added to the page.
But I am trying to do something more elaborate. Given that I have a lot control that need a tooltip, I decided to add an Event(it will show and hide the tooltip) to my usercontrol's base. All the usercontrol is use inside my main page (The tooltip is accessible from this page).
First, I have tried something like that :
protected virtual void Page_Load(object sender, EventArgs e)
{
Attributes.Add("OnMouseOver", "alert('d')");
}
On the control's base page load, I had an attribute to throw the event "OnMouseOver" to the control.
But it don't work, I am very confuse why...