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 3305156
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:08:16+00:00 2026-05-17T21:08:16+00:00

I have an ASP.NET Image control declared as: <asp:Image runat=server ID=SortOrder AlternateText=Ascending ImageUrl=~/images/sort_ascending.gif CssClass=Ascending

  • 0

I have an ASP.NET Image control declared as:

<asp:Image runat="server" ID="SortOrder"
AlternateText="Ascending"
ImageUrl="~/images/sort_ascending.gif"
CssClass="Ascending"
EnableViewState="true"
 /> 

My JavaScript code is:

function ReverseSort() {
    var img = window.event.srcElement;
    if(img.className == "Ascending") {
        img.className = "Descending";
        img.alt = "Descending";
        img.src = "<%= ResolveClientUrl("~/images/sort_descending.gif") %>";
    } else {
        img.className = "Ascending";  
        img.alt = "Ascending";
        img.src = "<%= ResolveClientUrl("~/images/sort_ascending.gif") %>";
    }
}

I have added an “onclick” attribute to the Image control in my Page_Load code-behind like so:

protected void Page_Load(object sender, EventArgs e) {
    if (IsPostBack)
        return;

    SortOrder.Attributes.Add("onclick", "ReverseSort()");
}

This is my SortOrder.OnClick event for my Image Control:

if (SortOrder.AlternateText == "Ascending") {
    /* Sort ascending */
} else {
    /* Sort descending */
}

My problem is, the SortOrder.AlternateText is always “Ascending”. My code-behind doesn’t seem to recognized the changes to the properties made by my javascript.

  • 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-05-17T21:08:16+00:00Added an answer on May 17, 2026 at 9:08 pm

    I wouldn’t expect that to work. The attributes on the server side control do not map to the DOM attributes on the client side. Although setting the AlternateText on the server will output the requisite alt text, it’s not a two way street.

    What you could do is use a hidden server side control to keep the state of the sort. A hidden <asp:checkbox> which you toggle via javascript will do it.

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

Sidebar

Related Questions

I have a custom asp.net server control to display images.What I need now is
I have an Image control in my asp.net page. I gave an image url
I have a FileUpload Control and a image control on asp.net page as follows
In my application (asp.net) I have an image control which by default has an
I have an asp.net image control in one ASP.NET page and have a Memory
I am using an asp.net image button control. On page load I have the
I have ASP.NET form with an upload control for users to post an image.
I need to bind client side onLoad event with ASP.Net Image control. I have
I have FileUpload control on my ASP.NET page and Image control where I show
i have certain element in a asp.net control: <a href=# title= style=background-image: url('../i/foo/image.png')> but

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.