using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;
[assembly:TagPrefix("MyWebMenu","zbjg")]
namespace MyTools
{
/// <summary>
/// Summary description for MyWebMenu.
/// </summary>
public class MyWebMenu : System.Web.UI.WebControls.Panel
{
public MyWebMenu()
{
this.BorderStyle = BorderStyle.Outset;
this.BackColor = Color.Silver;
this.BorderWidth= new Unit(2);
}
protected override void Render(HtmlTextWriter writer)
{
base.Render (writer);
writer.RenderBeginTag(HtmlTextWriterTag.Script);
writer.WriteLine("<!--");
writer.WriteLine(" document.getElementById('" + this.ClientID + "').style.position = 'absolute';");
writer.WriteLine(" document.getElementById('" + this.ClientID + "').style.display = 'none';");
writer.WriteLine(" function Hide_MyMenu() {");
writer.WriteLine(" var tempDiv = document.getElementById('" + this.ClientID + "');");
writer.WriteLine(" if(tempDiv.offsetLeft > window.event.clientX + 25) {");
writer.WriteLine(" tempDiv.style.display = 'none'; }");
writer.WriteLine(" if(tempDiv.offsetLeft + tempDiv.offsetWidth < window.event.clientY - 25) {");
writer.WriteLine(" tempDiv.style.display = 'none'; }");
writer.WriteLine(" if(tempDiv.offsetTop > window.event.clientY + 25) {");
writer.WriteLine(" tempDiv.style.display = 'none'; }");
writer.WriteLine(" if(tempDiv.offsetTop + tempDiv.offsetHeight < window.event.clientY - 25) {");
writer.WriteLine(" tempDiv.style.display = 'none'; }");
writer.WriteLine(" }");
writer.WriteLine("");
writer.WriteLine(" function Show_MyMenu() {");
writer.WriteLine(" var tempDiv = document.getElementById('" + this.ClientID + "');");
writer.WriteLine(" tempDiv.style.left = window.event.clientX ;");
writer.WriteLine(" tempDiv.style.top = window.event.clientY ;");
writer.WriteLine(" tempDiv.style.display = '' ;");
writer.WriteLine(" return false; }");
writer.WriteLine("");
writer.WriteLine(" document.oncontextmenu = Show_MyMenu;");
writer.WriteLine(" document.onmousemove = Hide_MyMenu;");
writer.WriteLine("//-->");
writer.RenderEndTag();
}
}
}
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;
[assembly:TagPrefix("MyWebMenu","zbjg")]
namespace MyTools
{
/// <summary>
/// Summary description for MyWebMenu.
/// </summary>
public class MyWebMenu : System.Web.UI.WebControls.Panel
{
public MyWebMenu()
{
this.BorderStyle = BorderStyle.Outset;
this.BackColor = Color.Silver;
this.BorderWidth= new Unit(2);
}
protected override void Render(HtmlTextWriter writer)
{
base.Render (writer);
writer.RenderBeginTag(HtmlTextWriterTag.Script);
writer.WriteLine("<!--");
writer.WriteLine(" document.getElementById('" + this.ClientID + "').style.position = 'absolute';");
writer.WriteLine(" document.getElementById('" + this.ClientID + "').style.display = 'none';");
writer.WriteLine(" function Hide_MyMenu() {");
writer.WriteLine(" var tempDiv = document.getElementById('" + this.ClientID + "');");
writer.WriteLine(" if(tempDiv.offsetLeft > window.event.clientX + 25) {");
writer.WriteLine(" tempDiv.style.display = 'none'; }");
writer.WriteLine(" if(tempDiv.offsetLeft + tempDiv.offsetWidth < window.event.clientY - 25) {");
writer.WriteLine(" tempDiv.style.display = 'none'; }");
writer.WriteLine(" if(tempDiv.offsetTop > window.event.clientY + 25) {");
writer.WriteLine(" tempDiv.style.display = 'none'; }");
writer.WriteLine(" if(tempDiv.offsetTop + tempDiv.offsetHeight < window.event.clientY - 25) {");
writer.WriteLine(" tempDiv.style.display = 'none'; }");
writer.WriteLine(" }");
writer.WriteLine("");
writer.WriteLine(" function Show_MyMenu() {");
writer.WriteLine(" var tempDiv = document.getElementById('" + this.ClientID + "');");
writer.WriteLine(" tempDiv.style.left = window.event.clientX ;");
writer.WriteLine(" tempDiv.style.top = window.event.clientY ;");
writer.WriteLine(" tempDiv.style.display = '' ;");
writer.WriteLine(" return false; }");
writer.WriteLine("");
writer.WriteLine(" document.oncontextmenu = Show_MyMenu;");
writer.WriteLine(" document.onmousemove = Hide_MyMenu;");
writer.WriteLine("//-->");
writer.RenderEndTag();
}
}
}