473,432 Members | 1,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,432 software developers and data experts.

How can I create this type of button?

Hello,

On an ASP.NET/VB web page I have an image button:

<asp:ImageButton id="btn" ImageUrl="..." Command="..."
CommandArgument="..."
CausesValidation="..." OnClick="OnClickMethod" runat="server"/>

How can I create a rollover effect? Is it possible?

Thanks,
Miguel

Nov 19 '05 #1
9 997
"Miguel Dias Moura" <md*REMOVE*moura@*NOSPAM*gmail.com> wrote in message
news:Oh**************@TK2MSFTNGP15.phx.gbl...
Hello,

On an ASP.NET/VB web page I have an image button:

<asp:ImageButton id="btn" ImageUrl="..." Command="..."
CommandArgument="..."
CausesValidation="..." OnClick="OnClickMethod" runat="server"/>

How can I create a rollover effect? Is it possible?


This has to be done in client-side JavaScript. You'd have an onmouseover
event handler to start the effect, and an onmouseout event handler to end
it. You can add these handlers to the button by calling

btn.Attributes.Add("onmouseover", "domouseover();");
btn.Attributes.Add("onmouseout", "domouseout();");

in the Prerender event of the page. You add the script for these two
functions by using Page.RegisterClientScriptBlock, also in PreRender.

As to what you do in the two functions, it's whatever you want the rollover
to look like. Just start the styles the same as domouseout will leave them.

John Saunders
Nov 19 '05 #2
You can also put the javascript right in the attribute, then you can very
easily make your image dynamic if you want base on a database or something
like that. You can try something like:

imgBtn.Attributes.Add("onmouseover","javascript:th is.src='./images/myimg2.gif'")
imgBtn.Attributes.Add("onmouseout","javascript:thi s.src='./images/myimg1.gif'")
"Miguel Dias Moura" <md*REMOVE*moura@*NOSPAM*gmail.com> wrote in message
news:Oh**************@TK2MSFTNGP15.phx.gbl...
Hello,

On an ASP.NET/VB web page I have an image button:

<asp:ImageButton id="btn" ImageUrl="..." Command="..."
CommandArgument="..."
CausesValidation="..." OnClick="OnClickMethod" runat="server"/>

How can I create a rollover effect? Is it possible?

Thanks,
Miguel

Nov 19 '05 #3
Here's the code for an image rollover button control that I made.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
/// <summary>

/// ImageRolloverButton Control

/// </summary>

[DefaultProperty("ImageURL"), ToolboxData(

"<{0}:ImageRolloverButton " +

"runat=server></{0}:ImageRolloverButton>")]

public class ImageRolloverButton :

System.Web.UI.WebControls.ImageButton

{

private string s;

/// <devdoc>

/// <para>Gets or sets the URL reference

/// to the image to display when the mouse

/// is moved over the image.</para>

/// </devdoc>

[Bindable(true), Category("Appearance"),

DefaultValue(""), Editor(typeof(

System.Web.UI.Design.ImageUrlEditor), typeof(

System.Drawing.Design.UITypeEditor))]

public virtual string RolloverImageUrl

{

get

{

string s = (string)ViewState["RolloverImageUrl"];

return((s == null) ? String.Empty : s);

}

set

{

s=value;

ViewState["RolloverImageUrl"] = s;

}

}

public override string ImageUrl

{

get {return(base.ImageUrl);}

set {base.ImageUrl=value;}

}

protected override void OnPreRender(EventArgs e)

{

Attributes.Add("onMouseOver", "this.src=MyImage" +

this.ClientID);

Attributes.Add("onMouseOut", "this.src='" +

base.ImageUrl + "'");

this.Page.RegisterStartupScript("MyImageKey" +

this.ClientID,"<script language=javascript>MyImage"

+ this.ClientID + "='" + s + "'</script>");

base.OnPreRender(e);

}

}

}

Nov 19 '05 #4
TJS
how does this get implemented ?
Nov 19 '05 #5
As a Class Library.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"TJS" <no****@here.com> wrote in message
news:Ov**************@TK2MSFTNGP11.phx.gbl...
how does this get implemented ?

Nov 19 '05 #6
TJS
hmmm, no...
it doesn't help
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:ec**************@TK2MSFTNGP12.phx.gbl...
As a Class Library.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"TJS" <no****@here.com> wrote in message
news:Ov**************@TK2MSFTNGP11.phx.gbl...
how does this get implemented ?


Nov 19 '05 #7
You create a new class library.
You paste the code.
You compile it into a DLL.
You reference the DLL from another project.
You add the DLL to your toolbox.
Drag & Drop.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"TJS" <no****@here.com> wrote in message
news:Oq*************@TK2MSFTNGP12.phx.gbl...
hmmm, no...
it doesn't help
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:ec**************@TK2MSFTNGP12.phx.gbl...
As a Class Library.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"TJS" <no****@here.com> wrote in message
news:Ov**************@TK2MSFTNGP11.phx.gbl...
how does this get implemented ?



Nov 19 '05 #8
TJS
you must be talking about VS stuff

I don't use VS
Nov 19 '05 #9
Well then you should be use to doing this kind of thing manually.
Compile the code into a DLL and use it in another project.
I suggest using Visual Studio though; it makes things much easier.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"TJS" <no****@here.com> wrote in message
news:ev**************@TK2MSFTNGP09.phx.gbl...
you must be talking about VS stuff

I don't use VS

Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Raghuram Banda | last post by:
Hi, Can any one help me, how to create a Radio button using DOM with default one option is selected Thanks in advance
1
by: Jenny | last post by:
Hi, Can I create an array of tags by assigning same name to these tags? For example, I have two <p> tags with the same name t1. But document.all.b.value=document.all.t.length does not...
2
by: strout | last post by:
It's a pain to create each button with 2 images: button_on.gif button_off.gif I am looking for a control that have on/off two states, preferred as BACKGROUND images and with button text on it. ...
4
by: Miguel Dias Moura | last post by:
Hello, I created a datalist in an ASP.Net / VB page. I display the image and price of a few products. When a user clicks an image I want to load the page "detail.aspx?number=id" and send the...
1
by: quickcur | last post by:
Hi, here is my code: <html> <head> <script type="text/javascript"> function setImage(num) { alert(num); }
3
by: Beamer | last post by:
Hi I am trying to build a roating slide effect in javascript. Basically, I have a list like below <ul id="slideShowCnt"> <li id="slide0"><img .../></li> <li id="slide0"><img .../></li> <li...
3
by: bluez | last post by:
I want to design a webpage where user can search the data from the database and list out the related records. Each of the record got a delete button which allow user to delete the record. ...
2
by: sowmram | last post by:
Hi, I'm trying to create a site very similar to wiki, where you can edit, save.. Generally update data for the future use... This particular program I wanna do it using javascripts... Please...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.