Tech Off Thread

15 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Mouse Over in ASP.NEt

Back to Forum: Tech Off
  • User profile image
    arun_coorg

    HI Friends ,

      
       Is there any way I can use mouseover in asp.net. I believe its not possible.

    What is the alternative?  


    Thanks


    Arun


  • User profile image
    W3bbo

    Consider that ASP.NET is executed on the server and that the "click" event for <Asp:Button /> doesn't work in any way similar to System.Windows.Forms.Button

    What kind of effect are you trying to do anyway?


    On a side note, this is the sort of thing that gets me annoyed, people who dive straight into the technical side without fully appreciating the theory behind it. Read up on the ASP.NET page lifecycle and the theory behind stateless HTTP connections.

    Things like "click" and "hover" should be handled by the client if its for presentational effects. "hover" effects shouldn't incurr any kind of "active" data transfer.

  • User profile image
    arun_coorg

    Hi ,
     
         I wanted to get some effects like mouseeover for menus(client effects like in frontpage).

    I  know ASP.NET is server side ...are there any ways i

    get effects similar to mouseover. Isnt there any other

    options other than for Flash.

    Thanks

    Arun

  • User profile image
    Yggdrasil

    arun_coorg wrote:
    Hi ,
     
         I wanted to get some effects like mouseeover for menus(client effects like in frontpage).

    I  know ASP.NET is server side ...are there any ways i

    get effects similar to mouseover. Isnt there any other

    options other than for Flash.

    Thanks

    Arun


    The simplest way is simply to use the HtmlControls rather than the WebControls. These map directly to HTML elements, so you can simply add the onmouseover attribute to the tag.

    If you want to use the WebControls, however, there is still a way. Even though a WebControl isn't necessarily rendered as one HTML tag, in the end, most of them are. An asp:Label is rendered as a <SPAN>. An asp:Button is an <input type="submit">, and so forth. This, at least, is how it is rendered on IE. You can take advantage of this and the fact that ASP.NET will pass any unknown attributes through.
    If you write code like this:


    <asp:Button runat="server" onmouseover="doRollOver()" />

    you might get a wiggly line saying onmouseover is unrecognized, but the ASP.NET parser will leave it in and pass it through to the <input type="submit"> that's generated.

    In some cases, this might not work - if we want to catch the client-side onclick event for a button, but adding OnClick to the tag specifies the server-side event, we can do it through code. In the Page_Load or CreateChildControls methods in our code, we can add the following line:


    myButton.Attributes.Add("onclick", "HandleClick");


    This will add the onclick attribute to the generated control.

  • User profile image
    W3bbo

    arun_coorg wrote:
    Hi ,
     
         I wanted to get some effects like mouseeover for menus(client effects like in frontpage).

    I  know ASP.NET is server side ...are there any ways i

    get effects similar to mouseover. Isnt there any other

    options other than for Flash.

    Thanks

    Arun


    Depends on what sort of "effects" you're after.

    I recommend you read this for menus first and have a strong knowledge in ECMAScript..

  • User profile image
    TooMuch204

    You use the mouse over by doing adding some code in the asp page. Sample of the code:

    <asp:Button ID="Button1" runat="server" Text="" onmouseover="this.style.textDecoration='underline'" onmouseout="this.style.textDecoration='none'" style="cursor:pointer"
                    BorderStyle="None" Width="20px" CssClass="SearchButton"/>

  • User profile image
    Dallas Steve

    W3bbo said:
    Consider that ASP.NET is executed on the server and that the "click" event for <Asp:Button /> doesn't work in any way similar to System.Windows.Forms.Button

    What kind of effect are you trying to do anyway?


    On a side note, this is the sort of thing that gets me annoyed, people who dive straight into the technical side without fully appreciating the theory behind it. Read up on the ASP.NET page lifecycle and the theory behind stateless HTTP connections.

    Things like "click" and "hover" should be handled by the client if its for presentational effects. "hover" effects shouldn't incurr any kind of "active" data transfer.

    W3bbo, The Master of Baiters, writes:

    On a side note, this is the sort of thing that gets me annoyed, people who dive straight into the technical side without fully appreciating the theory behind it. Read up on the ASP.NET page lifecycle and the theory behind stateless HTTP connections.


    Dear MasterBaiter

    His question is entirely appropriate and I'm glad he asked it.  I had the same question and Yggdrasil had a helpful answer.  Just because we had this question doesn't mean we don't know how an ASP.NET page works.  I happen to be MCSD certified in both C#.NET and VB.NET and I've been using ASP.NET at work for over 3 years.  Still, I wondered if there's a better way to blend client-side effects into an ASP.NET page.  Apparently there's not.  I'll use the HTML and Web controls as Yggdrasil described.

    Maybe you should spend less time "masterbaiting" on these forums.

    Dallas Steve

     

  • User profile image
    Dallas Steve

    W3bbo said:
    Consider that ASP.NET is executed on the server and that the "click" event for <Asp:Button /> doesn't work in any way similar to System.Windows.Forms.Button

    What kind of effect are you trying to do anyway?


    On a side note, this is the sort of thing that gets me annoyed, people who dive straight into the technical side without fully appreciating the theory behind it. Read up on the ASP.NET page lifecycle and the theory behind stateless HTTP connections.

    Things like "click" and "hover" should be handled by the client if its for presentational effects. "hover" effects shouldn't incurr any kind of "active" data transfer.

     Ooops!  Hit the Add button twice. 

  • User profile image
    stevo_

    Perhaps you should get a life, and fyi- MCSD aka ' I can ace a multiple answer question set where the answers are determined by reading purchased reading material, and not reality '.. means nothing.. so don't come here waving your fancy certificates around bitching at the past.

    Edit: I'd like to note the irony here as well, you state 'I know how ASP.NET works', where as the whole point w3bbo made was that people clearly don't understand how http / html works and SHOULD if they dev web applications, lest they burden the world with yet more security / usability horrors.

  • User profile image
    W3bbo

    stevo_ said:
    Perhaps you should get a life, and fyi- MCSD aka ' I can ace a multiple answer question set where the answers are determined by reading purchased reading material, and not reality '.. means nothing.. so don't come here waving your fancy certificates around bitching at the past.

    Edit: I'd like to note the irony here as well, you state 'I know how ASP.NET works', where as the whole point w3bbo made was that people clearly don't understand how http / html works and SHOULD if they dev web applications, lest they burden the world with yet more security / usability horrors.
    Furthermore he was judging me by a posting I made 4 years ago. I think the C9 devs need to add a "please don't resurrect posts unless necessary" warning or something.

  • User profile image
    figuerres

    W3bbo said:
    stevo_ said:
    *snip*
    Furthermore he was judging me by a posting I made 4 years ago. I think the C9 devs need to add a "please don't resurrect posts unless necessary" warning or something.
    seconded!  I hate it when I see a thread that's *YEARS* old suddenly pop up and come back from the grave exp. when it's for no good reason at all.

    i wonder for example just how and why this one came back? did the guy google and find it and then not care that it was dead?

    oh well, time to put in a feature request to the 9-team-devs

  • User profile image
    Ion Todirel

    figuerres said:
    W3bbo said:
    *snip*
    seconded!  I hate it when I see a thread that's *YEARS* old suddenly pop up and come back from the grave exp. when it's for no good reason at all.

    i wonder for example just how and why this one came back? did the guy google and find it and then not care that it was dead?

    oh well, time to put in a feature request to the 9-team-devs
    ++

  • User profile image
    littleguru

    W3bbo said:
    stevo_ said:
    *snip*
    Furthermore he was judging me by a posting I made 4 years ago. I think the C9 devs need to add a "please don't resurrect posts unless necessary" warning or something.
    ... and on the other side it shows us that posts in a forum are statements that stay there for a veeeeeery long time!

  • User profile image
    SlackmasterK

    Dunno what you want to accomplish. Many controls have a Tooltip property and many HTML controls let you add a Title element.

    You can always use Javascript onMouseOver and onMouseOut events.  I hate to suggest it, though.

  • User profile image
    SlackmasterK

    SlackmasterK said:
    Dunno what you want to accomplish. Many controls have a Tooltip property and many HTML controls let you add a Title element.

    You can always use Javascript onMouseOver and onMouseOut events.  I hate to suggest it, though.

    *Deleted*

    I really should read the whole thread.

    Tried to edit the post, failed... Interesting that when the java error popped up and I clicked 'Edit', my text input wasn't cleared.  Bah.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.