1.11M Members

onmouseover on C#

 
0
 

i am trying to call a C# fonction or event from a JS object.

i have this

<script language="javascript" type="text/javascript">
    function UpdPanelUpdate(){
        __doPostBack("????","");
    }
</script>

<a  onmouseover="UpdPanelUpdate()"> mose over me  </a>
<asp:Button ID="ClientID" runat="server" Text="Press ME" onclick="ClientID_Click1" />

i know that __doPostBack(" ",""); will cause my page to reload

my C# code looks like

using System; 
using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

public partial class _test__doPostBack : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e) 
{

}

public void ClientID_Click1(object sender, EventArgs e) 
{

mySub();

}

public void mySub() 
{
  // Action here 

}

}

the press event works just fine, but not the roll over

 
0
 

if you want to do something on mouseover event you can call the buttons click event on the c# side:
this is the example :

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    
    </div>
    </form>
</body>
</html>

Default.aspx.cs :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Button1.Attributes.Add("onmouseover", "this.click()");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Write("it works");
    }
}

create the files, run the code, you will understand.

 
0
 

That is a Good Post, Now What is the Attribute of the Button if it loses Focus ?

Thanks

 
0
 

That is a Good Post, Now What is the Attribute of the Button if it loses Focus ?

Thanks

onblur

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article