单击链接按钮时如何调用服务器端和客户端功能 [英] How to Call Server Side And Client Side function on Single Click of A Link Button
问题描述
你好..........
我有一个链接按钮.
在客户端上,单击此链接按钮,我正在通过javascript向用户显示一条消息.
但是我也想单击相同的按钮来更新数据库中的值.
(例如,我想对此进行反驳)
但是问题在于,整个事情正在< asp:repeater>中发生.控制.
因此,当我要单击按钮时,将执行客户端功能,但不会执行
在Repeater控件的"Itemcommand"中.
如果您有任何想法请建议我
在此先感谢.......
Hello..........
I have One Link Button.
On client click of this link button i am showing a message to the user via javascript.
But i want to update values in the database on click of the same button as well.
(e.g. I want to run counter on that ")
But the problem is that whole thing is happening in <asp:repeater> control.
so When i am going to click on button Client side function executes but IT does not go
in the "Itemcommand" of the Repeater control.
Suggest me if u have any ideas
Thanks in advance.......
推荐答案
嗨
例如
> http://stackoverflow.com/questions/2860132/execute-client-一键点击服务器端代码
http://forums.asp.net/t/1301318.aspx/1
谢谢
Hi
For Example
http://stackoverflow.com/questions/2860132/execute-client-server-side-code-with-one-click
http://forums.asp.net/t/1301318.aspx/1
Thanx
将此添加为链接"按钮.
Hi,
Add this as your Link Button.
<asp:LinkButton ID="LinkButtonTest" runat="server"
OnClientClick="javascript:alert('Hi');" onclick="LinkButtonTest_Click">Testing
并将其作为您后面的代码.
and this as your code behind.
protected void LinkButtonTest_Click(object sender, EventArgs e){
// code here.
}
您可以在OnClientClick事件中添加一个javascript函数以显示任何消息.
you can add a javascript function in OnClientClick event to show any message.
1.从您的javascript函数返回true,然后服务器端将被触发
2.您可以使用
1. Return true from your javascript function, then server side will be fired
2. u can use
__doPostBack(''" + UniqueIDWithDollars(ctrl) + @"'','''');
强制完全调用回发
这篇关于单击链接按钮时如何调用服务器端和客户端功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!