如何在Linkbutton上应用jQuery函数 [英] How to Apply jQuery Function on Linkbutton

查看:97
本文介绍了如何在Linkbutton上应用jQuery函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jquery表单,可在页面上弹出一条消息.我有一个要在Linkbutton上设置的jquery函数.

目前我有:

I have a one jquery form that pops up a message on the page. I have one jquery function which I want set on Linkbutton.

Currently I have :

<li onclick="TINY.box.show({iframe:'User_News.aspx',boxid:'frameless',width:250,height:250,fixed:false,maskid:'bluemask',maskopacity:40,closejs:function(){closeJS()}})" style="color: #0000FF; font-size: medium; height: 28px;" id="l1" runat="server">View Message 


我想将此功能设置到c#的Linkbutton上.


I want to set this function onto the Linkbutton of c#.

推荐答案

使用OnClientClick事件代替onclick.
这应该工作.请参见以下代码.

Use OnClientClick event instead of onclick.
This should work. See following code.

<%@ page language="C#"%>
<script runat="server">
  
void LinkButton1_Click (object sender, EventArgs e)
  {
    Label1.Text = "Thank you for visiting our site.";
  }
  
</script>
<html>
<head id="Head1" runat="server">
    <title>LinkButton.OnClientClick Example</title>
</head>
<body>
  <form id="form1" runat="server">
    
    <h3>LinkButton.OnClientClick Example</h3> 
     
      <br />
      
      <h4>Click to navigate to Microsoft.com:</h4>     
      
      <br />
        
      <asp:linkbutton id="LinkButton1"

       text="Open Web site"

       onclientclick="Navigate()"

       onclick="LinkButton1_Click"

       runat=Server />
       
       <br /><br />
       
      <asp:label id="Label1"

        runat=Server>
      </asp:label>

    </form>
    
    <script language=javascript>
      function Navigate()
      {
        javascript:window.open("http://www.microsoft.com");
      }    
      
    </script>
</body>
</html>


<asp:linkbutton id="LinkButton1"
       text="Open Web site"
       onclick="LinkButton1_Click"
       runat="Server" />



< script>



<script>


(``#LinkBut​​ton1'').click(function(){
//您的代码在这里
});

</script>
(''#LinkButton1'').click(function() {
//your code goes here
});

</script>


这篇关于如何在Linkbutton上应用jQuery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆