Hi,
You can use doPostBack in JavaScript to trigger a function in CodeBehind.
ImageButton1.Attributes.Add("onmouseover", "javascript:__doPostBack('ImageButton1','onmouseover')");
Code Behind:
In Page_Load, it needs to retrieve the doPostBack.
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params["__EVENTTARGET"] != null)
{
string target = Request.Params["__EVENTTARGET"].ToString();
string passedArgument = Request.Params["__EVENTARGUMENT"].ToString();
if (target == "ImageButton1" && passedArgument == "onmouseover")
{
multiview1.activeviewindex = 0;
}
}
}
And then you should define __doPostback JavaScript function.
If you page contains a Linkbutton control, it will be generated by ASP.NET. If not, you should create it manually. Define two hidden controls is necessary.
<script language="javascript">
function __doPostBack(eventTarget, eventArgument)
{
var theform;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
theform = document.forms["form1"];
}
else {
theform = document.form1;
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
</script>
<body>
<form id="form1" runat="server">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="" />
Hope it helps.