mouse info for WebCustomControl.

Q

Qwert

Hello,

if you have a WebCustomControl ( inherits from
System.Web.UI.WebControls.WebControl ), how do you create an event that
responses to the movement of the cursor above the control?

System.Web.UI.WebControls.ImageButton can determine the location of the
mouse relative to its origin. The 'tooltip' event can determine when the
mouse is above the control.

How do you create a 2 events that determine when the cursor enters and
leaves your custom control?

Thanks.
 
G

Guest

Hi Qwert,

you can only operate on the client with such events. That means, you cannot
create a server-side event for mousmovement. This would reload the page each
time a user moves with the mouse over the spcific control.

But you can operate with the client-side-events. The output must be similar
to the following statement (rendered control):

<... onmouemove="myfunction(this);" ...>

The argument "this" is not necessary (just for demonstration).
You can do this in your code-behind:

override void OnPreRender(EventArgs e)
{
base.Attributes ["onmouemove"] = "myfunction(this);";

if (!Page.IsClientScriptBlockRegistered ("myfunction"))
{
Page.RegisterClientScriptBlock ("myfunction", "... your js script ...");
}

base.OnePreRender (e);
}
 
Q

Qwert

Client side event. Makes sense. Allthough I have no idea what your code
means. I'll look into it. Thanks.


Hi Qwert,

you can only operate on the client with such events. That means, you
cannot
create a server-side event for mousmovement. This would reload the page
each
time a user moves with the mouse over the spcific control.

But you can operate with the client-side-events. The output must be
similar
to the following statement (rendered control):

<... onmouemove="myfunction(this);" ...>

The argument "this" is not necessary (just for demonstration).
You can do this in your code-behind:

override void OnPreRender(EventArgs e)
{
base.Attributes ["onmouemove"] = "myfunction(this);";

if (!Page.IsClientScriptBlockRegistered ("myfunction"))
{
Page.RegisterClientScriptBlock ("myfunction", "... your js script
...");
}

base.OnePreRender (e);
}

Qwert said:
Hello,

if you have a WebCustomControl ( inherits from
System.Web.UI.WebControls.WebControl ), how do you create an event that
responses to the movement of the cursor above the control?

System.Web.UI.WebControls.ImageButton can determine the location of the
mouse relative to its origin. The 'tooltip' event can determine when the
mouse is above the control.

How do you create a 2 events that determine when the cursor enters and
leaves your custom control?

Thanks.
 
G

Guest

Hi Qwert,

you can add client-side events to your html-tags by specifying the event's
name and the method to execute.

http://www.quirksmode.org/js/events_mouse.html

To add such a client-side-event using ASP.Net controls you must specify
these events in the Attribute property of your control.

myLabel.Attributes ["onclick"] = "myfunction();"

would render the following html-output:

<span id="..." onclick="myfunction();">...</span>

patrick

Qwert said:
Client side event. Makes sense. Allthough I have no idea what your code
means. I'll look into it. Thanks.


Hi Qwert,

you can only operate on the client with such events. That means, you
cannot
create a server-side event for mousmovement. This would reload the page
each
time a user moves with the mouse over the spcific control.

But you can operate with the client-side-events. The output must be
similar
to the following statement (rendered control):

<... onmouemove="myfunction(this);" ...>

The argument "this" is not necessary (just for demonstration).
You can do this in your code-behind:

override void OnPreRender(EventArgs e)
{
base.Attributes ["onmouemove"] = "myfunction(this);";

if (!Page.IsClientScriptBlockRegistered ("myfunction"))
{
Page.RegisterClientScriptBlock ("myfunction", "... your js script
...");
}

base.OnePreRender (e);
}

Qwert said:
Hello,

if you have a WebCustomControl ( inherits from
System.Web.UI.WebControls.WebControl ), how do you create an event that
responses to the movement of the cursor above the control?

System.Web.UI.WebControls.ImageButton can determine the location of the
mouse relative to its origin. The 'tooltip' event can determine when the
mouse is above the control.

How do you create a 2 events that determine when the cursor enters and
leaves your custom control?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top