Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > changing cursor of ImageButton

Reply
Thread Tools

changing cursor of ImageButton

 
 
Julia
Guest
Posts: n/a
 
      06-26-2006
Hi

I have developed a composite control containing an ImageButton. The user can
only press the ImageButton at some point. I would like to make the cursor of
the ImageButton normal all the time the ImageButton is not possible to press.
How do I do that?

Thanks in advance
Julia
 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      06-26-2006
Hi Julia,

If you set the image button's enabled property to false, the cursor should
stay at the default.

In a user control, you have to get a reference to the image button. Here's
some sample code (ASP.NET 2.0) in case it helps.

Let us know how you make out?

Ken
Microsoft MVP [ASP.NET]


' --imgbtn.ascx--

<%@ control classname="usrimgbtn" language="VB" %>

<asp:imagebutton id="ImageButton1" runat="server"
imageurl="http://www.gc.ca/images/flag.gif" /><br />
<br />
<asp:label id="lblEnabled" runat="server"></asp:label>


'-- imgbtncursor.aspx--
<%@ Page Language="VB" %>

<%@ register src="imgbtn.ascx" tagname="imgbtn" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub btnEnableDisable_Click _
(ByVal sender As Object, ByVal e As System.EventArgs)
Dim uc As UserControl
Dim imgbtn As ImageButton
Dim lbl As Label
uc = Page.FindControl("Imgbtn1")
If Not IsNothing(uc) Then
imgbtn = uc.FindControl("ImageButton1")
lbl = uc.FindControl("lblEnabled")
imgbtn.Enabled = Not imgbtn.Enabled
lbl.Text = imgbtn.Enabled.ToString
btnEnableDisable.Text = _
IIf(imgbtn.Enabled, "Disable", "Enable")
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Enable Disable button</title>
</head>
<body>
<form id="form1" runat="server">
<div>
&nbsp;<br />
<uc1:imgbtn id="Imgbtn1" runat="server" />
<br />
<br />
<asp:button id="btnEnableDisable" runat="server"
onclick="btnEnableDisable_Click" text="Disable" />&nbsp;</div>
</form>
</body>
</html>



"Julia" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> I have developed a composite control containing an ImageButton. The user
> can
> only press the ImageButton at some point. I would like to make the cursor
> of
> the ImageButton normal all the time the ImageButton is not possible to
> press.
> How do I do that?
>
> Thanks in advance
> Julia



 
Reply With Quote
 
 
 
 
Julia
Guest
Posts: n/a
 
      06-27-2006
Hi

It did not work to just set the ImageButton's enable property to false. I
also write all my code in C# so I dont write any asp.net.

But I have solved my problem by using StyleSheet like this:

..ImageButtonEnable
{
padding-left:5px;
padding-right:5px;
padding-top:5px;
}
..ImageButtonDisable
{
padding-left:5px;
padding-right:5px;
padding-top:5px;
cursor:default;
}

I dont know if it the best way to do but it works

Thanks
Julia

"Ken Cox [Microsoft MVP]" wrote:

> Hi Julia,
>
> If you set the image button's enabled property to false, the cursor should
> stay at the default.
>
> In a user control, you have to get a reference to the image button. Here's
> some sample code (ASP.NET 2.0) in case it helps.
>
> Let us know how you make out?
>
> Ken
> Microsoft MVP [ASP.NET]
>
>
> ' --imgbtn.ascx--
>
> <%@ control classname="usrimgbtn" language="VB" %>
>
> <asp:imagebutton id="ImageButton1" runat="server"
> imageurl="http://www.gc.ca/images/flag.gif" /><br />
> <br />
> <asp:label id="lblEnabled" runat="server"></asp:label>
>
>
> '-- imgbtncursor.aspx--
> <%@ Page Language="VB" %>
>
> <%@ register src="imgbtn.ascx" tagname="imgbtn" tagprefix="uc1" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <script runat="server">
>
> Protected Sub btnEnableDisable_Click _
> (ByVal sender As Object, ByVal e As System.EventArgs)
> Dim uc As UserControl
> Dim imgbtn As ImageButton
> Dim lbl As Label
> uc = Page.FindControl("Imgbtn1")
> If Not IsNothing(uc) Then
> imgbtn = uc.FindControl("ImageButton1")
> lbl = uc.FindControl("lblEnabled")
> imgbtn.Enabled = Not imgbtn.Enabled
> lbl.Text = imgbtn.Enabled.ToString
> btnEnableDisable.Text = _
> IIf(imgbtn.Enabled, "Disable", "Enable")
> End If
> End Sub
> </script>
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Enable Disable button</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <br />
> <uc1:imgbtn id="Imgbtn1" runat="server" />
> <br />
> <br />
> <asp:button id="btnEnableDisable" runat="server"
> onclick="btnEnableDisable_Click" text="Disable" /> </div>
> </form>
> </body>
> </html>
>
>
>
> "Julia" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi
> >
> > I have developed a composite control containing an ImageButton. The user
> > can
> > only press the ImageButton at some point. I would like to make the cursor
> > of
> > the ImageButton normal all the time the ImageButton is not possible to
> > press.
> > How do I do that?
> >
> > Thanks in advance
> > Julia

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to tell if cursor is sqlite.Cursor or psycopg2.Cursor dmaziuk Python 3 01-25-2011 04:52 AM
Declare Cursor error while implementing SCROLL CURSOR invy C Programming 4 12-28-2006 02:35 PM
Changing DEFAULT cursor to WAIT cursor in ASP =?Utf-8?B?VG9tYXMgS2VwaWM=?= ASP .Net 1 04-05-2005 07:42 PM
Changing the cursor on an ImageButton control. How? David Hearn ASP .Net 2 08-10-2004 01:24 PM
imagebutton:change the cursor from the server Naim Rizk ASP .Net Web Controls 0 09-12-2003 12:23 PM



Advertisments