从 Telerik radconfirm 调用 C# 代码
是否可以从 Telerik radconfirm 调用 C# 代码?我可以让它调用 Javascript,但没有服务器端代码。我希望用户单击一个按钮,给他们一个弹出框(radconfirm)。使用 radconfirm - 如果用户选择“是”,则将执行 C# 代码,如果单击“取消”,则不会执行任何代码
<asp:Button
ID="button1"
runat="server"
CssClass="resetOk"
Text="OK"
OnClientClick="radconfirm('<h3 style=\'color: #333399;\'>
Are you sure you want to reset this budget?</h3>',confirmCallBackFn,
330, 100,null,'Confirm Reset'); return false;"
/>
Is it possible to Call C# code from a Telerik radconfirm? I can make it call Javascript, but no server side code. I want the user to click a button which gives them a popupbox (radconfirm). With the radconfirm - if the user selects "yes" the c# code will be executed, if they click "cancel" no code will be executed
<asp:Button
ID="button1"
runat="server"
CssClass="resetOk"
Text="OK"
OnClientClick="radconfirm('<h3 style=\'color: #333399;\'>
Are you sure you want to reset this budget?</h3>',confirmCallBackFn,
330, 100,null,'Confirm Reset'); return false;"
/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您(至少)有两个选项可以从 RadConfirm(或任何 JavaScript 事件)调用服务器代码。在客户端事件处理程序中,可以:
“偷偷回发”和过程
服务器端代码
MSFT AJAX)调用 Web 服务
执行代码
选项 B 优于选项 A,因为它避免了 ASP.NET 页面生命周期,并且是一种更轻、更快的执行服务器代码以响应客户端事件的方法。仅当您在服务器上执行的代码需要更新页面上的 ASP.NET 服务器控件时,才使用选项 A。
帮助您选择任一选项的参考:
使用 jQuery 调用 ASP.NET Web 服务
使用 RadAjaxManager 从 JavaScript 执行 AJAX PostBack
You have (at least) two options for calling server code from a RadConfirm (or any JavaScript event, for that matter). In the client-side event handler, either:
"sneaky postback" and process
server-side code
MSFT AJAX) to call a web service that
executes your code
Option B is superior to Option A because it avoids the ASP.NET Page Lifecycle and is a much lighter, faster way to execute server code in response to a client event. Only use Option A if the code you're executing on the server needs to update ASP.NET server controls on the page.
References to help you with either option:
Calling ASP.NET web services with jQuery
Executing AJAX PostBack with RadAjaxManager from JavaScript
您可以在页面上添加一个RadAjaxManager,然后在confirmCallBackFn中发出Ajax请求。这将在服务器上引发一个事件,您将能够执行服务器代码,而无需更新页面上的任何控件 - 请参阅 telerik help 了解实施细节。
You can add a RadAjaxManager on the page and then just make an Ajax request in your confirmCallBackFn. This will raise an event on the server and you will be able to execute server code without needing to update any controls on the page - see the telerik help for the implementation details.
您好,据我了解,您想要阻止 onclick 的执行,就像您可以使用标准确认弹出窗口一样,telerik 网站上有一篇知识库文章:使用 radconfirm 阻止执行线程
Hi from what I understand you want to block the execution of the onclick like you would be able to do with a standard confirm popup there is a knowledge base article on the telerik site: Block the execution thread with radconfirm