添加onclick事件ASP.NET控件 [英] Adding OnClick event to ASP.NET control
问题描述
我想为我的面板
创建的OnClick
事件。到目前为止,现在大部分的谷歌搜索结果看上去或多或少是这样的:的添加onclick事件ASPNET标签。有什么办法,从javascript或面板属性调用codebehind功能?因为我想重定向用户到一个新的页面,在此之前,保存在ViewState中或的sessionState的一些信息。有什么建议么?
i would like to create OnClick
event for my panel
. So far now the most of the google results look more or less like this: adding onclick event to aspnet label. Is there any way, to call codebehind function from javascript or panel attributes? Because I would like to Redirect user to a new page and before that save some information in ViewSTate or Sessionstate. Any suggestions?
推荐答案
在您的Java脚本方法筹集 __ dopostback
打电话到服务器端方法
。
In your java script method raise a __dopostback
call to a Server side method
.
<script type="text/javascript">
function YourFunction()
{
__doPostBack('btnTemp', '')
}
</script>
其中的 btnTemp 是一个服务器端按钮,所以写在服务器端这个按钮,在那里你可以做处理,然后重定向到其他页面的onclick事件。
Where btnTemp is a server side button, so write a onClick event of this button on server side, where you can do the processing and then redirect to other page.
您可以在 DoPostBack有dopostback有很好的理解理解
这篇关于添加onclick事件ASP.NET控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!