开发者

how to write/code javascript(mouseover event) using c# methods/ c# code

note

  • yes client side must be java script but my qustion is not that.

  • i am asking that can i use c# language to implement "actions" fired on "click side events" such as mouse over

  • the reason for this stupid question is that i remember some syntax of registering functions for particular events of formview, which are call when the event occurs (yes there ispostback involved"

  • is something like the above possible for client side events using c# or even vb.net

heres a scrap 开发者_如何学Pythonof what i am trying to ask

 protected void Page_Load(object sender, EventArgs e)
{



    Label3.Text = "this is label three";



    Label3.Attributes.Add("OnMouseOver", "testmouseover()");



}


protected void testmouseover()
{
    Label4.Text = "this is label 4 mouse is working!!";

}


That is not possible.

  • You can use AJAX, but you cannot use AJAX to directly manipulate the DOM.
  • You can use an UpdatePanel, but not (easily) for mouse events.
  • You can use Script#, which converts C# into Javascript.
    However, it would have nothing to do with server-side code


Does ClientScript.RegisterClientScriptBlock() have what you need?. Check here


You can do this by using page methods.

protected void Page_Load(object sender, EventArgs e)
{
    Label3.Text = "this is label three";
    Label3.Attributes.Add("OnMouseOver", "testmouseover()");
}

[webmethod]
public static void testmouseover()
{
    // Implement this static method

}

and then on client side do this:

<script type='javascript'>
function testmouseover()
{
    PageMethods.testmouseover();
}
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜