Adding OnClick event to ASP.NET control(将 OnClick 事件添加到 ASP.NET 控件)
问题描述
我想为我的 panel
创建 OnClick
事件.到目前为止,大多数谷歌搜索结果或多或少是这样的:将 onclick 事件添加到 aspnet 标签.有没有办法从 javascript 或面板属性调用代码隐藏函数?因为我想将用户重定向到一个新页面,然后在 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 理解
这篇关于将 OnClick 事件添加到 ASP.NET 控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 OnClick 事件添加到 ASP.NET 控件


- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 输入按键事件处理程序 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- C# 中多线程网络服务器的模式 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01