Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8019785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:29:46+00:00 2026-06-04T21:29:46+00:00

I’m trying to add a rollover image to a test DotNetNuke page I’m working

  • 0

I’m trying to add a rollover image to a test DotNetNuke page I’m working on but can’t seem to get the syntax right (totally new to c#). This should be a simple one for anyone with any experience of it, I’m sure.

I have so far tried several different things most of which result in an object reference error. This is the last thing I tried (note below in the code where I have placed this, the line simply went here as this is where other attributes are added, I imagine there is a more logical place to put the line?):

loginLink.Attributes.Add(" onmouseover", "this.src=(http://localhost/portals/_default/skins/BSAVA/Images/Nav/log_in_link_h.png);");

The pages loads without an error but rollover does not work. The link renders with this attribute:

onmouseover="this.src=(http://localhost/portals/_default/skins/BSAVA/Images/Nav/log_in_link_h.png);"

Clearly not correct.

The whole page code is as follow:

using System;
using System.Web;
using System.Web.UI;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using DotNetNuke.UI.Modules;

namespace DotNetNuke.UI.Skins.Controls
{

public partial class Login : SkinObjectBase
{

    private const string MyFileName = "Login.ascx";

    public string Text { get; set; }

    public string CssClass { get; set; }

    public string LogoffText { get; set; }

    public string login_link_img = "http://localhost/portals/_default/skins/BSAVA/Images/Nav/log_in_link.png";
    public string login_link_img_hover = "http://localhost/portals/_default/skins/BSAVA/Images/Nav/log_in_link_h.png";

    public string logout_link_img_hover = "http://localhost/portals/_default/skins/BSAVA/Images/Nav/logout_link_h.png";
    public string logout_link_img = "http://localhost/portals/_default/skins/BSAVA/Images/Nav/logout_link.png";

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        try
        {

            if (Request.IsAuthenticated)
            {

            loginLink.CssClass = "logoutLink"; 
            loginLink.ImageUrl = logout_link_img;

                if (!String.IsNullOrEmpty(LogoffText))
                {
                    if (LogoffText.IndexOf("src=") != -1)
                    {
                        LogoffText = LogoffText.Replace("src=\"", "src=\"" + PortalSettings.ActiveTab.SkinPath);
                    }
                    loginLink.Text = LogoffText;
                }
                else
                {
                    loginLink.Text = Localization.GetString("Logout", Localization.GetResourceFile(this, MyFileName));
                }
                loginLink.NavigateUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "Logoff");
            }
            else
            {

            loginLink.CssClass = "loginLink"; 
            loginLink.ImageUrl = login_link_img;


                if (!String.IsNullOrEmpty(Text))
                {
                    if (Text.IndexOf("src=") != -1)
                    {
                        Text = Text.Replace("src=\"", "src=\"" + PortalSettings.ActiveTab.SkinPath);
                    }
                    loginLink.Text = Text;
                }
                else
                {
                    loginLink.Text = Localization.GetString("Login", Localization.GetResourceFile(this, MyFileName));
                }

                string returnUrl = HttpContext.Current.Request.RawUrl;
                if (returnUrl.IndexOf("?returnurl=") != -1)
                {
                    returnUrl = returnUrl.Substring(0, returnUrl.IndexOf("?returnurl="));
                }
                returnUrl = HttpUtility.UrlEncode(returnUrl);

                loginLink.NavigateUrl = Globals.LoginURL(returnUrl, (Request.QueryString["override"] != null));

                if (PortalSettings.EnablePopUps && PortalSettings.LoginTabId == Null.NullInteger)
                {
                    loginLink.Attributes.Add(" onclick", "return " + UrlUtils.PopUpUrl(loginLink.NavigateUrl, this, PortalSettings, true, false, 200, 550)); 
                    loginLink.Attributes.Add(" onmouseover", "this.src=(http://localhost/portals/_default/skins/BSAVA/Images/Nav/log_in_link_h.png);");

                }
            }

        }
        catch (Exception exc)
        {
            Exceptions.ProcessModuleLoadException(this, exc);
        }
    }

}
}

I’ve done plenty of searching around and several methods seem to crop up some using JavaScript others not. Any help on this is greatly appreciated, thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:29:47+00:00Added an answer on June 4, 2026 at 9:29 pm

    I use this one to achieve the RolloverImage effect on an Image button:

    namespace My.Controls
    {
        /// <summary>
        /// Summary description for RolloverImageButton
        /// </summary>
        [DefaultProperty("Text")]
        [ToolboxData("<{0}:RolloverImageButton runat=server></{0}:RolloverImageButton>")]
        public class RolloverImageButton : ImageButton
        {
            [DefaultValue("")]
            [UrlProperty]
            [Bindable(true)]
            public virtual string ImageOverUrl
            {
                get
                {
                    if (null == ViewState["ImageOverUrl"]) return string.Empty;
                    else return Convert.ToString(ViewState["ImageOverUrl"]);
                }
                set { ViewState["ImageOverUrl"] = value; }
            }
    
            protected override void AddAttributesToRender(HtmlTextWriter writer)
            {
                writer.AddAttribute("onmouseover", "this.src='" + base.ResolveClientUrl(ImageOverUrl) + "'");
                writer.AddAttribute("onmouseout", "this.src='" + base.ResolveClientUrl(ImageUrl) + "'");
                base.AddAttributesToRender(writer);
            }
        }
    }
    

    You can use it in your markup as you would the ImageButton, but you can additionaly set the ImageOverUrl to it.

    To make the Control globaly available without including the namespace in in every page you can simply add a reference to your web.config like this:

    <system.web>
      ...
      <pages theme="..." controlRenderingCompatibilityVersion="..." clientIDMode="...">
        <controls>
          <add tagPrefix="mycontrols" namespace="My.Controls" />
        </controls>
      </pages>
    </system.web>
    

    You can then use all controls defined in the My.Control namespace in your markup like this:

    <mycontrols:RolloverImageButton runat="server" ImageUrl="~/Images/image1.png" ImageOverUrl="~/Images/image1_h.png" ... />
    

    If you do not want it to be a Button control, simply override the Image class, not the ImageButton class and call it RolloverImage. You should than have an image tag you can display in an ordinary HyperLink.

    Regards,
    Gerald

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.